?

How to Build a Crypto AI Agent Using elizaOS & Ankr in 5 Steps

Kevin Dwyer

Kevin Dwyer

March 9, 2025

5 min read

agents.jpg

Crypto AI agents have become a top narrative for this crypto cycle, driving a huge amount of developer interest in building new AI-enabled dApps, trading strategies, market insights, and more. Combining blockchain and AI development sounds like a real challenge, but thankfully, there are ready-made tools and tutorials (like this one) to guide you through it from start to finish!

In this guide, we’ll walk you through building a fully functional crypto AI agent using elizaOS for AI-driven interactions and Ankr for blockchain data queries. Whether you want to analyze blockchain transactions, track token prices, monitor wallet activity, or build more advanced autonomous functionality, this step-by-step tutorial will help you get started.

Learn more about what crypto AI agents can do

Step 1: Install Prerequisites

Before diving in, ensure you have the following installed:

  • Node.js 23+ (using nvm is recommended)
  • pnpm 9+
  • Git for version control
  • A code editor (VS Code, Cursor, or VSCodium recommended)
  • CUDA Toolkit (optional, for GPU acceleration)

Step 2: Set Up elizaOS

Time estimate: 15-30 min.

Start by cloning the elizaOS repository and setting up the environment:

  • git clone https://github.com/elizaos/eliza.git

  • cd eliza

  • git checkout $(git describe --tags --abbrev=0)

  • pnpm install --no-frozen-lockfile

  • pnpm build

  • cp .env.example .env

Now, your base environment is ready to start building your AI agent.

Step 3: Customize & Create Your First AI Agent

Time estimate: 20-45 min.

Define Your AI Character

Navigate to the characters/ directory and choose a character file to modify or create a new one:

cp characters/sbf.character.json characters/{your-character-name}.character.json

Modify your character’s traits in the JSON file. Example:

  "bio": [
    "web3 analyst and creative polymath. Splits time between analyzing blockchain data and designing for global brands. Believes in the divine intersection of tech and art."
  ],
  "lore": [
    "Designed a collection that merged sacred geometry with market analysis patterns."
  ],
  "knowledge": ["Blockchain Analytics"],
  "topics": ["blockchain technology"],
  "style": {
    "all": ["Funny"],
    "chat": ["Knowledgeable"],
    "post": ["Direct"]
  },
  "adjectives": ["Professional"]
}

This defines your AI's personality, interests, and tone of communication.

Step 4: Connect Your AI Agent to Blockchain Data with Ankr

Time estimate: 30-60 min.

Once you’ve given your agent a personality, you can go ahead and add the Ankr plugin to begin asking your agent to query on-chain data.

"plugins": ["@elizaos/plugin-ankr", "@elizaos/plugin-twitter", "@elizaos/plugin-image-generation"],

You will need to grab your Ankr API Key by navigating to our Web3 API dashboard. Select the blockchain you want to pull data from (e.g., Solana, Ethereum) and copy the endpoint.

Alternatively, Ankr’s Advanced API is highly recommended for AI Agents as it pulls pre-indexed data from a variety of different chains simultaneously at near-instant speeds.

Screenshot 2025-03-09 102701.png

Head over to your .env file and look for the ANKR configurations. You can find this somewhere around line 900+ in the .env file.

Place your API Key here like so:

ANKR_WALLET=”ANKR_WALLET”

You’ll go through this same process by putting your API key in a few other sections.

Go to the packages folder and find the plugin-ankr folder.

Once in the plugin-ankr folder, head down to the environment.ts file.

Here, you’ll need to look for:

ANKR_WALLET: z.string().min(1, "ANKR_WALLET"),

Around line 35 of the file.


Enter your API key again around line 61.

ANKR_WALLET: process.env.ANKR_WALLET || "ANKR_WALLET",

Now, in the same plugin-ankr folder locate the dist folder.

Here you’ll see a file named index.js

In this file at line at around 4077 you need to enter your api key again.

ANKR_WALLET: z.string().min(1, "ANKR_WALLET"),


And again at around 4093

ANKR_WALLET: process.env.ANKR_WALLET || "ANKR_WALLET",

From here you should be all configured and ready for your bot to query on-chain.

Step 4: Run Your Crypto AI Agent

Time estimate: 10-20 min.

Start your agent by specifying your character file:

pnpm start --character="characters/{your-character-name}.character.json"

Open a new terminal window and start the client HTTP server:

pnpm start:client

Once the client is running, open http://localhost:5173/ (or whatever local host your terminal decides to open) in your browser to start interacting with your AI agent.

Step 5: Query Blockchain Data with Your AI Agent

Time estimate: 20-60 min.

Once your agent is live, try out blockchain queries using natural language. Here are some examples:

Checking Blockchain Statistics

Show me stats for [chain]eth[/chain]

Fetching Top Currencies

Show me the top currencies on [chain]eth[/chain]

Checking Wallet Balance

Show me the balance for wallet [wallet]0x6B0031518934952C485d5a7E76f1729B50e67486[/wallet] on [chain]eth[/chain]

Viewing Wallet Interactions

Show me interactions for the wallet [wallet]0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45[/wallet]

Fetching NFT Metadata

Show me the metadata for NFT [token]1234[/token] at contract [contract]0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d[/contract] [chain]eth[/chain]

Listing NFTs Owned by a Wallet

Show me all NFTs owned by wallet [wallet]0x1234567890123456789012345678901234567890[/wallet] on [chain]eth[/chain]

Checking Token Holders

Show me holders for contract [contract]0xf307910A4c7bbc79691fD374889b36d8531B08e3[/contract] on [chain]bsc[/chain]

Conclusion

Congratulations! You have successfully built and deployed your crypto AI agent using elizaOS and Ankr. Your AI can now interact with blockchain data, analyze transactions, and provide real-time insights using simple natural language commands.

To further enhance your agent, consider:

  • Adding more plugins for other clients (Slack, Discord, Telegram).
  • Fine-tuning your AI’s personality and expertise.
  • Expanding its capabilities with custom blockchain queries, image generation, and more.

For more discussions and updates, join the elizaOS community on Twitter, Telegram, Discord, or Substack!

Happy coding! 🤖

Join the Conversation on Our Channels

Twitter | Telegram | Substack |  Discord | YouTube | LinkedIn | Reddit | All Links

Similar articles.

How We’re Making Blockchain-Aware AI Agents With elizaOS

How We’re Making Blockchain-Aware AI Agents With elizaOS

Kevin Dwyer

Kevin Dwyer

February 4, 2025

elizaOS.jpg

TL;DR

  • elizaOS is a powerful framework for building AI agents.
  • Ankr lets agents learn from blockchain data and execute on-chain tasks autonomously.
  • **The possibilities are...
Let’s Get Agentic: The State of Crypto AI Agents in 2025

Let’s Get Agentic: The State of Crypto AI Agents in 2025

Kevin Dwyer

Kevin Dwyer

February 18, 2025

lga.jpg

Imagine using software that doesn’t just follow your commands but thinks, learns, and adapts—advancing your goals autonomously. This is exactly what AI agents are designed...