Getting Started with Agents
Learn how to set up and use AI Agents in W-Kits to interact with WhiteChain. Follow the steps below to create your first agent and start building decentralized applications powered by AI.
Installation
First, install the W-Kits package using your preferred package manager:
npm install w-kitsCreate Your First Agent
Once installed, you can create an AI Agent by importing the necessary modules and configuring it with your preferred model and blockchain settings. Here's an example:
import { Agent } from 'w-kits';
import { google } from 'w-kits/models';
const agent = new Agent({
model: google('gemini-2.0-flash-exp'),
chain: 'testnet',
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
tokenList: {
WPN: {
address: '0x619114eE16B57b43237153C585d5FAbd20e4EBfA',
symbol: 'WPN',
decimals: 18,
},
},
});Using the Agent
Once your agent is initialized, you can use it to interact with WhiteChain. Here are some common methods:
// Add a new token to the agent's token list
agent.addToken('WPN', '0x619114eE16B57b43237153C585d5FAbd20e4EBfA', 18);
// Get token information
const tokenInfo = agent.getToken('WPN');
// Generate text using the agent
const response = await agent.generateText({
prompt: 'What is the current gas price on WhiteChain?',
temperature: 0.7,
});Next Steps
Now that your agent is set up, you can start using it to interact with WhiteChain. Explore the documentation to learn more about advanced features like sending transactions, querying data, and integrating with dApps.