Documentation Index
Fetch the complete documentation index at: https://docs.radixagent.com/llms.txt
Use this file to discover all available pages before exploring further.
Radix Agent Kit provides AI agents with comprehensive Radix blockchain functionality through 20 specialized tools and direct API access.
🤖 AI Agent Core
Natural Language Processing
Agents translate plain English into blockchain operations using GPT-4 by default.
const agent = new RadixAgent({
networkId: RadixNetwork.Stokenet,
openaiApiKey: process.env.OPENAI_API_KEY,
model: "gpt-4", // or gpt-3.5-turbo
temperature: 0.1
});
await agent.run("Send 100 XRD to account_tdx_...");
Memory Management
Optional conversation memory for context-aware interactions.
const agent = new RadixAgent({
useMemory: true, // BufferMemory for conversation history
maxIterations: 10
});
Pre-built tools organized by operation type:
- Account & Wallet: 3 tools
- Token Operations: 5 tools
- Component Interaction: 2 tools
- Validator Operations: 3 tools
- DeFi Operations: 6 tools (Ociswap Pool V2 support)
- Utility: 1 tool
💰 Account & Wallet Management
Wallet Creation
Generate secure 24-word BIP-39 mnemonics compatible with Radix Wallet.
// Generate new wallet
const { wallet, mnemonic } = RadixMnemonicWallet.generateRandom({
networkId: NetworkId.Stokenet
});
// From existing mnemonic
const wallet = RadixMnemonicWallet.fromMnemonic(mnemonic, {
networkId: NetworkId.Stokenet,
accountIndex: 0
});
Get comprehensive account details including metadata and balances.
await agent.run("Show my account details");
// Returns: address, public key, metadata, XRD balance
Balance Checking
View all fungible tokens and NFT collections with formatted amounts.
await agent.run("What are my token balances?");
// Returns: All tokens with symbols, amounts, resource addresses
Testnet Funding
Automatic funding for new wallets on Stokenet using multiple faucet methods.
const faucetHelper = new FaucetHelper();
await faucetHelper.autoFundNewWallet(wallet, 100); // Minimum 100 XRD
🪙 Token Operations
Fungible Token Creation
Create tokens with configurable parameters.
await agent.run("Create token GameCoin with symbol GAME and supply 1000000");
// Direct API
const token = new Token(transactionBuilder, gatewayClient, networkId);
await token.createFungibleResource({
name: "GameCoin",
symbol: "GAME",
initialSupply: "1000000",
divisibility: 18
}, wallet, currentEpoch);
NFT Collection Creation
Deploy non-fungible token collections with metadata support.
await agent.run("Create NFT collection CryptoArt");
// With parameters
await token.createNonFungibleResource({
name: "CryptoArt",
description: "Digital art collection",
maxSupply: 10000,
iconUrl: "https://example.com/icon.png"
}, wallet, currentEpoch);
Token Minting
Mint additional supply for existing resources.
// Fungible tokens
await agent.run("Mint 1000 more tokens of resource_tdx_...");
// NFTs with metadata
await agent.run("Mint NFT with custom metadata");
Token Transfers
Send both fungible tokens and NFTs between accounts.
// Fungible transfer
await agent.run("Send 100 XRD to account_tdx_...");
// NFT transfer
await agent.run("Transfer NFT #001 from collection resource_... to account_tdx_...");
// Direct API
await token.transferFungible({
fromAccount: wallet.getAddress(),
toAccount: "account_tdx_...",
resourceAddress: "resource_tdx_...",
amount: "100"
}, wallet, currentEpoch);
🔧 Component Interaction
Smart Contract Calls
Execute methods on any Radix component with parameters.
await agent.run("Call get_price method on component_tdx_...");
// Direct API
const component = new Component(transactionBuilder, gatewayClient, networkId);
await component.callMethod({
componentAddress: "component_tdx_...",
methodName: "get_price",
args: ["arg1", "arg2"]
}, wallet, currentEpoch);
State Inspection
Retrieve current state data from components.
await agent.run("Get state of component_tdx_...");
await component.getState({
componentAddress: "component_tdx_..."
});
🥩 Validator Operations
XRD Staking
Stake XRD with validators to earn rewards.
await agent.run("Stake 100 XRD with validator_tdx_...");
// Direct API
const defi = new DeFi(transactionBuilder, gatewayClient, networkId);
await defi.stakeXRD({
ownerAddress: wallet.getAddress(),
validatorAddress: "validator_tdx_...",
amount: "100"
}, wallet, currentEpoch);
Unstaking
Withdraw staked XRD from validators.
await agent.run("Unstake 50 XRD from validator_tdx_...");
await defi.unstakeXRD({
ownerAddress: wallet.getAddress(),
validatorAddress: "validator_tdx_...",
amount: "50"
}, wallet, currentEpoch);
Reward Claiming
Collect staking rewards from validators.
await agent.run("Claim rewards from validator_tdx_...");
await defi.claimXRD({
ownerAddress: wallet.getAddress(),
validatorAddress: "validator_tdx_..."
}, wallet, currentEpoch);
🏊♂️ DeFi Operations
Pool Creation (Ociswap Pool V2)
Create advanced liquidity pools with multiple features.
// Standard pool
await agent.run("Create pool with 1000 XRD and 2000 TOKEN with 0.3% fee");
// Imbalanced pool (80/20)
await agent.run("Create 80/20 weighted pool with 8000 XRD and 2000 TOKEN");
// Hooked pool with custom logic
await agent.run("Create hooked pool with hook component_tdx_... using 1000 XRD and 2000 TOKEN");
// Direct API
await defi.createTwoResourcePool({
ownerAddress: wallet.getAddress(),
resourceAddress1: "resource_tdx_...",
resourceAddress2: "resource_tdx_...",
amount1: "10000",
amount2: "20000",
feeTier: 30, // 0.3% fee
assetRatio: [80, 20], // Optional: imbalanced pool
hookAddress: "component_tdx_..." // Optional: hooked pool
}, wallet, currentEpoch);
Liquidity Management
Add/remove liquidity with slippage protection.
// Add liquidity
await agent.run("Add 1000 XRD and 2000 TOKEN to pool component_tdx_...");
// Remove liquidity
await agent.run("Remove 100 LP tokens from pool component_tdx_...");
// Direct API with slippage protection
await defi.addLiquidity({
ownerAddress: wallet.getAddress(),
poolAddress: "component_tdx_...",
amounts: ["1000", "2000"],
minAmounts: ["990", "1980"] // 1% slippage tolerance
}, wallet, currentEpoch);
await defi.removeLiquidity({
ownerAddress: wallet.getAddress(),
poolAddress: "component_tdx_...",
amountLP: "100",
minAmounts: ["980", "1960"]
}, wallet, currentEpoch);
Token Swapping
Execute swaps with minimum output protection.
await agent.run("Swap 100 XRD for TOKEN in pool component_tdx_... expecting min 195 TOKEN");
await defi.swapTokens({
ownerAddress: wallet.getAddress(),
poolAddress: "component_tdx_...",
fromResourceAddress: "resource_tdx_...",
toResourceAddress: "resource_tdx_...",
amountIn: "100",
minAmountOut: "195" // Slippage protection
}, wallet, currentEpoch);
Flash Loans
Borrow and repay tokens in a single transaction.
await agent.run("Flash loan 10000 XRD from pool component_tdx_... using callback component_tdx_...");
await defi.executeFlashLoan({
ownerAddress: wallet.getAddress(),
poolAddress: "component_tdx_...",
resourceAddress: "resource_tdx_...",
amount: "10000",
callbackComponentAddress: "component_tdx_...",
callbackData: "0x1234..."
}, wallet, currentEpoch);
🔐 Security Features
Transaction Validation
Comprehensive security checks before transaction execution.
const security = new TransactionSecurity({
maxAmount: 1000, // Max XRD per transaction
allowedDestinations: ["account_tdx_..."], // Whitelist
forbiddenDestinations: ["account_tdx_..."], // Blacklist
allowResourceCreation: true,
allowComponentCalls: true,
maxActionsPerTransaction: 10
});
const validation = security.validateTransaction(transaction, {
totalAmount: 100,
destinations: ["account_tdx_..."],
actionCount: 3
});
Rate Limiting
Prevent transaction spam with configurable limits.
const rateLimiting = {
maxTransactions: 10,
timeWindowMs: 60000, // 1 minute
throwOnLimit: true
};
const security = new TransactionSecurity({}, rateLimiting);
Secure Key Storage
AES-256-GCM encryption for sensitive data.
const storage = new SecureKeyStorage();
await storage.storeKey("wallet-key", mnemonic, "mnemonic", {
created: Date.now(),
network: "stokenet"
});
const retrieved = await storage.getKey("wallet-key", "mnemonic");
Automatic validation for all address formats and amounts.
// Address validation
transactionBuilder.isValidAddress("account_tdx_..."); // true/false
// Amount validation with decimal handling
const parsed = parseFloat("100.5"); // Automatic validation
🌐 Network Support
Multi-Network
Support for Radix Mainnet and Stokenet with automatic configuration.
// Stokenet (testnet)
const agent = new RadixAgent({
networkId: RadixNetwork.Stokenet // https://stokenet.radixdlt.com
});
// Mainnet
const agent = new RadixAgent({
networkId: RadixNetwork.Mainnet // https://mainnet.radixdlt.com
});
Gateway Integration
Direct access to Radix Gateway API with error handling and retries.
const gateway = new RadixGatewayClient({
networkId: RadixNetwork.Stokenet,
applicationName: "MyApp"
});
const status = await gateway.getGatewayStatus();
const epoch = await gateway.getCurrentEpoch();
const balances = await gateway.getAccountBalances("account_tdx_...");
🛠️ Direct API Access
Transaction Building
Low-level transaction construction for advanced use cases.
const builder = new RadixTransactionBuilder({
networkId: RadixNetwork.Stokenet
});
const transaction = await builder.buildTransferTransaction({
fromAccount: wallet.getAddress(),
toAccount: "account_tdx_...",
resourceAddress: "resource_tdx_...",
amount: "100"
}, wallet.getPrivateKeyHex(), currentEpoch);
Wallet Management
Multiple wallet types with Ed25519 cryptography.
// Mnemonic wallet
const mnemonicWallet = RadixMnemonicWallet.fromMnemonic(mnemonic, config);
// Hardware wallet interface
const hardwareWallet = new VaultWallet(config);
// Basic wallet interface
interface RadixWallet {
getAddress(): string;
getPublicKey(): string;
getPrivateKeyHex(): string;
signTransaction(hash: Uint8Array): Promise<string>;
}
Service Classes
Specialized classes for different blockchain operations.
// Token operations
const token = new Token(builder, gateway, networkId);
// DeFi operations
const defi = new DeFi(builder, gateway, networkId);
// Component interactions
const component = new Component(builder, gateway, networkId);
// Account management
const account = new RadixAccount(builder, gateway, networkId);
Error Handling
Comprehensive error handling with user-friendly messages.
// Tool-level error handling
try {
const result = await tool.func(input);
} catch (error) {
return `❌ Operation failed: ${error.message}`;
}
Transaction Monitoring
Track transaction status and receipt details.
const txHash = await submitTransaction(tx);
const status = await gateway.getTransactionStatus(txHash);
const details = await gateway.getTransactionDetails(txHash);
Connection Management
Automatic endpoint selection and connection pooling.
// Gateway client handles:
// - Automatic network endpoint selection
// - Request retries on failure
// - Connection timeout management
// - Response validation
🎯 Integration Examples
Discord Bot
import { RadixAgent } from "radix-agent-kit";
const agent = new RadixAgent({
networkId: RadixNetwork.Stokenet,
mnemonic: process.env.WALLET_MNEMONIC
});
client.on('messageCreate', async (message) => {
if (message.content.startsWith('!radix ')) {
const command = message.content.slice(7);
const response = await agent.run(command);
await message.reply(response);
}
});
Web API
app.post('/api/blockchain', async (req, res) => {
const { command, userId } = req.body;
// User-specific wallet
const agent = new RadixAgent({
mnemonic: getUserMnemonic(userId),
networkId: RadixNetwork.Stokenet
});
const result = await agent.run(command);
res.json({ result });
});
class MyCustomTool extends DynamicStructuredTool {
name = "my_custom_operation";
description = "Performs custom blockchain operation";
schema = z.object({
param1: z.string(),
param2: z.number()
});
func = async ({ param1, param2 }) => {
// Custom logic using radix services
return "Operation completed";
};
}
const agent = new RadixAgent({
customTools: [new MyCustomTool()]
});
📋 Complete Feature Matrix
| Category | Features | Tools | Direct API |
|---|
| Account Management | Address generation, balance checking, account info | 3 tools | RadixAccount, RadixWallet |
| Token Operations | Create, mint, transfer tokens and NFTs | 5 tools | Token class |
| DeFi | Pool creation, liquidity, swapping, flash loans | 9 tools | DeFi class |
| Smart Contracts | Method calls, state inspection | 2 tools | Component class |
| Security | Validation, encryption, rate limiting | Built-in | TransactionSecurity, SecureKeyStorage |
| Network | Multi-network, gateway integration | Built-in | RadixGatewayClient |
| Wallet | Multiple types, key management | Built-in | MnemonicWallet, VaultWallet |
All features work independently or together through the AI agent interface.