AI Agents
Introduction
AI agents are transforming interactions with decentralized applications by simplifying interfaces and enabling automation. These agents operate autonomously, executing tasks based on predefined logic, user inputs, and on-chain events. They are increasingly utilized in decentralized finance (DeFi) AI applications, where they manage assets, execute trades, and even facilitate decentralized autonomous organizations (DAOs). However, integrating AI agents with blockchain infrastructure requires a flexible and modular framework that can support both on-chain and off-chain interactions.
What is ElizaOS?
ElizaOS is a modular, blockchain-agnostic AI agent framework designed to streamline the creation of autonomous Web3 AI agents. It provides a flexible, pluggable architecture that supports integration with multiple blockchains, AI models, and automation tools.
Why Use ElizaOS?
Blockchain-Agnostic – Supports multiple blockchain networks.
Modular Design – Enables customization and easy integration.
On-Chain & Off-Chain Interactions – Facilitates AI agents interacting with smart contracts and external APIs.
Seamless Web3 Integration – Supports Gelato Relay as part of the official plugin
Architecture Overview
ElizaOS is structured into four key components:
Adapters – Manage data exchange between AI agents and external sources.
Characters – Define agent behavior and interaction logic.
Clients – Handle communication across different platforms.
Plugins – Extend functionality, including Web3 integrations and automated workflows.
This modular architecture allows developers to build customizable AI agents with efficient interaction logic while maintaining a clear separation of concerns.
To learn more about ElizaOS, refer to their extensive docs here and github repo here
Plugin: Gelato
The plugin-gelato
extends ElizaOS by enabling AI agents to interact with Gelato Relay for gasless transactions. It supports:
sponsoredCallERC2771 – Uses a sponsor API key along with a user's signature (e.g., from MetaMask) to securely sponsor gasless transactions. The payment is handled via Gelato's 1Balance system. The Gelato Relay SDK includes various methods for managing sponsored ERC2771 transactions, with
sponsoredCallERC2771
being the most direct way to sign and send transactions in a single step. Other SDK methods allow for separating these processes when needed.sponsoredCall – Utilizes authentication through a sponsor API key to sponsor gasless transactions for users. The payment mechanism is also managed via Gelato's 1Balance system, allowing for seamless execution of transactions without requiring users to hold native tokens.
This plugin enables seamless integration of Web3 automation into AI agents, allowing them to interact with smart contracts efficiently and without requiring direct user gas payments.
Use Case: CoinFlip AI – On-Chain Betting
CoinFlip AI is a decentralized game that showcases the integration of ElizaOS with Gelato's Web3 services. Players interact with an AI agent called FlipMaster through a chat interface to place bets, while a smart contract on INK Sepolia manages the game logic. The system runs a local ElizaOS server for each player and includes a backend server to track game states and betting statistics. The code and documentation are open-source.
How CoinFlip AI Works
A player places a bet via the AI agent.
The bet is relayed to a smart contract on INK Sepolia through Gelato Relay, allowing gasless transactions.
Gelato Web3 Functions batch bets every minute and process them on-chain.
At the end of each round, Gelato VRF provides a verifiable random outcome.
The game determines winners based on the outcome and distributes rewards.
Players can query the AI agent to check if they won, with all results verifiable on-chain.
Quick Start
Follow these steps to set up and run the CoinFlip AI agent:
Clone and checkout the correct branch:
Set up environment variables:
Edit the .env
file and configure the required variables:
Install dependencies and build:
Start the agent:
Start the client interface:
In a new terminal window, run:
Then, open your browser and navigate to the URL displayed in the terminal (usually http://localhost:3000
).
Additional Resources
For a more detailed guide, refer to the blog post: How to Create Crypto AI Agents with ElizaOS and Gelato.
The full source code and setup instructions are available in the GitHub repository: CoinFlip AI Agent.
Last updated