Skip to content

ATP Plugin

The ATP Plugin enables your agent to interact with IQ’s Agent Tokenization Platform. It provides functionality for:

Buying, selling, and managing AI agent tokens using IQ as the base currency Viewing agent performance metrics and token statistics Managing token holdings and checking position values


Installation

  1. Install the required packages:

    Terminal window
    npm i @iqai/agent @iqai/plugin-atp
  2. Create a .env file with the required configuration:

    Terminal window
    WALLET_PRIVATE_KEY=your-wallet-private-key

Basic Setup

Here’s a complete example of setting up an agent with the ATP plugin:

import { AgentBuilder, ModelProviderName } from "@iqai/agent";
import { createATPPlugin } from "@iqai/plugin-atp";
async function main() {
// Initialize ATP plugin
const atpPlugin = await createATPPlugin({
walletPrivateKey: process.env.WALLET_PRIVATE_KEY,
});
// Create agent with plugin
const agent = new AgentBuilder()
.withClient(DirectClient)
.withModelProvider(
ModelProviderName.OPENAI,
process.env.OPENAI_API_KEY
)
.withPlugin(bootstrapPlugin)
.withPlugin(atpPlugin)
.build();
await agent.start();
}
main().catch(console.error);

Available Operations

  • Agent Statistics: View performance metrics and token statistics
  • Portfolio Management: Monitor holdings and position values
  • Trading Operations: Buy/sell agent tokens using IQ
  • Agents list: View a list of available agents

Usage Examples

OperationExample Query
Check StatsShow me stats for agent 0x1234...5678
View PortfolioShow my ATP holdings
Buy TokensBuy 1000 IQ worth of agent 0x1234...5678
Sell TokensSell 50 tokens of agent 0x1234...5678
List AgentsShow me top agents on atp

Configuration Options

The ATP plugin accepts the following configuration parameters:

interface ATPPluginConfig {
walletPrivateKey: string; // Private key for transactions
}

Error Handling

Always implement proper error handling when using the plugin:

try {
const atpPlugin = await createATPPlugin({
walletPrivateKey: process.env.WALLET_PRIVATE_KEY,
});
} catch (error) {
console.error('Failed to initialize ATP plugin:', error);
}

Best Practices

  • βœ” Token Validation: Verify agent addresses before transactions
  • βœ” Amount Verification: Double-check token amounts and IQ values
  • βœ” Transaction Monitoring: Track transaction status and confirmations
  • βœ” Balance Management: Ensure sufficient IQ balance for purchases

Common Issues and Troubleshooting

  • Invalid Agent Address: Ensure you’re using the correct agent token contract address
  • Insufficient IQ Balance: Verify you have enough IQ tokens for purchases
  • Transaction Failures: Check transaction parameters and network status
  • Token Approval: Ensure proper token approvals before selling