How to Build Your First Crypto AI Agent with ElizaOS (Developer Guide)
How to Build Your First Crypto AI Agent with ElizaOS (Developer Guide)
This tutorial walks you through building a production-ready crypto AI agent using ElizaOS in under 4 hours. You'll set up the development environment, integrate Ethereum and Solana blockchain connectors, implement a simple token-swapping plugin, add conversational memory, and deploy your agent. By the end, you'll have an agent capable of executing blockchain transactions autonomously, responding to user queries via Telegram, and managing a crypto wallet. Prerequisites: Node.js 18+, basic TypeScript knowledge, and a test wallet with USDC on Ethereum testnet.
Prerequisites & Environment Setup
System Requirements:
- OS: macOS, Linux, or Windows (WSL2)
- Node.js: Version 18+
- Package Manager: Yarn or npm
- Text Editor: VS Code recommended
- Git: For cloning ElizaOS
Create Test Accounts:
- Ethereum Testnet Wallet: Use MetaMask or ethers.js
- Telegram Bot Token: Create via @BotFather
- OpenAI API Key: Get from platform.openai.com
Step 1: Clone and Install ElizaOS
bash1git clone https://github.com/elizaOS/eliza 2cd eliza 3yarn install 4yarn build
Step 2: Create Your Agent Directory
bash1mkdir my-crypto-agent 2cd my-crypto-agent 3yarn init -y 4yarn add @elizaos/core @elizaos/client-telegram @elizaos/plugin-evm 5yarn add dotenv typescript ts-node
Step 3: Configure Environment Variables
Create .env file:
bash1OPENAI_API_KEY=sk-xxxxxxxxxxxxx 2MODEL=gpt-4-turbo 3ETHEREUM_RPC_URL=https://goerli.infura.io/v3/YOUR_KEY 4SOLANA_RPC_URL=https://api.devnet.solana.com 5PRIVATE_KEY=0xxxxxxxxxxxxx 6WALLET_ADDRESS=0xxx... 7TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh 8TELEGRAM_CHAT_ID=987654321 9AGENT_NAME=MyTradingBot
Step 4: Create Agent Configuration
Create agent.ts with ElizaOS config: name, description, systemPrompt, model, memory, plugins, connectors.
Step 5: Implement Token Swap Plugin
Create plugins/swapPlugin.ts with Uniswap V3 Router integration. Handle token swaps via smart contracts.
Step 6: Initialize and Run Agent
Create main.ts that instantiates Agent, loads plugins, and starts listening for Telegram messages.
Step 7: Build and Run
bash1yarn tsc --init 2node --loader ts-node/esm main.ts
Step 8: Interact with Your Agent
Message your Telegram bot:
- "What's my wallet balance?"
- "Swap 100 USDC for ETH"
Agent responds with data and executes transactions.
Step 9: Production Deployment
Option A: Vercel (Serverless)
- Deploy for $0-20/month
Option B: Docker (Self-Hosted)
- Build container and run on VPS
Key Safeguards for Production
Transaction Limits: Set MAX_SINGLE_SWAP to prevent unauthorized large transactions.
Slippage Protection: Allow 2% slippage but validate expected output.
Rate Limiting: Limit to 10 requests per minute.
FAQ
Q: Can I run multiple agents? A: Yes. Create separate agent instances with different wallet addresses and Telegram bots.
Q: How do I add Solana support? A: Install @elizaos/plugin-solana and add it to agentConfig.plugins.
Q: What's the cheapest way to run an agent 24/7? A: Vercel free tier (~$0/month). For higher volume, rent VPS ($5-10/month).
Related Articles
Related Posts
The Complete Guide to AI Agents in Crypto: How Autonomous AI Is Reshaping Blockchain in 2026
The definitive guide to AI agents in crypto. From payment infrastructure and decentralized compute to DeFAI trading and DAO governance — understand how autonomous AI agents are reshaping blockchain in 2026, with a market that grew from B to 9B in just 18 months.
MarketingBig Tech vs Crypto: Two Competing Visions for the AI Agent Economy
Analyze competing visions for AI agent infrastructure: centralized big tech platforms vs. permissionless crypto approaches. Trade-offs and coexistence.
MarketingHow to Use Crypto AI Agents: A Practical Guide for Non-Developers
Learn how to interact with and use crypto AI agents without coding knowledge. Step-by-step guide for non-technical users on platforms, wallets, and security.