import "dotenv/config"; // Required for Node.js environmentsimport { RadixAgent, RadixNetwork, RadixMnemonicWallet } from "radix-agent-kit";// Generate a new 24-word walletconst wallet = RadixMnemonicWallet.generateRandom({ networkId: 2 // Stokenet});console.log("🔑 Your address:", wallet.getAddress());console.log("📝 Your mnemonic:", wallet.getMnemonic());// Create agent with new walletconst agent = new RadixAgent({ networkId: RadixNetwork.Stokenet, openaiApiKey: process.env.OPENAI_API_KEY, wallet: wallet});// ⚠️ New wallets start with 0 XRD!// Use the agent to request funding: see step 4 below
// Ask your agent to fund your walletconst result = await agent.run("Fund my wallet with testnet XRD");console.log(result);// Check if it workedawait agent.run("What's my XRD balance?");
Try these basic commands to verify everything works:
Copy
async function testAgent() { try { // Check balance console.log(await agent.run("What's my XRD balance?")); // Get account info console.log(await agent.run("Show my account details")); // Check current epoch console.log(await agent.run("What's the current epoch?")); } catch (error) { console.error("Error:", error.message); }}testAgent();
// Check balancesawait agent.run("What's my XRD balance?");await agent.run("Show all my token balances");// Account informationawait agent.run("Show my account details");// Request more testnet XRD if neededawait agent.run("Fund my wallet");
// Create a fungible tokenawait agent.run("Create a token called GameCoin with symbol GAME and supply 1000000");// Create an NFT collectionawait agent.run("Create NFT collection called CryptoArt");
// Send XRD (replace with a real address)await agent.run("Send 10 XRD to account_tdx_2_1c8atrq...");// Send custom tokensawait agent.run("Send 100 GameCoin to account_tdx_2_1c8atrq...");
// Stake XRD (replace with a real validator address)await agent.run("Stake 100 XRD with validator_tdx_2_1sd5368...");// Check staking statusawait agent.run("Show my staking positions");// Claim rewardsawait agent.run("Claim rewards from validator_tdx_2_1sd5368...");
// Create a liquidity poolawait agent.run("Create pool with 1000 XRD and 2000 TOKEN with 0.3% fee");// Add liquidity to existing poolawait agent.run("Add 500 XRD and 1000 TOKEN to pool component_rdx_...");// Swap tokensawait agent.run("Swap 100 XRD for TOKEN in pool component_rdx_...");// Remove liquidityawait agent.run("Remove 50 LP tokens from pool component_rdx_...");
DeFi on Stokenet: Ociswap pools are only available on Mainnet. For Stokenet testing, deploy your own pool blueprint like SimplePool.