Skip to main content

Overview

The Solana Agent Kit allows developers to build AI-driven agents that interact with Solana and Solayer seamlessly. It enables AI agents to perform on-chain transactions, including staking SOL on Solayer (sSOL staking) using Solana Blinks. With the Solana Agent Kit, AI-powered automation can integrate directly with Solayer’s DeFi ecosystem, supporting actions like staking, yield strategies, and more.

Installation

To install the Solana Agent Kit, use npm:
npm install solana-agent-kit

Quick Start Guide

Import & Initialize the Agent First, import the required modules and initialize the Solana Agent Kit with your wallet private key, Solana RPC URL, and OpenAI API key.
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";

// Initialize with private key and RPC URL
// For production, use Solayer mainnet:
const agent = new SolanaAgentKit(
  "your-wallet-private-key-as-base58",
  "https://mainnet-rpc.solayer.org",
  "your-openai-api-key"
);

// For testing and development, use Solayer devnet:
// const agent = new SolanaAgentKit(
//   "your-wallet-private-key-as-base58",
//   "https://devnet-rpc.solayer.org", // Devnet endpoint for testing only
//   "your-openai-api-key"
// );

// Create LangChain tools
const tools = createSolanaTools(agent);
The devnet RPC endpoint (https://devnet-rpc.solayer.org) is specifically for devnet and testing purposes only. Use the mainnet RPC endpoint (https://mainnet-rpc.solayer.org) for production applications.

Stake SOL on Solayer (sSOL Staking) To stake SOL on Solayer using the AI agent, call the restake function:
const signature = await agent.restake(
  1 // amount in SOL to stake
);

Additional Features & Documentation

The Solana Agent Kit is continuously evolving to support more DeFi integrations and automated smart contract interactions. For detailed documentation, examples, and latest updates, visit the GitHub repository:
Solana Agent Kit on GitHub