This tutorial demonstrates how to create a research agent that receives SOL payments from users before executing tasks. The agent analyzes investment-related queries and retrieves data from Web3 tools.Documentation Index
Fetch the complete documentation index at: https://docs.galadriel.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The agent leverages:gpt-4omodel from OpenAI for language processing.CodeAgentto orchestrate a series of steps toward a final result.AgentRuntimeto connect clients to the agent and manage execution.- Clients:
SimpleMessageClientfor local testing with predefined messages.- (Optional)
TwitterMentionClientfor processing mentions on Twitter.
- Web3 Tools:
get_coin_price(CoinGecko) to fetch real-time cryptocurrency prices.get_token_profile(DexScreener) to retrieve token profiles.
- A Pricing Mechanism using Solana (SOL) payments. The agent will validate payment before executing the task.
Payment & Transaction Requirements
To use the agent, a client (user) must provide a task with either:- A link to a Solana transaction (e.g., from Solscan)
- A transaction signature on the Solana blockchain
Setup
-
Local Environment & Galadriel Installation:
- Agent Wallet Creation: The agent needs a Solana wallet to receive payments. If you don’t have one, create a new one. The tutorial is described in Wallet Tutorial.
-
Environment Variables Configuration:
Rename
template.envto.envand populate it with your OpenAI API key, agent wallet address, and optional Twitter API credentials (if usingTwitterMentionClient):- Make sure you have configured
SOLANA_KEY_PATHin .agents.env file to point the path to your Solana wallet
- Make sure you have configured
-
Agent Code (
agent.py): Create a file namedagent.pywith the following Python code. Remember to replace placeholders with your actual values.Code Explanation:- Imports: Imports necessary libraries and modules.
-
Environment Variables: Loads environment variables from a
.envfile. -
Model Setup: Initializes the
LiteLLMModelwith the specified model ID and API key. -
Tool Setup:
- Initializes
coingecko.get_coin_priceanddexscreener.get_token_profile
- Initializes
-
Agent Setup:
- Initializes the
CodeAgentwith the specified tools
- Initializes the
-
Client Setup:
- Initializes the
SimpleMessageClientwith a sample question and Solana transaction link.
- Initializes the
-
Runtime Setup:
- Initializes the
AgentRuntimewith the agent, pricing, input, and output.
- Initializes the
-
Run the agent:
Optional: Running the agent with Twitter Client
To use the Twitter client, you have to setTWITTER_CONSUMER_API_KEY, TWITTER_CONSUMER_API_SECRET, TWITTER_ACCESS_TOKEN and TWITTER_ACCESS_TOKEN_SECRET environment variables defined inside .env file.
-
Uncomment Twitter related code snippets:
TwitterMentionClientimport statementtwitter_clientinitialization with the proper credentials- Pass
twitter_clientclient to theAgentRuntimearguments forinputsandoutputs
-
Run the agent:

