Wallet Plugin
The Plugin Wallet enables your agent to interact with blockchain wallets. It provides functionality for:
- Fetching token holdings across multiple chains
- Retrieving transaction history for specified wallets
- Supporting multiple blockchain networks via the Covalent API
Installation
Section titled “Installation”-
Install the required package:
Terminal window npm i @iqai/plugin-walletTerminal window pnpm add @iqai/plugin-walletTerminal window yarn add @iqai/plugin-wallet -
Create a
.env
file with the required configuration:Terminal window COVALENT_API_KEY=your-covalent-api-keyWALLET_ADDRESS=your-wallet-address
Basic Setup
Section titled “Basic Setup”Here’s a complete example of setting up your agent with the Wallet Plugin:
import { createWalletPlugin } from "@iqai/plugin-wallet";
async function main() { // Initialize Wallet Plugin const walletPlugin = await createWalletPlugin({ covalentApiKey: process.env.COVALENT_API_KEY, walletAddress: process.env.WALLET_ADDRESS, });
// Integrate walletPlugin with your agent or system const agent = new AgentBuilder().withPlugin(walletPlugin).build(); await agent.start();}
main().catch(console.error);
Available Operations
Section titled “Available Operations”- Holdings Retrieval: Fetch token balances for a wallet
- Transaction History: Retrieve transaction details including timestamps, status, and gas information
Usage Examples
Section titled “Usage Examples”Operation | Example Query |
---|---|
Check Holdings | get my holdings on fraxtal |
Check Holdings | show my tokens on eth-mainnet |
Check Transactions | get my transactions on fraxtal |
Check Transactions | view transaction history of 0x1234...5678 on polygon |
Configuration Options
Section titled “Configuration Options”The Wallet Plugin accepts the following configuration parameters:
interface WalletPluginConfig { covalentApiKey: string; // Covalent API key for blockchain data access walletAddress: string; // Default wallet address}
Error Handling
Section titled “Error Handling”Always implement proper error handling when using the plugin:
try { const walletPlugin = await createWalletPlugin({ covalentApiKey: process.env.COVALENT_API_KEY, walletAddress: process.env.WALLET_ADDRESS, });} catch (error) { console.error('Failed to initialize Wallet Plugin:', error);}
Best Practices
Section titled “Best Practices”- Chain Validation: Verify supported chain names before making requests
- Address Verification: Ensure wallet addresses are correct and valid
- Rate Limit Awareness: Handle API rate limits according to Covalent guidelines
- Security Measures: Keep your API key secure and never expose it publicly
Common Issues and Troubleshooting
Section titled “Common Issues and Troubleshooting”- Invalid Chain Name: Ensure you’re using supported chain names as per the Covalent API documentation.
- Missing Wallet Address: If required, provide a valid wallet address.
- API Connection Errors: Check your network connectivity and API key validity.
- Rate Limiting: Be aware of the API rate limits and implement retries or backoff mechanisms.