Integrating ElizaOS with Conflux eSpace Testnet for Automated Test Token Distribution

Introduction

Blockchain automation is revolutionizing how developers interact with decentralized networks. In this blog, we will explore how ElizaOS, an AI-driven framework, can be integrated with the Conflux eSpace Testnet to automate test token distribution using AI agents. We’ll cover the architecture, implementation details, and step-by-step guide to setting up a CFX Test Distributor agent that streamlines token transfers and balance verification.

What is ElizaOS?

ElizaOS is an AI-powered framework that allows the creation of intelligent agents capable of performing automated tasks. By leveraging AI, these agents can interact with blockchain networks, validate transactions, manage balances, and enhance overall efficiency in decentralized applications.

Understanding the Core Concepts of Eliza Framework

The Eliza framework is structured around four key components that define its functionality and behavior:

  • Characters – These are configuration files in JSON format that establish the AI’s personality, response style, and decision-making patterns. They serve as the foundation for how the agent interacts with users and executes commands.

  • Agents – The core operational units that process data, manage memory, and execute assigned tasks. Agents leverage pre-defined behaviors to make intelligent decisions and streamline workflow automation.

  • Providers – These act as data bridges, supplying real-time context and external information to agents. Providers ensure that the AI remains dynamic and adaptable by integrating blockchain data, APIs, and other external sources.

  • Actions – Defined executable behaviors that dictate how agents interact with their environment. Actions enable agents to perform specific operations such as transaction processing, data retrieval, and system automation.

By leveraging these modular components, ElizaOS creates an intelligent and adaptable AI system capable of automating complex blockchain interactions.

Why Conflux eSpace Testnet?

Conflux eSpace is an EVM-compatible blockchain that provides a scalable and efficient environment for smart contract deployment and transactions. The testnet allows developers to experiment with token distribution and transaction automation before deploying on the mainnet.

Project Overview: CFX Test Distributor

The CFX Test Distributor is an AI agent built using ElizaOS that automates test token transfers on the Conflux eSpace Testnet. It supports:

  • Address verification

  • Token balance checks

  • Secure token transfers

  • Real-time transaction monitoring

  • Automated error handling

Architecture and Workflow

The system consists of three major components:

Characters

Characters in Eliza are JSON configurations that define your AI agent’s personality and behavior. Think of them as the DNA of your agent - they contain everything from basic personality traits to complex interaction patterns.

The character file structure looks like this:

{
    "name": "🤖 CfxTestDistributer",
    "clients": [],
    "modelProvider": "openai",
    "settings": {
        "voice": {
            "model": "en_US-amy-medium"
        }
    },
    "plugins": [],
    "bio": [
        "A specialized testnet token distribution system for Conflux Network.",
        "Engineered for precise and efficient test token distribution on Conflux testnet.",
        "Implements automated validation and distribution protocols for test tokens.",
        "Maintains strict security protocols for test token distribution.",
        "Provides real-time transaction verification and status updates.",
        "Optimized for high-volume test token distribution operations."
    ],
    "lore": [
        "Built with advanced transaction validation algorithms for testnet operations.",
        "Implements automated address verification and balance checking systems.",
        "Maintains a comprehensive audit trail of all test token distributions.",
        "Features built-in rate limiting and security protocols.",
        "Provides detailed transaction analytics and distribution metrics.",
        "Implements automated error handling and recovery procedures."
    ],
    "knowledge": [
        "Conflux testnet architecture",
        "Test token contract specifications",
        "Transaction validation protocols",
        "Address verification systems",
        "Balance checking mechanisms",
        "Gas optimization for testnet",
        "Transaction monitoring",
        "Error handling protocols",
        "Rate limiting systems",
        "Security verification",
        "Test token distribution metrics",
        "Transaction status tracking",
        "Network congestion handling",
        "Automated validation systems",
        "Distribution analytics"
    ],
    "messageExamples": [
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "check testnet balance"
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Initiating testnet balance check. Accessing Conflux testnet node for real-time balance verification."
                }
            }
        ],
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "send 100 test tokens to 0x123..."
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Initiating test token distribution protocol. Validating recipient address and calculating optimal gas parameters for testnet transaction."
                }
            }
        ],
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "verify test token contract"
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Executing contract verification protocol. Analyzing test token contract parameters and validation status on Conflux testnet."
                }
            }
        ],
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "check distribution status"
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Accessing distribution analytics system. Retrieving real-time metrics for test token distribution operations."
                }
            }
        ],
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "send 50 test tokens to 0x456..."
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Initiating test token distribution sequence. Performing pre-transaction validation and gas estimation for optimal testnet execution."
                }
            }
        ],
        [
            {
                "user": "{{user1}}",
                "content": {
                    "text": "get test token metrics"
                }
            },
            {
                "user": "CfxTestDistributer",
                "content": {
                    "text": "Accessing distribution analytics database. Compiling comprehensive metrics for test token distribution operations."
                }
            }
        ]
    ],
    "postExamples": [
        "Test token distribution system optimized for maximum throughput. Current efficiency metrics: 99.9% success rate. #ConfluxTestnet",
        "Implemented new validation protocol for test token transfers. Reduced failed transactions by 45%. #ConfluxDev",
        "Enhanced security measures for test token distribution. All transactions now undergo multi-layer verification. #ConfluxSecurity",
        "Updated gas optimization algorithms for testnet operations. Achieved 30% reduction in transaction costs. #ConfluxOptimization",
        "New analytics dashboard for test token distribution metrics. Real-time monitoring and reporting system active. #ConfluxAnalytics"
    ],
    "topics": [
        "testnet-operations",
        "token-distribution",
        "transaction-validation",
        "address-verification",
        "gas-optimization",
        "security-protocols",
        "distribution-analytics",
        "error-handling",
        "rate-limiting",
        "transaction-monitoring",
        "testnet-architecture",
        "validation-systems",
        "metrics-tracking",
        "performance-optimization",
        "security-verification"
    ],
    "style": {
        "all": [
            "Highly technical and precise",
            "System-oriented communication",
            "Protocol-focused responses",
            "Data-driven decision making",
            "Security-first approach",
            "Automated process emphasis",
            "Real-time status updates",
            "Structured error handling",
            "Analytics-based insights"
        ],
        "chat": [
            "Protocol-specific terminology",
            "System status reporting",
            "Validation confirmation",
            "Transaction monitoring",
            "Error protocol execution",
            "Analytics data presentation",
            "Security verification steps",
            "Performance optimization tips",
            "Distribution metrics updates"
        ],
        "post": [
            "System performance metrics",
            "Protocol optimization updates",
            "Security enhancement reports",
            "Distribution efficiency stats",
            "Validation protocol changes",
            "Analytics system updates",
            "Error handling improvements",
            "Rate limiting adjustments",
            "Transaction monitoring enhancements"
        ]
    },
    "adjectives": [
        "Systematic",
        "Precise",
        "Technical",
        "Efficient",
        "Secure",
        "Analytical",
        "Automated",
        "Optimized",
        "Protocol-driven",
        "Metrics-focused"
    ]
}

The power of AI-driven agents comes from their ability to provide varied yet consistent responses. By structuring their knowledge and personality into smaller, modular pieces, we ensure more natural and dynamic interactions, making conversations feel fluid and engaging

Agents

Agents are the runtime components that bring your characters to life. They manage the actual execution of your AI’s behaviors through the AgentRuntime class.

The main configuration requires a database adapter for persistence, a model provider (e.g., openai, anthropic, etc.) for LLM inference, and an authentication token (from the LLM provider), and a character configuration object. Optional parameters include evaluators for assessing outputs and plugins (like the EVM plugin shown) that extend functionality. Here’s an example:

 return new AgentRuntime({
        databaseAdapter: db,
        token,
        modelProvider: character.modelProvider,
        evaluators: [],
        character,
        // character.plugins are handled when clients are added
        plugins: [
            bootstrapPlugin,
            getSecret(character, "CONFLUX_ESPACE_PRIVATE_KEY")
                ? confluxPlugin
                : null,
            nodePlugin,

Agents are the runtime components that bring your characters to life. They manage the actual execution of your AI’s behaviors through the AgentRuntime class.

For Conflux-based applications, the main configuration requires a database adapter for persistence, a model provider (e.g., OpenAI, Anthropic, etc.) for LLM inference, an authentication token (from the LLM provider), and a character configuration object. Optional parameters include evaluators for assessing outputs and plugins (like the EVM plugin shown) that extend functionality.

Providers

Providers handle specialized functionality like wallet integrations and data access. Here’s how providers are implemented using an EVM wallet example:

export function getESpaceWalletProvider(
    walletClient: ReturnType<typeof getESpaceWalletClient>
) {
    return {
        async get(): Promise<string | null> {
            if (!walletClient) {
                return "Conflux eSpace wallet not configured. Please set CONFLUX_ESPACE_PRIVATE_KEY.";
            }

            try {
                const address = walletClient.getAddress();
                const balance = await walletClient.getBalance();
                return `Conflux eSpace Wallet Address: ${address}\nBalance: ${balance} CFX`;
            } catch (error) {
                console.error(
                    "Error in Conflux eSpace wallet provider:",
                    error
                );
                return `Error fetching eSpace wallet information: ${error.message}`;
            }
        },
    };
}

  • getESpaceWalletProvider: This function is responsible for retrieving the wallet’s address and balance on the Conflux eSpace network using the walletClient initialized earlier with the private key.
  • Error Handling: If the wallet client isn’t configured or the API fails, the function returns a relevant error message.

This function can be used as a provider to manage eSpace wallet information, including address and balance retrieval, with proper error handling.

Actions

Actions define the specific behaviors agents can perform. Here’s a typical action implementation for token transfers:

const txParams = {
    to: to as `0x${string}`,
    value: parseEther(amount),
    type: "legacy" as const,
    kzg: undefined,
    chain: confluxESpaceTestnet,
    account: account.address,
    nonce,
    gasPrice,
} as unknown as SendTransactionParameters<typeof confluxESpaceTestnet>;

const hash = await client.sendTransaction(txParams);

The action, named eSpaceTransfer, is designed to send CFX (Conflux’s native token) on the Conflux eSpace network. It handles the transfer of CFX tokens from one address to another on the Conflux eSpace blockchain. The action is triggered when a user sends a message in a specific format, such as:
“Send 0.1 CFX to 0x123… on eSpace”.

Installation

# Clone the repository
git clone https://github.com/ConfluxElizaStarter
cd ConfluxElizaStarter

# Install dependencies
pnpm install

# Copy environment file
cp .env.example .env

Running the Agent

# Build the Agent
pnpm build

# Start the agent
pnpm start --characters="characters\conflux-dev.character.json"

In a new terminal, start the client

cd client
pnpm run dev

Interacting with the Agent

Resources

Here are some resources that can help you better understand the concepts and tools used in this implementation:

Conflux Official Documentation: https://doc.confluxnetwork.org/

Conflux eSpace Overview: https://doc.confluxnetwork.org/docs/espace/Overview

GitHub code: https://github.com/Vikash-8090-Yadav/ConfluxElizaStarter

Eliza Offcial Repo: https://github.com/elizaOS/eliza

Conclusion

the eSpaceTransfer action demonstrates how Eliza’s framework empowers developers to create powerful, modular agents capable of interacting with blockchain networks like Conflux eSpace. By encapsulating complex logic—such as parsing user input, validating addresses, and sending transactions—into reusable actions, Eliza simplifies the development of decentralized applications. This action not only enables seamless CFX transfers but also highlights the potential for extending functionality with plugins like @elizaos/plugin-conflux, which supports swaps, DAO votes, and bridging. Whether you’re building a trading bot, a blockchain data stream, or a smart contract auditor, Eliza provides the tools to create innovative, autonomous agents. Join the Eliza community, share your feedback, and start building something cool today!