starknet-agent-kit

starknet-agent-kit

A toolkit for creating AI agents that can interact with the Starknet blockchain

Stars: 54

Visit
 screenshot

starknet-agent-kit is a NestJS-based toolkit for creating AI agents that can interact with the Starknet blockchain. It allows users to perform various actions such as retrieving account information, creating accounts, transferring assets, playing with DeFi, interacting with dApps, and executing RPC read methods. The toolkit provides a secure environment for developing AI agents while emphasizing caution when handling sensitive information. Users can make requests to the Starknet agent via API endpoints and utilize tools from Langchain directly.

README:


starknet-agent-kit (alpha)

NPM Version License GitHub Stars Node Version

A NestJS-based toolkit for creating AI agents that can interact with the Starknet blockchain.

⚠️ Warning: This kit is currently under development. Use it at your own risk! Please be aware that sharing sensitive information such as private keys, personal data, or confidential details with AI models or tools carries inherent security risks. The contributors of this repository are not responsible for any loss, damage, or issues arising from its use.

Getting Started

npm install @nestjs/common @nestjs/core @nestjs/platform-fastify starknet @langchain/anthropic

You will need two things:

  • A Starknet wallet private key (you can get one from Argent X)
  • An Anthropic API key

Basic Usage

import { StarknetAgent } from 'starknet-agent-kit';

const agent = new StarknetAgent({
  anthropicApiKey: process.env.ANTHROPIC_API_KEY,
  walletPrivateKey: process.env.PRIVATE_KEY,
});

// Execute commands in natural language
await agent.execute('transfer 0.1 ETH to 0x123...');

// Get balance
await agent.execute('What is my ETH balance?');

// Swap tokens
await agent.execute('Swap 5 USDC for ETH');

// Create account
await agent.execute('Create a new Argent account');

Features

  • Retrieve account infos (Balance, public key, etc)
  • Create one or multiple accounts (Argent & OpenZeppelin)
  • transfer assets between accounts
  • Play with DeFi (Swap on Avnu)
  • Play with dApps (Create a .stark domain)
  • All RPC read methods supported (getBlockNumber, getStorageAt, etc.)

Environment Variables

Create a .env file with the following variables:

# Your Starknet wallet private key (required)
PRIVATE_KEY=your_private_key

# Your Starknet public address (required)
PUBLIC_ADDRESS=your_public_address

# Your Anthropic API key for AI functionality (required)
# Get it from: https://console.anthropic.com/
ANTHROPIC_API_KEY=your_anthropic_api_key

# Your Starknet RPC URL (required)
# You can use public endpoints or get a dedicated one from providers like Infura
RPC_URL=your_rpc_url

# Your custom API key for securing the endpoints (required)
# Generate a strong random string to protect your API endpoints
# This key must be included in the x-api-key header when making requests to your API
# You can generate a secure random string using these commands:
#   - Linux/macOS: openssl rand -hex 32
#   - Windows (PowerShell): -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 32 | % {[char]$_})
API_KEY=your_api_key

Local Development

  1. Clone the repository:
git clone https://github.com/yourusername/starknet-agent-kit.git
  1. Install dependencies:
npm install
  1. Start the development server:
npm run start:dev

The API will be available at http://localhost:3000/api.

API Endpoints

POST /api/agent/request

Make requests to the Starknet agent.

Request body:

{
  "request": "Your natural language request here"
}

Headers:

x-api-key: your_api_key

Tools

All Langchain tools are available to be imported and used directly:

import { getBalance, transfer, swapTokens } from 'starknet-agent-kit';

Testing

To run tests:

npm run test

For E2E tests:

npm run test:e2e

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for starknet-agent-kit

Similar Open Source Tools

For similar tasks

For similar jobs