### Fetch Native Token Balance in Go Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Example of fetching a user's native token balance using the `tokenManager`. It requires a context, user ID, and platform identifier, returning the balance or an error. ```go balance, err := tokenManager.FetchNativeTokenBalance( context.Background(), "user_id", "platform", ) if err != nil { log.Printf("Error fetching balance: %v", err) return } log.Printf("User balance: %f", balance.Balance) ``` -------------------------------- ### Run the D.A.T.A Agent Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Executes the compiled D.A.T.A agent application. This command starts the agent, which will then load its configuration and begin its operations. ```bash ./data-agent ``` -------------------------------- ### Download Go Dependencies Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Downloads all the necessary Go module dependencies for the D.A.T.A framework. This command ensures all external libraries are available for building the project. ```bash go mod download ``` -------------------------------- ### Clone D.A.T.A Repository Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Clones the D.A.T.A framework repository from GitHub and navigates into the project directory. This is the first step in setting up the project locally. ```bash git clone https://github.com/carv-protocol/d.a.t.a cd d.a.t.a ``` -------------------------------- ### Expected Configuration Output Source: https://docs.carv.io/svm-ai-agentic-chain/quick-start/command-line-tool An example of the output expected after successfully configuring the Solana CLI for the CARV SVM Testnet. It shows the RPC URL and other relevant settings. ```bash Config File: /xxx/xxx/.config/solana/cli/config.yml RPC URL: https://rpc.testnet.carv.io/rpc WebSocket URL: wss:////rpc.testnet.carv.io/rpc (computed) Keypair Path: ./wallet.json Commitment: confirmed ``` -------------------------------- ### Setup .Play Name Service SDK Source: https://docs.carv.io/carv-ecosystem/carv-play/carv-intro/.play-name-service-integration Imports necessary functions from the .Play Name Service SDK. These functions, `getNames` and `getAddress`, are used for domain resolution. ```javascript import { getNames, getAddress} from '@carv-protocol/pns-js' ``` -------------------------------- ### Install @carv-protocol/pns-js SDK Source: https://docs.carv.io/carv-ecosystem/carv-play/carv-intro/.play-name-service-integration Installs the .Play Name Service JavaScript SDK using npm. This is the first step to integrate PNS functionality into your project. ```bash npm install @carv-protocol/pns-js ``` -------------------------------- ### Implement Custom Tool in Go Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Demonstrates how to create a custom tool for the D.A.T.A framework by implementing the `core.Tool` interface. This includes methods for initialization, naming, describing the tool, and defining available actions. ```go package tools import ( "context" "github.com/carv-protocol/d.a.t.a/src/internal/core" ) type CustomTool struct{} func (t *CustomTool) Initialize(ctx context.Context) error { return nil } func (t *CustomTool) Name() string { return "custom tool" } func (t *CustomTool) Description() string { return "A custom tool for specific functionality" } func (t *CustomTool) AvailableActions() []core.Action { return nil } ``` -------------------------------- ### Add Social Platform Integration in Go Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Shows how to integrate a new social media platform by implementing the `core.SocialPlatform` interface. This involves defining methods for sending messages and receiving messages from a channel. ```go package social import ( "context" "github.com/carv-protocol/d.a.t.a/src/internal/core" ) type CustomPlatform struct { // Your platform-specific fields } func (p *CustomPlatform) SendMessage(ctx context.Context, msg core.SocialMessage) error { // Implementation return nil } func (p *CustomPlatform) GetMessageChannel() <-chan core.SocialMessage { // Implementation return nil } ``` -------------------------------- ### Build the D.A.T.A Agent Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Compiles the Go source code for the D.A.T.A agent, creating an executable file named 'data-agent' in the current directory. This step is necessary before running the agent. ```bash go build -o data-agent ./src/cmd/agent ``` -------------------------------- ### JavaScript Request Example for Token Info Source: https://docs.carv.io/d.a.t.a.-ai-framework/api-documentation/token-info-and-price Shows how to fetch token information using the JavaScript Fetch API. This example demonstrates making a GET request with custom headers, including the Authorization token. ```javascript fetch('https://interface.carv.io/ai-agent-backend/token_info?ticker=aave', { method: 'GET', headers: { 'Authorization': 'your_token_here' } }) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Project Configuration YAML Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Main configuration file for the D.A.T.A agent, specifying paths to character configurations, database settings, LLM provider details, and CARV API endpoints. Settings here can be overridden by environment variables. ```yaml character: # Path to character configuration file path: "./src/config/character_data_agent.json" database: # Database type: "sqlite" or "postgres" type: "sqlite" # Database path (for SQLite) or connection string (for Postgres) path: "./data/agent.db" llm_config: # LLM provider: "openai", "deepseek", etc. provider: "deepseek" # API key for the LLM provider api_key: "" # Base URL for API calls base_url: "https://api.deepseek.com" # Model name model: "deepseek-chat" data: carvid: # CarvID API endpoint url: "https://api.carv.io/v1" # API key for CarvID api_key: "your-carvid-api-key-here" token: network: "base" ticker: "carv" ``` -------------------------------- ### Process Social Messages in Go Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Illustrates how to process incoming social messages using the agent. It involves creating a `core.SocialMessage` object and passing it to the agent's `ProcessMessage` method, handling potential errors. ```go msg := &core.SocialMessage Type: "message", Content: "Hello, agent!", Platform: "discord", FromUser: "user123", } processedMsg, err := agent.ProcessMessage(context.Background(), msg) if err != nil { log.Printf("Error processing message: %v", err) return } ``` -------------------------------- ### Verify Solana CLI Configuration Source: https://docs.carv.io/svm-ai-agentic-chain/quick-start/command-line-tool Retrieves and displays the current configuration of the Solana CLI. This is used to confirm that the RPC URL has been set correctly to the CARV SVM Testnet. ```bash solana config get ``` -------------------------------- ### Project Environment Variables Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Configuration file for setting environment-specific variables, including LLM API keys, CARV API details, and optional social media credentials. These variables influence the agent's behavior and connectivity. ```env # LLM Configuration LLM_API_KEY=your_api_key LLM_PROVIDER=openai # CARV Configuration CARV_DATA_BASE_URL=https://api.carv.io CARV_DATA_API_KEY=your_carv_api_key # Optional Social Media Configuration DISCORD_API_TOKEN=your_discord_token TWITTER_API_KEY=your_twitter_key TWITTER_API_KEY_SECRET=your_twitter_secret TWITTER_ACCESS_TOKEN=your_twitter_access TWITTER_TOKEN_SECRET=your_twitter_token TELEGRAM_BOT_TOKEN=your_telegram_token ``` -------------------------------- ### HTTP and Shell Request Examples for Token Info Source: https://docs.carv.io/d.a.t.a.-ai-framework/api-documentation/token-info-and-price Demonstrates how to make a GET request to the token info endpoint using cURL, suitable for HTTP clients or shell environments. Includes setting the Authorization header and query parameters. ```http curl -X GET "https://interface.carv.io/ai-agent-backend/token_info?ticker=aave" \ -H "Content-Type: application/json" \ -H "Authorization: " ``` ```shell curl -X GET "https://interface.carv.io/ai-agent-backend/token_info?ticker=aave" \ -H "Authorization: your_token_here" ``` -------------------------------- ### Character Configuration JSON Source: https://docs.carv.io/d.a.t.a.-ai-framework/quick-start-guide Defines the core attributes of an AI agent, including its name, system prompt, biographical details, communication style, goals, and priority accounts. This JSON file customizes the agent's persona and operational directives. ```json { "name": "DataAgent", "system": "An AI agent for Web3 data analysis", "bio": [ "Specialized in blockchain data analysis", "Expert in token-based interactions" ], "style": { "tone": ["professional", "helpful", "precise"], "constraints": [] }, "goals": [ { "name": "Data Analysis", "description": "Provide accurate blockchain data analysis", "priority": 0.8 } ], "priority_accounts": [ { "platform": "discord", "id": "your_priority_account_id" } ] } ``` -------------------------------- ### LLM Query Generation and Analysis Template Source: https://docs.carv.io/d.a.t.a.-ai-framework/use-cases-and-implementation/getting-on-chain-data-for-ai-agents A TypeScript method that returns a template string. This template guides LLMs in generating SQL queries based on database schema, examples, and user input, and specifies a detailed JSON structure for the analysis output. ```TypeScript getQueryTemplate(): string { return ` # Database Schema {{databaseSchema}} # Query Examples {{queryExamples}} # User's Query {{userQuery}} # Query Guidelines: 1. Time Range Requirements: - ALWAYS include time range limitations in queries - Default to last 3 months if no specific time range is mentioned - Use date_parse(date, '%Y-%m-%d') >= date_add('month', -3, current_date) for default time range - Adjust time range based on user's specific requirements 2. Query Optimization: - Include appropriate LIMIT clauses - Use proper indexing columns (date, address, block_number) - Consider partitioning by date - Add WHERE clauses for efficient filtering 3. Response Format Requirements: You MUST respond in the following JSON format: { "sql": { "query": "your SQL query string", "explanation": "brief explanation of the query", "timeRange": "specified time range in the query" }, "analysis": { "overview": { "totalTransactions": "number", "timeSpan": "time period covered", "keyMetrics": ["list of important metrics"] }, "patterns": { "transactionPatterns": ["identified patterns"], "addressBehavior": ["address analysis"], "temporalTrends": ["time-based trends"] }, "statistics": { "averages": {}, "distributions": {}, "anomalies": [] }, "insights": ["key insights from the data"], "recommendations": ["suggested actions or areas for further investigation"] } } 4. Analysis Requirements: - Focus on recent data patterns - Identify trends and anomalies - Provide statistical analysis - Include risk assessment - Suggest further investigations Example Response: { "sql": { "query": "WITH recent_txs AS (SELECT * FROM eth.transactions WHERE date_parse(date, '%Y-%m-%d') >= date_add('month', -3, current_date))...", "explanation": "Query fetches last 3 months of transactions with aggregated metrics", "timeRange": "Last 3 months" }, "analysis": { "overview": { "totalTransactions": 1000000, "timeSpan": "2024-01-01 to 2024-03-12", "keyMetrics": ["Average daily transactions: 11000", "Peak day: 2024-02-15"] }, "patterns": { "transactionPatterns": ["High volume during Asian trading hours", "Weekend dips in activity"], "addressBehavior": ["5 addresses responsible for 30% of volume", "Increasing DEX activity"], "temporalTrends": ["Growing transaction volume", "Decreasing gas costs"] }, "statistics": { "averages": { "dailyTransactions": 11000, "gasPrice": "25 gwei" }, "distributions": { "valueRanges": ["0-1 ETH: 60%", "1-10 ETH: 30%", ">10 ETH: 10%"] }, "anomalies": ["Unusual spike in gas prices on 2024-02-01"] }, "insights": ["Overall network activity is increasing."], "recommendations": ["Investigate the addresses with high transaction volume."] } } `; } ``` -------------------------------- ### Fetch News Articles (HTTP GET) Source: https://docs.carv.io/d.a.t.a.-ai-framework/api-documentation/news Example HTTP GET request to retrieve news articles from the carv.io AI Agent Backend. It specifies the endpoint, required headers for content type and authorization, and demonstrates how to make the call using curl. ```http curl -X GET "https://interface.carv.io/ai-agent-backend/news" \ -H "Content-Type: application/json" \ -H "Authorization: " ``` -------------------------------- ### API-Verified Quest Setup Source: https://context7_llms Guides developers on setting up custom quests within the CARV ecosystem using API integrations. Supports both RESTful and GraphQL approaches for quest verification. ```RESTFUL API-Verified Quest (RESTFUL): How to set up custom quests using RESTful API. This involves defining quest parameters, submitting verification requests, and handling responses via HTTP methods. Example Endpoint: POST /api/v1/quests/verify Request Body: { "questId": "unique_quest_id", "userId": "user_identifier", "proof": "generated_proof_data" } Response: { "status": "success|failed", "message": "Verification result description" } ``` ```GraphQL API-Verified Quest (GraphQL): How to set up custom quests using GraphQL API. This allows for more flexible data fetching and mutation for quest verification. Example Mutation: mutation VerifyQuest($questId: ID!, $userId: ID!, $proof: String!) { verifyQuest(questId: $questId, userId: $userId, proof: $proof) { status message } } Variables: { "questId": "unique_quest_id", "userId": "user_identifier", "proof": "generated_proof_data" } ``` -------------------------------- ### SQL Query Examples for Transaction Analysis Source: https://docs.carv.io/d.a.t.a.-ai-framework/use-cases-and-implementation/getting-on-chain-data-for-ai-agents Provides two common SQL query examples for analyzing blockchain transaction data. The first identifies the most active addresses in the last 7 days, and the second analyzes an address's transaction statistics (incoming/outgoing value and count) over the last 30 days. ```sql -- 1. Find Most Active Addresses in Last 7 Days: WITH address_activity AS ( SELECT from_address AS address, COUNT(*) AS tx_count FROM eth.transactions WHERE date_parse(date, '%Y-%m-%d') >= date_add('day', -7, current_date) GROUP BY from_address UNION ALL SELECT to_address AS address, COUNT(*) AS tx_count FROM eth.transactions WHERE date_parse(date, '%Y-%m-%d') >= date_add('day', -7, current_date) GROUP BY to_address ) SELECT address, SUM(tx_count) AS total_transactions FROM address_activity GROUP BY address ORDER BY total_transactions DESC LIMIT 10; -- 2. Analyze Address Transaction Statistics (Last 30 Days): WITH recent_transactions AS ( SELECT from_address, to_address, value, block_timestamp, CASE WHEN from_address = :address THEN 'outgoing' WHEN to_address = :address THEN 'incoming' ELSE 'other' END AS transaction_type FROM eth.transactions WHERE date >= date_format(date_add('day', -30, current_date), '%Y-%m-%d') AND (from_address = :address OR to_address = :address) ) SELECT transaction_type, COUNT(*) AS transaction_count, SUM(CASE WHEN transaction_type = 'outgoing' THEN value ELSE 0 END) AS total_outgoing_value, SUM(CASE WHEN transaction_type = 'incoming' THEN value ELSE 0 END) AS total_incoming_value FROM recent_transactions GROUP BY transaction_type; ``` -------------------------------- ### Example JSON Response from GraphQL Query Source: https://docs.carv.io/carv-ecosystem/carv-play/carv-intro/api-verified-quest-graphql Illustrates the expected JSON output structure from a GraphQL query, specifically when querying for ERC1155 balances. This format is used as input for the JavaScript expression function. ```JSON { "erc1155Balances": [ { "account": { "id": "0x357a5ee000b5ca0935aad7bb4cb96e8acaf46727" }, "token": { "id": "0xc2f24ffe96a69e381a747dc73fcd51492e29a0a4/0x1", "identifier": "1" } } ] } ``` -------------------------------- ### Run Verifier with Keystore Source: https://docs.carv.io/carv-ecosystem/verifier-nodes/join-mainnet-verifier-nodes/operating-a-verifier-node/running-in-cli/using-source-code Executes the verifier binary using a keystore file and its password, along with reward address and commission rate. Requires a valid keystore path and password. ```bash ./verifier -keystore-path -keystore-password -reward-address -commission-rate ``` -------------------------------- ### Install D.A.T.A Plugin Source: https://docs.carv.io/d.a.t.a.-ai-framework/getting-started/d.a.t.a-framework-plugin-for-eliza Installs the D.A.T.A Framework plugin for Eliza using pnpm. This is the initial step to integrate the plugin into your project. ```bash pnpm install @elizaos/plugin-d.a.t.a ``` -------------------------------- ### Set CARV SVM Testnet RPC URL Source: https://docs.carv.io/svm-ai-agentic-chain/quick-start/command-line-tool Configures the Solana CLI to point to the CARV SVM Testnet RPC endpoint. This command updates the CLI's configuration to use the specified network. ```bash solana config set --url https://rpc.testnet.carv.io/rpc ```