BLOG — Developer Tutorials

7 days ago

How to Create Crypto AI Agents With ElizaOS & Gelato

Introduction

AI agents have ushered in a golden age of interface simplification. Intuitive, user-friendly interfaces accessible to all. The AI agent framework landscape has evolved significantly, with platforms like Eliza, Virtuals, and arc.fun (built on rig framework) leading the way in autonomous AI agent development. These platforms and frameworks are driving the growth of the agentic economy, particularly in Decentralized Finance AI (DeFAI), where AI agents can independently own assets, trade, and form DAOs.

Web3-native AI frameworks, while promising, are held back by fundamental limitations. Data fragmentation across platforms, high gas costs, and limited cross-chain functionality create significant barriers to widespread adoption.

Frameworks such as Eliza, are bridging this gap. ElizaOS is a blockchain-agnostic framework that simplifies the creation and deployment of autonomous AI agents across both Web2 and Web3 platforms. ElizaOS has seen significant growth in recent months, with increasing adoption and expanding use cases in areas such as automated trading and community management.

ElizaOS's capabilities can be significantly enhanced through integration with Gelato's Web3 Services infrastructure. Gelato provides key infrastructure components that address common challenges in onchain AI agent development: automated transaction management across EVM chains, gasless operations through its Relay network, verifiable random number generation, and decentralized automation through Web3 Functions. This integration offers developers a practical foundation for building onchain AI agents that can operate effectively across blockchain networks while maintaining security.

Understanding the ElizaOS Framework and Plugins

ElizaOS features a decoupled structure with a core runtime and four key components: adapters (for data management), characters (for defining agent personalities), clients (for message interactions across platforms), and plugins (for extensible functionality).

Each component interfaces with the runtime independently, allowing developers to add or modify components without affecting the others. This modular approach enables easy extension of the system's capabilities.

The design of ElizaOS puts developers first, using a pluggable modular design, and maintaining system simplicity while ensuring functionality. This approach allows Eliza to support various model providers, platform integrations, chain compatibilities, and advanced functions through its extensible architecture.

Understand ElizaOS Without Reading the Docs

The runtime environment is TypeScript-based and manages the agent's core operations: state, memory, and message processing. It serves as the foundation where all components interact.

How ElizaOS Processes & Parses

Traditionally, programming agents involved hardcoding specific rules, parameters, and decision-making logic. This made the behavior of agents predictable and limited to the scope of their programming. ElizaOS however, implements a flexible architecture combining LLMs with retrieval-augmented generation (RAG) and a modular plugin system. Through its runtime environment, agents can dynamically compose context from conversation history and retrieve knowledge, while extending their capabilities through pluggable components.

Intelligent Components of ElizaOS

Character files use JSON configurations to define agent behavior and capabilities. They maintain the agent's base traits, knowledge, and interaction patterns that determine how it responds to different situations.

Integration & Extensibility of ElizaOS

The client module handles message interactions between the agent and various platforms like Discord, Twitter, Telegram, and Farcaster. It's one of the core components responsible for managing communication across different integrated platforms.

The plugin system makes the entire platform expandable, allowing developers to add new features through modular components. Whether adding media generation capabilities or integrating new blockchain features, plugins can extend the system's capabilities without disturbing its core architecture. Each plugin follows a defined interface that specifies its name, description, and optional components like actions, providers, etc.

AI Agents & Environments of ElizaOS

Adapters standardize data between the runtime and blockchain networks, enabling seamless web3 interactions by transforming on-chain data, transaction information, and smart contract events into formats the agent system can process. Their modular design lets developers customize blockchain data handling independently of other components.

Agents are the core entities that handle autonomous interactions in Eliza. Each agent processes messages, maintains its state, executes actions, and evaluates responses while behaving consistently across different platforms.

Actions are fundamental to defining how agents interact with messages and perform complex tasks. They contain structured definitions for validating and handling operations, enabling agents to interact with external systems, process workflows, and execute functions like token transfers and smart contract interactions.

Providers supply dynamic context and real-time data to agents, acting as intermediaries to external systems for market data, wallet information, and other contextual data. Basic providers include Time, Facts, and Boredom providers for managing different aspects of agent interactions.

Evaluators assess conversations and extract valuable information, helping agents build long-term memory, track goals, extract facts, and maintain context awareness. They're primarily used for fact extraction, goal tracking, and verifying agent functionality in edge cases.

Key Capabilities of ElizaOS

Multi-chain support

ElizaOS offers multi-chain support through its plugin architecture, specifically within its Web3 Integration Plugins. The system is compatible with a variety of blockchain ecosystems, including:

  1. Ethereum-compatible chains (EVM compatibility)

  2. Solana, with additional features like trust scoring and wallet management

  3. Several other prominent blockchains such as Aptos, Conflux, Flow, MultiversX, Near, Sui, TON, ICP, and zkSync Era

ElizaOS also integrates GOAT (Great Onchain Agent Toolkit) for cross-chain operations, enhancing its ability to work across different blockchain networks. This cross-chain capability has been further strengthened by the addition of Gelato Relay to the ElizaOS Plugin Registry, enabling gasless transactions and simplified transaction management across 40+ EVM chains. Through this integration, developers can now build applications that work smoothly across various blockchain networks without dealing with complex gas fee logistics. This helps reduce fragmentation and makes development much easier.

Social platform integration

ElizaOS allows AI agents to engage across major platforms like Discord and Twitter, while maintaining consistent behavior and memory through its runtime system. This means that each agent can now operate simultaneously across multiple platforms while preserving its core character traits and decision-making capabilities.

Token/NFT operations and management

The framework manages token and NFT operations through specialized plugins that handle basic transfers and smart contract deployments. For tokens, the system provides features for calculating buy amounts, tracking portfolio values, and executing swaps. It supports NFT collection generation and deployment, and handles various collection attributes and blockchain integrations. Token and NFT functionalities are managed through a token provider for market calculations and trading, and a wallet provider for managing portfolios and values.

Trust score evaluation system

The trust score evaluation system in Eliza functions as a critical security layer for transactions by combining token performance metrics with recommender credibility to assess overall trustworthiness. The system processes two main components:

  1. Token performance data which examines historical price movements, liquidity metrics, and market behavior patterns.

  2. Recommender metrics that evaluate the track record and reliability of entities making token or transaction recommendations.

This is very important as it checks the safety of token swaps and blockchain interactions. It does this by comparing calculated trust scores against minimum thresholds before allowing transactions to proceed.

Intent recognition system

Eliza's intent recognition works by combining two parallel processes. The first handles direct action matching, where it identifies the primary intent and checks for similar variations in how a user might express that intent. The second process handles context—it looks at the current conversation state, the user's history, and any relevant background knowledge. These two processes work together through a memory system that tracks conversations, stores knowledge and maintains relationship data.

The system parses user input through both paths simultaneously—checking for specific actions while also evaluating the broader context. This helps it understand both what a user is explicitly asking for and what they might mean based on the full context of their interaction. It's particularly important for Web3 interactions where misinterpreting user intent could lead to incorrect financial transactions or smart contract interactions.

What ElizaOS V2 Will Bring

ElizaOS released their V2 product roadmap outlining three major system upgrades. At the core of V2, it introduces a technical separation between core platform code and plugin extensions. This creates a cleaner development environment where plugins can be built and updated without affecting the platform's core code, and platform updates won't break existing plugins.

Alongside this architectural change, ElizaOS is launching a new Agent Marketplace that serves two key functions: a token launchpad and a no-code platform for AI agent creation. The marketplace integrates with existing ElizaOS components through multi-agent functionality and shared tokenomics and is positioned as essential infrastructure for future agent-based development.

To support these new features, ElizaOS has developed a custom liquidity provider solution. This LP solution will launch together with the platform's tokenomics and is an integral part of how the platform will handle liquidity for the various tokens and agents within the ecosystem.

Gelato Web3 Services - Enabling AI Agent Infrastructure

Web3 automation faces fundamental challenges due to how blockchains are designed. Ethereum and similar networks are deterministic—meaning they always produce the same output given the same input. However, the real world and the internet are constantly changing and unpredictable. This creates a major disconnect: smart contracts struggle to interact with real-world data and systems outside the blockchain.

Gelato is already powering several prominent AI projects in the blockchain space. SingularityFi builds its L2 on Gelato to bring the AI economy onchain, bridging DeFi and AI tokenization with a new asset class of tokenized yield-bearing AI compute. Freysa is an AI agent designed to protect its funds by rejecting transfer requests. In a challenge to convince Freysa to release its prize pool, participants used Gelato Relay's gasless transaction service to send persuasive messages. Anomaly functions as an L2 game publisher targeting Telegram's 900M daily users, fueled by the Anomaly AI SDK, which introduces advanced features like player model training and automated quest creation. These examples demonstrate how Gelato's services are becoming foundational infrastructure for the emerging AI-economy on blockchain.

Core functionalities

Gelato Functions

Web3 Functions (W3F) provide a way to automate smart contract tasks using Solidity functions for pure on-chain operations, TypeScript functions for cases that need off-chain data or computation, and automated transactions for simple predefined operations with fixed inputs. When you create a W3F, you specify trigger conditions (a smart contract event) that determine when it should execute. Gelato’s executors monitor these triggers and run the function code when the conditions are met. This enables agents to respond to blockchain events and automate actions, effectively bridging on-chain triggers with off-chain agent logic and actions.

Gelato Relay

Gelato Relay lets users send transactions without having native tokens (like ETH) for gas fees. It works by having users sign a message instead of sending a direct transaction. The gas fees are covered either by the dApp developer through 1Balance or by the user paying with supported ERC-20 tokens.

The 1Balance system acts as a unified gas tank that works across different networks. A developer can deposit funds once and cover transaction costs on multiple chains, with the Paymaster component directing funds as needed. The security is handled in two parts:

  1. EIP-712 - Makes sure signed messages can’t be tampered with

  2. ERC2771 - Verifies on-chain that a transaction is coming from Gelato's trusted forwarder (the Gelato Relay contract)

The Relay can greatly simplify transaction execution for agents by replacing direct gas-based transactions with message signing and effectively removing the need for agents to manage gas.

Gelato VRF

Blockchains have a fundamental issue with randomness—all nodes need to reach a consensus and produce the same result when processing transactions. This makes "random" numbers generated purely on-chain to be theoretically predicted or manipulated. Miners/validators could choose to process or withhold transactions based on how the randomness would affect outcomes, and developers could potentially code contracts to take advantage of known random number generation patterns.

VRF (Verifiable Random Function) solves this by moving the random number generation off-chain while maintaining verifiability on-chain. It combines the generation of random numbers with cryptographic proof of correctness. When Drand (a decentralized randomness beacon) generates a random number, it also produces proof that can be independently verified by anyone to confirm the number wasn't manipulated. Once generated, the random number and its proof are sent back to the requesting contract through a callback function.

AI agents now can make provably random decisions with VRF by allowing them to request and receive verifiably random numbers off-chain, which can then be used as inputs for decision-making processes.

How to Build a Crypto AI Agent Using Gelato: A Reference Implementation

All code & docs are available to clone from open-source repositories

Tutorial: youtube.com/watch?v=XLLhsTCMsvo

Tutorial Repo: github.com/gelatodigital/coinflip-ai-agent-eliza​​

Gelato Docs: docs.gelato.network/

ElizaOS Docs: elizaos.github.io/eliza/docs/intro/

ElizaOS repo: github.com/elizaOS/eliza

What is Coinflip Al?

CoinFlip AI is a game that demonstrates the integration of ElizaOS with Gelato's Web3 services through a practical betting application. All code and documentation are available in our open-source repository. 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 uses a local ElizaOS server for each player and includes a backend server for tracking both game states and betting statistics.

How It Works

When a bet is placed, it's relayed to the smart contract on INK Sepolia through Gelato Relay, enabling gasless transactions. The game operates in one-minute rounds, managed by Gelato Web3 Functions that query for all bets placed during that period. When a round ends, the system requests a random outcome from Gelato VRF, which determines heads or tails and subsequently the winners. Players can then ask the AI agent "did I win?" to check their results, and the entire process is verifiable on-chain.

Setup Developer Environment

To set up the development environment, developers need Node.js 23.3.0 and PNPM package manager. The project requires configuring environment variables in .env for: wallet private key for transaction signing, Gelato Relay API key for gasless transactions, and optionally an OpenAI API key if using GPT-4 for the AI agent (though other models like Llama can be used). After configuration, the implementation requires running pnpm install in both root and agent directories, followed by pnpm build to compile the project.

The game runs through two main components: a backend server that hosts the ElizaOS agent (pnpm start) and a frontend client (pnpm start client) that provides the chat interface. Before playing, users must deposit a minimum of 0.01 ETH to the contract. Players interact with the AI agent "FlipMaster" through the chat interface to place bets on heads or tails. When bets are placed, Gelato Relay handles the gasless transactions to the smart contract.

Every minute, a Gelato Web3 Function queries for placed bets and triggers the round resolution. The contract requests randomness through Gelato VRF, which provides a verifiable random outcome to determine winners. Results can be verified through contract events and queried through the chat interface. This demonstrates how Gelato's services can work together to provide automated, gasless, and verifiably random blockchain interactions through an AI interface.

Behind the Scenes

The implementation leverages three key Gelato services: Relay for handling gasless transactions, W3F for managing game rounds at one-minute intervals, and VRF for generating verifiable random outcomes. The game's smart contract builds on Gelato's randomness system to handle all core game mechanics, including accepting bets, managing game rounds, and selecting winners. At the end of each round, the contract automatically requests a random number from Gelato's secure random number service, which then determines the outcome and identifies which players have won.

ElizaOS integration brings the AI element to life. The plugin-gelato interface enables the AI agent to interact with blockchain functions seamlessly. The agent's personality and responses are carefully crafted to provide a friendly and intuitive user experience. This integration demonstrates how AI can make blockchain interactions more accessible to average users.

Outlook

The future of AI agents extends far beyond simple automation. Traditionally, bots merely relayed information but now AI agent KOLs such as $aiXBT can analyze market trends in real-time, generate actionable investment insights, and adapt strategies based on changing market conditions. In October 2024, truth_terminal became one of the first notable onchain AI agents when it launched the GOAT memecoin, which quickly crossed a market cap of $1 billion.

Our development of Coinflip represents just the beginning of AI agents in gaming environments. While currently a straightforward heads-or-tails implementation, it points toward a future where AI agents could be trained to understand individual risk preferences, engage in strategic games like poker and chess, and operate as autonomous participants that learn and adapt from each interaction. This evolution in gaming capabilities parallels developments in prediction markets, where Olas Predict on the Gnosis Chain is already demonstrating more advanced AI agent functionality. By automating market creation, analyzing complex data streams, and assessing probabilities in real-time, these systems are advancing how we aggregate and interpret market signals.

Last week, we saw how AI agents can be used for automated shopping (in this case Amazon) and paying with crypto through GOAT SDK and Crossmint.. Imagine AI agents capable of running entire e-commerce operations, from inventory management to customer service and marketing.

As we've seen, from financial markets to gaming, prediction platforms to e-commerce, AI agents are rapidly evolving from simple automation tools to sophisticated, autonomous decision-makers. These advancements mark a significant change in how we use and interact with AI. As AI agents become more capable of learning and making complex decisions, they'll likely play a larger role in various facets of life.

Conclusion

AI agents have evolved significantly over time. Early versions used predefined rules and had limited decision-making abilities. Frameworks like ElizaOS leverage large language models, retrieval-augmented generation, and extensible plugin architectures. This enables more dynamic, context-aware agents capable of intelligent interactions across multiple platforms and blockchain networks.

By combining a flexible framework such as ElizaOS with Gelato’s robust Web3 Services, the approach addresses key technical challenges in creating autonomous, cross-platform applications. The CoinFlip AI game serves as a practical demonstration of how these technologies can be integrated to create engaging blockchain-based applications. By integrating AI agent capabilities with blockchain infrastructure, developers can create more sophisticated, interactive, and responsive applications that push the boundaries of current approaches.

Developer Library

Tutorial: youtube.com/watch?v=XLLhsTCMsvo

Tutorial Repo: github.com/gelatodigital/coinflip-ai-agent-eliza​​

Gelato Docs: docs.gelato.network/

ElizaOS Docs: elizaos.github.io/eliza/docs/intro/

ElizaOS repo: github.com/elizaOS/eliza


For developers looking to integrate their applications with Gelato Web3 Services, check out Web3 Functions, Relay, and apply for beta access to VRF! Visit our Discord server for developer support and engagement, and stay updated with the latest developments by following us on X.