5. Setup and start Eliza agent
Last updated
Last updated
Eliza-Starter is a template from Eliza framework to allow developers to create characters, clients and plugins. In this starter, a plugin called GetGift is created to call functions consumer smart contract deployed in previous steps.
Let's get ready to use the Eliza AI Agent Framework with the GetGift Eliza plugin by following steps:
Check the .env.example
file and make sure your .env
file has all the indicated environment variables. We will need the Google Gemini key, evm private key and avalanche fuji rpc url set correctly in the .env
.
Open the file src/custom-plugins/actions/getGift.ts
, and paste in the necessary configurations which are marked as TODOs. To make the actions to send transactions as we requested, these constants must be updated:
contractAddress
: the address of Functions consumer smart contract. Update the value with contract you added to the the Chainlink Functions subscription.
donHostedSecretsSlotId
: the slot ID for secret saved in the DON. If you did not modify the script in last step, assign the default one to the the constant. The default value is 0
.
In GetGiftAction Class, core functionalities to interact with the smart contract are implemented, and wallet provider which is a wrapper of viem used to handle blockchain interactions. Within the class, the function getGift
parses parameters and extract gift and grantee's address and then make a call to the hardcoded smart contract with necessary data.
The other exported object is Action getGiftAction which is the "configuration" of the plugin. The plugin is registered with agent as an entry to make the action.
After config info updated, run the agent with default character using the following command (⚠️ remember to check that your using node V23 or higher!)
If your AI agent start successfully, you will see the info below:
Ask for a NFT gift
Have your wallet address and one of the 3 gift codes ready. Then type your request in natural language - use can use the following template:
please send the gift to: <<YOUR_WALLET>> My gift code is: <<GIFT_CODE_IN_DATABASE>>
Type this into your terminal as show below:
Check the responses
The AI agent will process the request and return the message and transaction hash. You will the see the info below:
Check the Chainlink Functions app
Check if a NFT minted for a specific address
Please be noticed that the same gift codes cannot be redeemed twice which means you cannot have the duplicated gift on the address.
Git clone the repo:
`git clone `
Then change directory into the Eliza-Twitter-Chainlink-Functions
project folder and run.
Update variables in action implementation file getGift.ts
()
donHostedSecretsVersion
: the version of secret saved in the DON you uploaded in last step. You can find the value in your Remix IDE terminal. In last step, you have already uploaded secret to the DON, when making the request, you must pass the donHostedSecretsSlotId
and donHostedSecretsVersion
to tell the DON where to fetch the encrypted secrets. Both of these things should be printed to your Remix IDE terminal from the.
clSubId
: Chainlink Functions Subscription ID. Update the value to the subscription ID you created on the .
getGift.ts
implements a custom for interacting with a Chainlink Functions consumer contract on the Avalanche Fuji testnet. Here's a breakdown of its main components:
After the action in AI agent is processed, a transaction is sent to the Functions consumer smart contract deployed before. The contract constructs a new Functions request with gift ID and send to the DON, and the the request is displayed on .
Go to the to check if you have a new NFT. Paste the address of your GetGift
contract into the OpenSea search bar, and you can see the NFT(s) minted to your address!