Building a Solana Wallet Balance Agent with Fetch.ai’s
0
0
Building a Solana Wallet Balance Agent with Fetch.ai’s uAgent Chat Protocol and query it from ASI-One
Unlocking the power of decentralised AI agents for seamless blockchain interactions

Introduction
In the evolving landscape of decentralised technologies, the integration of autonomous agents with blockchain platforms is paving the way for innovative applications. Fetch.ai’s uAgents provides a robust framework for developing such agents, and with the introduction of the Agent Chat Protocol and ASI-One, developers can now create intelligent agents capable of natural language interactions. This article guides you through building a Solana Wallet Balance Agent that leverages these tools to provide real-time wallet balance information. Getting it on Agentverse and make it discoverable to the world.
Understanding the uAgent and Chat Protocol
The uAgent is the piece of code which can be different triggered on different events or request and colloborate with other agents using on_message handler. The Agent Chat Protocol is a standardised communication framework that enables agents to exchange messages in a structured and reliable manner. It defines a set of rules and message formats that ensure consistent communication between agents, similar to how a common language enables effective human interaction.
Key components of chat protocol include:
- ChatMessage: The primary message type for communication, containing a timestamp, unique message ID, and content.
- ChatAcknowledgement: Confirms the receipt of messages, referencing the original message ID.
- Content Types: Such as TextContent, ResourceContent, and MetadataContent, allowing for diverse message payloads.
This protocol ensures that agents can communicate effectively, handling various content types and maintaining session integrity.
Introducing ASI-One
ASI-One is Fetch.ai’s Web3-native large language model designed for agentic AI. It introduces next-level adaptive reasoning and context-aware decision-making.
Notable features:
- Dynamic Reasoning Modes: Including Multi-Step, Complete, Optimised, and Short Reasoning, allowing the model to adapt its reasoning depth and precision based on the task at hand.
- Mixture of Agents (MoA) and Mixture of Models (MoM): Enhancing scalability and efficiency by orchestrating multiple models and agents.
- Knowledge Graph Integration: Offering personalised and context-rich interactions by integrating structured knowledge representations.
- Voice Integration: Can now understand your query and respond to you using verbally.
- Text-to-Image and Image-to-text
These capabilities make ASI-one an ideal choice for building intelligent agents that require nuanced understanding and interaction.
Building the Solana Wallet Balance Agent
The Solana Wallet Balance Agent allows users to query wallet balances using natural language. It uses the Solana RPC API to fetch real-time balance information and provides formatted responses with both SOL and lamports values.
Message Flow
The communication flow between ASI-1 Mini, the Solana Wallet Agent, and OpenAI Agent follows this sequence:

- Query Initiation: ASI-One Mini sends a natural language query (e.g., “What’s the balance of wallet address {address}”) as a ChatMessage to the Solana Wallet Agent.
- Parameter Extraction: The Solana Wallet Agent forwards the query to OpenAI Agent on Agentversefor parameter extraction. OpenAI Agent processes the natural language and extracts the wallet address. The address is returned in a Pydantic Model format as StructuredOutputResponse.
- Balance Query: The Solana Wallet Agent calls the get_balance_from_address function with the extracted address. The function queries the Solana RPC API and returns the balance information.
- Agent Response: The Solana Wallet Agent sends the formatted response back as a ChatMessage to ASI-1 Mini.
- Message Acknowledgements: Each message is acknowledged using ChatAcknowledgement.
Implementation Steps
Set Up the Agent Environment: Create a new agent named “SolanaWalletAgent” on Agentverse and create the following files.
- solana.py: Handles interaction with the Solana RPC API.
- agent.py: Main agent file.
- chat_proto.py: Implements the chat protocol.
- Implement Solana Service: In solana.py, define the function get_balance_from_address to interact with the Solana RPC API and retrieve wallet balances.
- Define Chat Protocol: In chat_proto.py, implement the necessary classes and message handlers as per the Agent Chat Protocol specifications.
- Integrate with ASI-1 Mini: Ensure that your agent can receive and process messages from ASI-1 Mini, utilising its natural language understanding capabilities to extract wallet addresses from user queries.

Conclusion
By integrating Fetch.ai’s Agent Chat Protocol with ASI-One, developers can create intelligent agents capable of natural language interactions and real-time blockchain data retrieval. The Solana Wallet Balance Agent exemplifies how these technologies can be combined to provide seamless and user-friendly access to blockchain information. As decentralised technologies continue to evolve, such integrations will play a crucial role in building the next generation of intelligent applications.
Note: For detailed code examples and further guidance, refer to the official Fetch.ai innovation labs documentation on the Agent Chat Protocol and the Solana Wallet Balance Agent.
Building a Solana Wallet Balance Agent with Fetch.ai’s was originally published in Fetch.ai on Medium, where people are continuing the conversation by highlighting and responding to this story.
0
0
Securely connect the portfolio you’re using to start.