Integrate Into Your DApp

Integrate Into Your DApp

Starknet Agent Kit can be integrated into your existing dApp or process as an NPM package, enabling AI-powered interactions with the Starknet blockchain through natural language.

Current Features

Install Package

Add the Starknet Agent Kit to your project:

npm install starknet-agent-kit
# or
yarn add starknet-agent-kit
# or
pnpm add starknet-agent-kit

Initialize Agent

Create a new agent instance with your configuration:

import { StarknetAgent } from "starknet-agent-kit";
 
const agent = new StarknetAgent({
  // AI Provider Configuration
  aiProviderApiKey: "your-ai-provider-key",
  aiProvider: "anthropic", // or 'openai', 'gemini', 'ollama'
  aiModel: "claude-3-5-sonnet-latest",
  
  // Starknet Configuration
  accountPrivateKey: "your-wallet-private-key",
  rpcUrl: "your-rpc-url",
});

Execute Commands

Use natural language to interact with Starknet:

// Query balances
await agent.execute("What is my ETH balance?");
 
// Perform transfers
await agent.execute("transfer 0.1 ETH to 0x123...");
 
// Execute swaps
await agent.execute("Swap 5 USDC for ETH");

Configuration Reference

The StarknetAgent constructor currently accepts the following configuration options:

interface StarknetAgentConfig {
  // Required Parameters
  aiProviderApiKey: string;    // Your AI provider API key
  aiProvider: "anthropic" | "openai" | "gemini" | "ollama";  // AI model provider
  aiModel: string;             // Model identifier (e.g., "claude-3-5-sonnet-latest")
  accountPrivateKey: string;   // Your Starknet wallet private key
  rpcUrl: string;             // Starknet RPC endpoint
}

Make sure to never expose your private keys or API keys in your code. Use environment variables or secure key management solutions.