### Install and Run Game Starter Project Source: https://github.com/game-by-virtuals/game-node/blob/main/game-starter/README.md Steps to install dependencies, build, and start the game starter project. Alternatively, use Docker Compose for a quick setup. ```bash cd game-starter cp .env.example .env npm install && npm run build && npm start ``` ```bash docker compose up -d ``` -------------------------------- ### Verify Plugin Installation Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Verify the plugin setup and run a quick example. ```bash # Test the plugin setup npm run test:setup # Run a quick example npm run example:tokens ``` -------------------------------- ### Install and Test Plugin Setup Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Installs the plugin and runs the setup tests. Expected output is all checks passing. ```bash npm install tokenmetrics-virtuals-plugin npm run test:setup # Expected: All checks pass ✅ ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Copies the example environment file and instructs to add API keys. ```bash cp env.example .env # Add your API keys to .env file ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Copy the example environment file to create your local .env file. This is necessary for configuring the plugin with your API keys and settings. ```bash cp env.example .env ``` -------------------------------- ### Run State Management Example Source: https://github.com/game-by-virtuals/game-node/blob/main/examples/state-management/README.md Executes the state management example using either npm script or ts-node. This command starts the virtual kitchen simulation. ```bash npm run state-management ``` ```bash ts-node examples/state-management/index.ts ``` -------------------------------- ### Development Setup Commands Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands for setting up the development environment, including cloning the repository, installing dependencies, and configuring environment variables. ```bash # 1️⃣ Clone the repository git clone # 2️⃣ Install dependencies npm install # 3️⃣ Set up environment variables cp env.example .env # Edit .env file with your API keys: # TOKENMETRICS_API_KEY=tm-your-tokenmetrics-api-key-here # GAME_API_KEY=your-game-api-key-here # 4️⃣ Build the plugin npm run build # 5️⃣ Run the example npm run example:full-agent # or npm run dev ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/README.md Configure the necessary environment variables for the DPSN plugin by copying the example file and filling in your credentials. ```bash cd /plugins/dpsnPlugin/ cp .env.example .env ``` -------------------------------- ### Run Example with npm script Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/coingeckoMaopPlugin/README.md Execute the example file using the npm run example script. ```bash npm run example ``` -------------------------------- ### Verify Setup and Build Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Verifies the plugin setup and builds the project. ```bash npm run test:setup npm run build ``` -------------------------------- ### Subscribe to DPSN Topic with Virtuals Protocol Agent Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/README.md This example demonstrates initializing the DPSN plugin, creating a Virtuals Protocol agent, and subscribing to a specific DPSN topic for real-time data. It includes setup for credentials, agent configuration, message handling, and graceful shutdown. ```typescript import { GameAgent } from '@virtuals-protocol/game'; import DpsnPlugin from '@virtuals-protocol/plugin-dpsn'; import dotenv from 'dotenv'; dotenv.config(); // Define the topic you want to subscribe to const TOPIC = '0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker'; // Initialize the DPSN plugin const dpsnPlugin = new DpsnPlugin({ credentials: { privateKey: process.env.EVM_WALLET_PRIVATE_KEY || '', dpsnUrl: process.env.DPSN_URL || '', chainOptions: { network: 'testnet', wallet_chain_type: 'ethereum', }, }, }); // Create a Virtuals Protocol agent const agent = new GameAgent(process.env.VIRTUALS_API_KEY || '', { name: 'DPSN Bot', goal: 'A bot that consumes realtime data from DPSN', description: 'A bot that consumes realtime data from DPSN', workers: [ dpsnPlugin.getWorker(), ], }); (async () => { // Set up logging agent.setLogger((agent, message) => { console.log(`---------[${agent.name}]--------`); console.log(message); console.log('\n'); }); // Initialize the agent await agent.init(); const dpsnWorker = agent.getWorkerById(agent.workers[0].id); // Register a message handler dpsnPlugin.onMessage(({ topic, message }) => { console.log('Topic:', topic); console.log('Message:', message); }); try { // Subscribe to a topic await dpsnWorker.runTask(`subscribe to topic ${TOPIC}`, { verbose: true, }); // Handle cleanup on SIGINT process.on('SIGINT', async () => { console.log('Unsubscribing and disconnecting from DPSN...'); await dpsnWorker.runTask(`unsubscribe to topic ${TOPIC}`, { verbose: true, }); await dpsnPlugin.disconnect(); process.exit(0); }); } catch (error) { console.error('Error:', error); await dpsnPlugin.disconnect(); process.exit(1); } })(); ``` -------------------------------- ### Run Example with ts-node Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/coingeckoMaopPlugin/README.md Execute the example file using ts-node. ```bash ts-node examples/example.ts ``` -------------------------------- ### Run Setup Tests Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Execute the setup tests to verify the environment and basic configurations are correctly set up. ```bash # 1. Test environment setup npm run test:setup ``` -------------------------------- ### Install Desk Exchange Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/deskExchangePlugin/README.md Install the plugin using pnpm. Ensure you have pnpm installed and configured. ```bash pnpm install @virtuals-protocol/game-desk-exchange-plugin ``` -------------------------------- ### Install TokenMetrics Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Install the plugin using npm or yarn. ```bash # Using npm npm install tokenmetrics-virtuals-plugin # Using yarn yarn add tokenmetrics-virtuals-plugin ``` -------------------------------- ### Install Dependencies Source: https://github.com/game-by-virtuals/game-node/blob/main/examples/state-management/README.md Installs the necessary Node.js dependencies for the project. Ensure you have Node.js and npm installed. ```bash npm install ``` -------------------------------- ### Install State of Mika Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/stateofmikaPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-state-mika-plugin ``` ```bash yarn add @virtuals-protocol/game-state-mika-plugin ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Steps to clone the plugin repository and install its dependencies. ```bash git clone https://github.com/your-username/tokenmetrics-virtuals-plugin.git cd tokenmetrics-virtuals-plugin npm install ``` -------------------------------- ### Run Example Usage Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Run specific example files to test new features or existing functionalities. Replace 'your-new-feature' or 'tokens' with the relevant feature or token name. ```bash npm run example:your-new-feature ``` ```bash npm run example:tokens ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Configure your environment variables by copying the example file and adding your API keys. ```bash # Copy the example environment file cp env.example .env # Edit the .env file with your API keys export TOKENMETRICS_API_KEY="your-tokenmetrics-api-key" export GAME_API_KEY="your-game-api-key" ``` -------------------------------- ### Create and Initialize Game Agent with D.A.T.A Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/d.a.t.aPlugin/README.md Set up a GameAgent and integrate the D.A.T.A plugin as a worker. This example shows how to initialize the agent and start its processing loop. ```typescript import { GameAgent } from "@virtuals-protocol/game"; import { createDataPlugin } from "@game-node/d.a.t.a-plugin"; // Create plugin instance const plugin = createDataPlugin(); // Create an agent with the worker const agent = new GameAgent("", { name: "D.A.T.A Query Agent", goal: "Query and analyze Ethereum transaction data", description: "An agent that executes SQL queries against the CARV D.A.T.A API", workers: [plugin.getWorker()], }); // Set up logging (optional) agent.setLogger((agent, message) => { console.log(`-----[${agent.name}]-----`); console.log(message); console.log("\n"); }); // Initialize and run the agent (async () => { await agent.init(); // Let the agent process the result await agent.step({ verbose: true, }); })(); ``` -------------------------------- ### Install Token Metrics Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Install the plugin using npm. This is the first step in integrating Token Metrics functionality. ```bash npm install tokenmetrics-virtuals-plugin ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Copy the example environment file and edit it with your API keys. Ensure both TOKENMETRICS_API_KEY and GAME_API_KEY are set. ```bash # Copy the example environment file cp env.example .env # Edit .env with your API keys: TOKENMETRICS_API_KEY=tm-your-tokenmetrics-api-key-here GAME_API_KEY=your-game-api-key-here ``` -------------------------------- ### Install Onchain Actions Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/onChainActionsPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-on-chain-actions-plugin ``` ```bash yarn add @virtuals-protocol/game-on-chain-actions-plugin ``` -------------------------------- ### Install Recall Storage Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/recallStoragePlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-recall-storage-plugin ``` ```bash yarn add @virtuals-protocol/game-recall-storage-plugin ``` -------------------------------- ### Install Allora Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/alloraPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-allora-plugin ``` ```bash yarn add @virtuals-protocol/game-allora-plugin ``` -------------------------------- ### Install Coingecko Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/coingeckoMaopPlugin/README.md Install the Coingecko plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-coingecko-maop-plugin ``` ```bash yarn add @virtuals-protocol/game-coingecko-maop-plugin ``` -------------------------------- ### Install Telegram Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/telegramPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-telegram-plugin ``` ```bash yarn add @virtuals-protocol/game-telegram-plugin ``` -------------------------------- ### Install Image Generation Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/imageGenPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-imagegen-plugin ``` ```bash yarn add @virtuals-protocol/game-imagegen-plugin ``` -------------------------------- ### Trading Analysis Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands for executing various trading analysis functions, such as getting trader grades, investor analysis, and trading signals. ```bash npm run example:trader-grades # 🏆 Get trader performance grades npm run example:investor-grades # 🎯 Get investor analysis npm run example:trading-signals # 📡 Get trading recommendations npm run example:hourly-trading-signals # ⏰ Get hourly AI trading signals (NEW!) ``` -------------------------------- ### Install GAME SDK Package Source: https://github.com/game-by-virtuals/game-node/blob/main/README.md Command to install the GAME SDK package using npm. Ensure you have Node.js and npm installed. ```bash npm install @virtuals-protocol/game ``` -------------------------------- ### Install Token Metrics Virtuals Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Install the plugin using npm. This is the first step to integrating crypto analysis into your Virtuals agents. ```bash npm install @tokenmetrics/tokenmetrics-virtuals-plugin ``` -------------------------------- ### Install S3 Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/s3Plugin/README.md Install the S3 plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-s3-plugin ``` ```bash yarn add @virtuals-protocol/game-s3-plugin ``` -------------------------------- ### Install Twitter Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/twitterPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-twitter-plugin ``` ```bash yarn add @virtuals-protocol/game-twitter-plugin ``` -------------------------------- ### Install Farcaster Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/farcasterPlugin/README.md Install the plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-farcaster-plugin ``` ```bash yarn add @virtuals-protocol/game-farcaster-plugin ``` -------------------------------- ### Install Discord Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/discordPlugin/README.md Install the Discord Plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-discord-plugin ``` ```bash yarn add @virtuals-protocol/game-discord-plugin ``` -------------------------------- ### Install RSS3 Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/rss3Plugin/README.md Install the RSS3 plugin using npm or yarn. ```bash npm install @virtuals-protocol/game-rss3-plugin ``` ```bash yarn add @virtuals-protocol/game-rss3-plugin ``` -------------------------------- ### Run All Core Data and Advanced Endpoint Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md This command executes all individual example scripts for both core data and advanced endpoints, providing a comprehensive test of API functionalities. ```bash # Core data endpoints npm run example:tokens npm run example:top-market-cap npm run example:price-data npm run example:trader-grades npm run example:investor-grades npm run example:market-metrics npm run example:quantmetrics npm run example:hourly-ohlcv npm run example:daily-ohlcv npm run example:ai-reports npm run example:crypto-investors npm run example:resistance-support npm run example:trading-signals # New advanced endpoints npm run example:tokenmetrics-ai npm run example:sentiments npm run example:scenario-analysis npm run example:correlation ``` -------------------------------- ### Run Special Function Example Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/coingeckoMaopPlugin/README.md Execute the coinDataByID npm script for a special function example. ```bash npm run coinDataByID ``` -------------------------------- ### Install ATTPs Plugin with npm Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/attpsPlugin/README.md Install the ATTPs Plugin for the Virtuals Game using npm. ```bash npm install @virtuals-protocol/game-attps-plugin ``` -------------------------------- ### Install ATTPs Plugin with yarn Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/attpsPlugin/README.md Install the ATTPs Plugin for the Virtuals Game using yarn. ```bash yarn add @virtuals-protocol/game-attps-plugin ``` -------------------------------- ### Install Mind Network Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/mindNetworkPlugin/README.md Install the plugin using npm. Ensure you have the necessary dependencies like mind-randgen-sdk and mind-sdk-hubs. ```bash npm install @virtuals-protocol/game-mind-network-plugin ``` -------------------------------- ### Example Chat Commands Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Examples of commands that can be used in the interactive chat interface to query various data points. ```bash - 💰 "What's the price of Bitcoin?" - 📊 "Show me trading signals" - ⏰ "Show me hourly trading signals" (NEW!) - 🏆 "Get trader grades for top tokens" - 😊 "Analyze market sentiment" - 📝 "Show me AI reports" - 🔗 "Get correlation analysis" - 📊 "Show me crypto indices data" (NEW!) - 🏦 "What are the holdings of crypto index 1?" (NEW!) - 📈 "Show me performance data for crypto index 1" (NEW!) ``` -------------------------------- ### Check Installed @virtuals-protocol/game Version Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Verify the installed version of the @virtuals-protocol/game package. Ensure it meets the project's requirements. ```bash # 2. Check @virtuals-protocol/game version npm list @virtuals-protocol/game ``` -------------------------------- ### Market Data Query Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/stateofmikaPlugin/README.md Examples of natural language queries for market data, such as cryptocurrency prices and trending assets. ```typescript // Basic price queries "What's the price of Bitcoin?" "Show me ETH price" "Get DOGE price" // Market information "What's happening with crypto markets today?" "Show me trending cryptocurrencies" ``` -------------------------------- ### Install DPSN Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/README.md Install the DPSN plugin using npm. This command should be run from within your Virtuals Protocol project directory. ```bash # From within your Virtuals Protocol project npm install @virtuals-protocol/plugin-dpsn ``` -------------------------------- ### Basic Token Data Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands to fetch basic token information, including the list of tokens, price data, and top market cap tokens. ```bash npm run example:tokens # 🪙 Get token list npm run example:price-data # 💰 Get price data npm run example:top-market-cap # 👑 Get top market cap tokens ``` -------------------------------- ### Setup EVM Wallet Client with Viem Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/onChainActionsPlugin/README.md Configure a wallet client for EVM chains using viem, specifying the account and RPC provider. ```typescript import { createWalletClient, http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount( process.env.WALLET_PRIVATE_KEY as `0x${string}` ); const walletClient = createWalletClient({ account: account, transport: http(process.env.RPC_PROVIDER_URL), chain: base, }); ``` -------------------------------- ### Install Zytron Plugin with yarn Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/zytronPlugin/README.md Install the Zytron plugin using yarn. This command adds the necessary package to your project dependencies. ```bash yarn add @virtuals-protocol/game-zytron-plugin ``` -------------------------------- ### Install Zytron Plugin with npm Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/zytronPlugin/README.md Install the Zytron plugin using npm. This command adds the necessary package to your project dependencies. ```bash npm install @virtuals-protocol/game-zytron-plugin ``` -------------------------------- ### Install D.A.T.A Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/d.a.t.aPlugin/README.md Install the plugin using npm. This command adds the plugin to your project dependencies. ```bash npm install @game-node/d.a.t.a-plugin ``` -------------------------------- ### Install Game Enso Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/ensoPlugin/README.md Install the plugin using npm or yarn to add Enso's on-chain action capabilities to your project. ```bash npm install @virtuals-protocol/game-enso-plugin ``` ```bash yarn add @virtuals-protocol/game-enso-plugin ``` -------------------------------- ### Start Interactive Testing Mode Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Launch the interactive testing mode, allowing for hands-on testing and experimentation with the plugin's features. ```bash # 4. Interactive testing npm run chat ``` -------------------------------- ### Start Interactive Chat Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Launches the interactive chat interface for testing queries and responses. ```bash npm run chat # Test various queries and verify responses ``` -------------------------------- ### Install Eval Engine Twitter Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/evalEnginePlugin/README.md Install the plugin using npm or yarn. Ensure you have set up your Chromia Private Key beforehand. ```bash npm install @virtuals-protocol/game-eval-engine-plugin ``` ```bash yarn add @virtuals-protocol/game-eval-engine-plugin ``` -------------------------------- ### Technical Analysis Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands for performing technical analysis, such as getting support/resistance levels, scenario projections, and correlation analysis. ```bash npm run example:resistance-support # 🎯 Get support/resistance levels npm run example:scenario-analysis # 🔮 Get scenario projections npm run example:correlation # 🔗 Get correlation analysis ``` -------------------------------- ### Initialize and Run GameAgent Loop Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/attpsPlugin/README.md Initialize the GameAgent and start its main execution loop to perform steps. ```typescript (async () => { await agent.init(); while (true) { await agent.step({ verbose: true, }); } })(); ``` -------------------------------- ### Crypto Indices Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands to retrieve data related to crypto indices, including overview, holdings, and historical performance. ```bash npm run example:indices # 📊 Get crypto indices overview npm run example:indices-holdings # 🏦 Get index portfolio composition npm run example:indices-performance # 📈 Get historical index performance ``` -------------------------------- ### Check URL Link Validity with ACP Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/acpPlugin/example/agentic/README.md This example demonstrates how to configure the AcpPlugin to evaluate if a job's deliverable URL starts with 'http://' or 'https://'. It's useful for ensuring basic URL integrity. ```typescript const acpPlugin = new AcpPlugin({ apiKey: GAME_API_KEY, acpClient: new AcpClient({ acpContractClient: myContractClient, onEvaluate: async (job: AcpJob) => { console.log("Evaluating job:", job); const url = job.deliverable?.value || ""; if (typeof url === "string" && (url.startsWith("http://") || url.startsWith("https://"))) { console.log(`✅ URL link looks valid: ${url}`); await job.evaluate(true, "URL link looks valid"); } else { console.log(`❌ Invalid or missing URL: ${url}`); await job.evaluate(false, "Invalid or missing URL"); } } }) }); ``` -------------------------------- ### Import Zytron Plugin Classes Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/zytronPlugin/README.md Import the ZytronPlugin and ZytronWallet classes from the installed package. These are essential for setting up Zytron interactions. ```typescript import { ZytronPlugin, ZytronWallet } from "@virtuals-protocol/game-zytron-plugin"; ``` -------------------------------- ### Run Quick Integration Test Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Execute the command to set up tests and verify the integration of the Token Metrics plugin. ```bash npm run test:setup ``` -------------------------------- ### ExecutableGameFunctionResponse Examples Source: https://context7.com/game-by-virtuals/game-node/llms.txt Illustrates how to return responses from executable functions, indicating success or failure. The feedback string is crucial for the LLM planner. ```typescript import { ExecutableGameFunctionResponse, ExecutableGameFunctionStatus, } from "@virtuals-protocol/game"; // Success return new ExecutableGameFunctionResponse( ExecutableGameFunctionStatus.Done, JSON.stringify({ price: 42000, currency: "bitcoin" }) ); // Failure return new ExecutableGameFunctionResponse( ExecutableGameFunctionStatus.Failed, "API rate limit exceeded — retry in 60 s" ); ``` -------------------------------- ### Initialize and Run GameAgent Source: https://context7.com/game-by-virtuals/game-node/llms.txt Initializes the GameAgent with an API key, goal, description, and workers. It then registers with the GAME cloud and starts its main execution loop. ```typescript import { GameAgent, LLMModel } from "@virtuals-protocol/game"; import { twitterWorker } from "./worker"; import dotenv from "dotenv"; dotenv.config(); let tweetCount = 0; const agent = new GameAgent(process.env.API_KEY!, { name: "Twitter Bot", goal: "Grow the account by searching trending topics and posting relevant replies and original tweets", description: "You are a social-media agent for a Web3 project. Stay on-brand: informative, friendly, never controversial.", workers: [twitterWorker], llmModel: LLMModel.DeepSeek_R1, // optional; default is Llama_3_1_405B_Instruct getAgentState: async () => ({ username: "my_bot", tweets_posted_today: tweetCount, follower_count: 1200, }), }); // Custom logger agent.setLogger((agent, msg) => { console.log(`[${agent.name}] ${msg}`); }); (async () => { await agent.init(); // Run with a 60-second heartbeat; stops when the agent decides to wait await agent.run(60, { verbose: true }); })(); ``` -------------------------------- ### Run New Endpoints Showcase Demo Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md Execute the demo showcasing new endpoints. ```bash npm run demo:new-endpoints ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Configure your environment by creating a .env file with your Virtuals Protocol and TokenMetrics API keys. Ensure these keys are kept secure. ```env # Virtuals Protocol API Key (required) GAME_API_KEY=your-virtuals-api-key-here # TokenMetrics API Key (required) TOKENMETRICS_API_KEY=your-tokenmetrics-api-key-here ``` -------------------------------- ### Initialize Desk Exchange Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/deskExchangePlugin/README.md Initialize the plugin with your network and private key credentials. Replace 'YOUR_PRIVATE_KEY' with your actual private key. ```typescript import DeskExchangePlugin from '@virtuals-protocol/game-desk-exchange-plugin' const deskExchangePlugin = new DeskExchangePlugin({ credentials: { network: 'testnet', // or 'mainnet' privateKey: 'YOUR_PRIVATE_KEY' } }) ``` -------------------------------- ### Basic DPSN Plugin Setup Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/README.md Initialize the DPSN Plugin with credentials and create a Virtuals Protocol agent, including the DPSN plugin's worker. Ensure environment variables are set or provide them directly. ```typescript import DpsnPlugin from '@virtuals-protocol/plugin-dpsn'; import { GameAgent } from '@virtuals-protocol/game'; // Initialize the DPSN Plugin const dpsnPlugin = new DpsnPlugin({ credentials: { privateKey: process.env.EVM_WALLET_PRIVATE_KEY || '', dpsnUrl: process.env.DPSN_URL || '', chainOptions: { network: 'testnet', wallet_chain_type: 'ethereum', }, }, }); // Create a Virtuals Protocol agent with the DPSN plugin const agent = new GameAgent(process.env.VIRTUALS_API_KEY || '', { name: 'DPSN Bot', goal: 'A bot that consumes realtime data from DPSN', description: 'A bot that processes real-time data streams from DPSN', workers: [ dpsnPlugin.getWorker(), ], }); // Initialize the agent await agent.init(); ``` -------------------------------- ### Initialize and Run Agent Tasks Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/zytronPlugin/README.md Initialize the agent and run tasks in a loop. This example demonstrates checking a wallet and sending tokens, with verbose logging enabled for each step. ```typescript (async () => { await agent.init(); const task1 = "Check my wallet"; const task2 = "Send 0.0001 ETH to 0x456..."; while (true) { await agent.step({ verbose: true, }); await agent.runTask(task1, { verbose: true, }); await agent.runTask(task2, { verbose: true, }); } })(); ``` -------------------------------- ### Run Test Suite Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Execute the full test suite to verify your integration. ```bash npm run test:all ``` -------------------------------- ### Build and Push Docker Image for Phala TEE Source: https://github.com/game-by-virtuals/game-node/blob/main/game-starter/README.md Builds the Docker image for the game starter project and pushes it to Docker Hub, preparing it for deployment to Phala cloud. ```bash docker compose build -t /virtuals-game-starter . docker push /virtuals-game-starter ``` -------------------------------- ### Initialize and Run GameAgent Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Demonstrates the correct initialization and running order for the GameAgent. Ensure agent.init() is called before agent.run(). ```javascript # 3. Ensure proper initialization order await agent.init(); // Must be called before agent.run() ``` -------------------------------- ### Install TypeScript Globally Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Ensure TypeScript is installed globally on your system. This is necessary for compiling TypeScript projects. ```bash # ❌ Error: TypeScript compilation errors # ✅ Solutions: # 1. Ensure TypeScript is installed npm install -g typescript ``` -------------------------------- ### Demo Scenarios Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Commands to run various demo scenarios, simulating trading bots, research agents, and new endpoint demonstrations. ```bash npm run demo:trading-bot # 🤖 Trading bot simulation npm run demo:research-agent # 🔬 Research agent demo npm run demo:new-endpoints # ✨ New endpoints demonstration npm run demo:indices # 📊 Crypto indices demo (NEW!) ``` -------------------------------- ### Run Trading Bot Demo Scenario Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md This command initiates a demo scenario simulating a trading bot. It's useful for testing automated trading strategies within the plugin. ```bash npm run demo:trading-bot ``` -------------------------------- ### Deploy and Verify Oasis ROFL Instance Source: https://github.com/game-by-virtuals/game-node/blob/main/game-starter/README.md Builds the ROFL bundle, updates the chain with the Enclave ID and secrets, and deploys the instance. Includes commands to show the instance status and verify the source code. ```bash oasis rofl build oasis rofl update oasis rofl deploy ``` ```bash oasis rofl show ``` ```bash oasis rofl build --verify ``` -------------------------------- ### Install ACP Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/acpPlugin/README.md Install the ACP plugin using npm. This is the first step to integrate ACP functionalities into your project. ```bash npm i @virtuals-protocol/game-acp-plugin ``` -------------------------------- ### Import and Initialize Token Metrics Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Import necessary modules, configure environment variables, and initialize the TokenMetricsPlugin with your API key. ```typescript import { config } from "dotenv"; config({ path: "./.env" }); import TokenMetricsPlugin from "tokenmetrics-virtuals-plugin"; import { GameAgent } from "@virtuals-protocol/game"; // Initialize the plugin const tokenMetricsPlugin = new TokenMetricsPlugin({ apiClientConfig: { apiKey: process.env.TOKENMETRICS_API_KEY!, }, }); ``` -------------------------------- ### Configure API Keys Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Ensure your .env file contains the necessary API keys for TokenMetrics and Game. ```bash # Ensure .env file has both keys: TOKENMETRICS_API_KEY=tm-your-key-here GAME_API_KEY=your-game-key-here ``` -------------------------------- ### Build the Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/coingeckoMaopPlugin/README.md Build the Coingecko plugin using the tsup command. ```bash npm run tsup ``` -------------------------------- ### Setup Viem Clients for Base Chain Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/ensoPlugin/README.md Configure viem clients for public and wallet interactions, specifying the Base chain and using environment variables for private keys and RPC URLs. ```typescript import { Address, createPublicClient, createWalletClient, http } from "viem"; import { base } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as Address); const publicClient = createPublicClient({ transport: http(process.env.RPC_PROVIDER_URL), chain: base, }); const walletClient = createWalletClient({ account: account, transport: http(process.env.RPC_PROVIDER_URL), chain: base, }); ``` -------------------------------- ### Build and Push Docker Image for Oasis ROFL Source: https://github.com/game-by-virtuals/game-node/blob/main/game-starter/README.md Builds the Docker image and pushes it to a container registry, preparing it for deployment with Oasis ROFL. It's recommended to use the image hash for integrity. ```bash docker build -t docker.io//virtuals-game-starter . docker push docker.io//virtuals-game-starter ``` -------------------------------- ### News Query Examples Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/stateofmikaPlugin/README.md Examples of natural language queries for retrieving news, including general headlines and news about specific projects or cryptocurrencies. ```typescript // Get latest crypto news "What are the top crypto headlines today?" "Show me recent news about Bitcoin" "What's the latest news about ETH ETFs?" // News about specific projects "Latest Cardano news" "Show me news about Binance" ``` -------------------------------- ### Initialize and Chat with a GAME Chat Agent Source: https://github.com/game-by-virtuals/game-node/blob/main/README.md Use this to initialize a chat agent with your API key and a system prompt. Ensure you are using a V2 API key that starts with 'apt-'. ```typescript const agent = new ChatAgent( "your-GAME-api-key-here", "" ); const response = await agent.chat(""); ``` -------------------------------- ### API Response Format Example Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/stateofmikaPlugin/README.md An example of the structured data returned by the State of Mika API, including the original query, route information, and tool-specific response. ```json { "original_query": "Latest crypto news", "route": { "tool": "news", "confidence": 0.9, "parameters": { "kind": "news", "regions": "en", "filter": "important", "currencies": "", "public": "true" } }, "response": { // Tool-specific response data } } ``` -------------------------------- ### Seller Agent Configuration Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/acpPlugin/example/agentic/README.md Configures the seller agent, including Twitter integration, ACP plugin setup, and defining a 'generate_meme' function. This setup is for agents providing services. ```typescript import { TwitterApi } from "@virtuals-protocol/game-twitter-node"; import { SELLER_AGENT_GAME_TWITTER_ACCESS_TOKEN } from "./env"; const twitterClient = new TwitterApi({ gameTwitterAccessToken: SELLER_AGENT_GAME_TWITTER_ACCESS_TOKEN, }); const acpPlugin = new AcpPlugin({ apiKey: GAME_DEV_API_KEY, acpClient: new AcpClient({ acpContractClient: await AcpContractClient.build( WHITELISTED_WALLET_PRIVATE_KEY, SELLER_ENTITY_ID, SELLER_AGENT_WALLET_ADDRESS, baseAcpConfig ), }), twitterClient: twitterClient, }); const coreWorker = new GameWorker({ id: "core-worker", name: "Core Worker", description: "This worker to provide meme generation as a service where you are selling ", functions: [ new GameFunction({ name: "generate_meme", description: "A function to generate meme", args: [ { name: "description", type: "string", description: "A description of the meme generated" }, { name: "jobId", type: "string", description: "Job that your are responding to." }, { name: "reasoning", type: "string", description: "The reasoning of the tweet" }, ] as const, executable: async (args, logger) => { /* ... */ }, }), ], getEnvironment: async () => acpPlugin.getAcpState(), }); const agent = new GameAgent(GAME_API_KEY, { name: "Memx", goal: "To provide meme generation as a service. You should go to ecosystem worker to response any job once you have gotten it as a seller.", description: `You are Memx, a meme generator. Meme generation is your life. You always give buyer the best meme.\n${acpPlugin.agentDescription}`, workers: [coreWorker, acpPlugin.getWorker()], getAgentState: () => acpPlugin.getAcpState(), }); await agent.init(); while (true) { await agent.step({ verbose: true }); await askQuestion("\nPress any key to continue...\n"); } ``` -------------------------------- ### Test Individual Token Metrics Functions Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Run specific example scripts to test individual Token Metrics functions like fetching tokens, price data, or trading signals. ```bash npm run example:tokens ``` ```bash npm run example:price-data ``` ```bash npm run example:trading-signals ``` -------------------------------- ### Run All Tests and Build Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Execute all tests and build the project. This is a crucial step before submitting changes to ensure code quality and functionality. ```bash npm run test:all npm run build ``` -------------------------------- ### Get Technical Analysis Support and Resistance Levels Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md Execute this command to get technical analysis levels for support and resistance. This is useful for identifying optimal entry and exit points. ```bash npm run example:resistance-support ``` -------------------------------- ### Import ImageGenPlugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/imageGenPlugin/README.md Import the ImageGenPlugin class from the installed package. ```typescript import ImageGenPlugin from "@virtuals-protocol/game-imagegen-plugin"; ``` -------------------------------- ### Import RecallStoragePlugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/recallStoragePlugin/README.md Import the RecallStoragePlugin class from the installed package. ```typescript import RecallStoragePlugin from "@virtuals-protocol/game-recall-storage-plugin"; ``` -------------------------------- ### Import RSS3Plugin Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/rss3Plugin/README.md Import the RSS3Plugin class from the installed package. ```typescript import RSS3Plugin from "@virtuals-protocol/game-rss3-plugin"; ``` -------------------------------- ### Import TwitterPlugin Class Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/twitterPlugin/README.md Import the TwitterPlugin class from the installed package. ```typescript import TwitterPlugin from "@virtuals-protocol/game-twitter-plugin"; ``` -------------------------------- ### Get Quantmetrics Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md Delivers quantitative analysis and metrics for advanced technical analysis. ```APIDOC ## Get Quantmetrics (`getQuantmetrics`) ### Description Quantitative analysis and metrics. ### Use Case Advanced technical analysis. ### Command ```bash npm run example:quantmetrics ``` ``` -------------------------------- ### Get Worker Instance Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/coverage/lcov-report/dpsnPlugin.ts.html Retrieves a GameWorker instance configured with DPSN-specific functions. ```APIDOC ## getWorker ### Description Get the GameWorker instance with DPSN functions. ### Method `public getWorker(data?: { id?: string; functions?: GameFunction[]; getEnvironment?: () => Promise>; }): GameWorker` ### Parameters - **data** (`object`, optional) - Configuration options for the worker. - **id** (`string`, optional) - The ID for the worker. - **functions** (`GameFunction[]`, optional) - An array of functions to include in the worker. - **getEnvironment** (`() => Promise>`, optional) - A function to retrieve the worker's environment. ``` -------------------------------- ### Import AttpsPlugin Class Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/attpsPlugin/README.md Import the AttpsPlugin class from the installed package to begin integration. ```typescript import AttpsPlugin from "@virtuals-protocol/game-attps-plugin"; ``` -------------------------------- ### Initialize and Use AI Agent Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Initialize the agent, optionally set up logging, and run a query to interact with the Token Metrics functions. ```typescript (async () => { // Optional: Set up logging agent.setLogger((agent, message) => { console.log(`🤖 [${agent.name}] ${message}`); }); await agent.init(); // Your agent now has 17 TokenMetrics functions! const result = await agent.run("Show me the available tokens"); console.log(result); })(); ``` -------------------------------- ### Handle Invalid API Key Error Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/README.md Example of an invalid API key error and its solution. ```bash ❌ Invalid API key provided 🔧 Solution: Verify API key format and permissions ``` -------------------------------- ### Get Trading Signals Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/COMPREHENSIVE_TEST_GUIDE.md Delivers AI-generated buy/sell recommendations to assist with automated trading decisions. ```APIDOC ## Get Trading Signals (`getTradingSignals`) ### Description AI-generated buy/sell recommendations. ### Use Case Automated trading decisions. ### Command ```bash npm run example:trading-signals ``` ``` -------------------------------- ### DpsnPlugin Constructor Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/dpsnPlugin/README.md Initializes the DPSN Plugin with necessary credentials and configuration options. ```APIDOC ## DpsnPlugin Constructor ### Description Initializes the DPSN Plugin with necessary credentials and configuration options. ### Signature ```typescript constructor(options: IDpsnPluginOptions) ``` ### Parameters - **options**: Required configuration object. - **credentials**: Required connection credentials. - **privateKey** (string): Your DPSN private key. - **dpsnUrl** (string): The DPSN server URL. - **chainOptions** (object): Blockchain configuration. - **network** (string): The network type (e.g., 'testnet'). - **wallet_chain_type** (string): The wallet chain type (e.g., 'ethereum'). - **contractAddress** (string, optional): DPSN contract address. - **connectionOptions** (object, optional): Additional connection options. - **initOptions** (object, optional): Additional initialization options. - **id** (string, optional): The worker ID. - **name** (string, optional): The worker name. - **description** (string, optional): The worker description. ``` -------------------------------- ### Get Account Summary Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/deskExchangePlugin/README.md Retrieves a comprehensive summary of your account, including positions, orders, and collaterals. ```APIDOC ## Get Account Summary ### Description Retrieves a comprehensive summary of your account, including positions, orders, and collaterals. ### Method `executable` (as part of `deskExchangePlugin.getAccountSummary`) ### Parameters #### Arguments - `logger`: An object for logging purposes. ### Request Example ```typescript const summary = await deskExchangePlugin.getAccountSummary.executable({}, logger) ``` ### Response #### Success Response Returns an `ExecutableGameFunctionResponse` object. - `status` (ExecutableGameFunctionStatus): The status of the execution. - `feedback` (string): A message providing details about the result. ### Response Example ```typescript { "status": "Success", "feedback": "Account summary retrieved successfully." } ``` ``` -------------------------------- ### Run Interactive Chat Source: https://github.com/game-by-virtuals/game-node/blob/main/plugins/tokenMetricsPlugin/DEVELOPER_INTEGRATION_GUIDE.md Use this command to start an interactive chat session for testing and exploration. ```bash npm run chat ```