A server that initializes and manages a Solana Agent for onchain interactions using LangChain and OpenAI.
- Dynamic agent initialization with configurable LLM parameters
- Secure wallet key derivation from kms derive server
- Real-time chat interface with the agent
- Wallet address retrieval endpoint
POST /init
Request body:
{
"OPENAI_API_KEY": "your-api-key",
"RPC_URL": "your-rpc-url",
"llm": {
"modelName": "gpt-4o-mini", // optional, default: "gpt-4o-mini"
"temperature": 0.7 // optional, default: 0.7
}
}
POST /chat
Request body:
{
"message": "your message here"
}
GET /wallet
- Install dependencies:
npm install
- Start the server:
npm run start
The server will run on port 8000 by default. You can change this by setting the PORT
environment variable.
- Build the TypeScript code:
npm run build
- Run in development mode:
npm run dev
docker build -t <username>/solana-agent-kit:latest .
docker push <username>/solana-agent-kit:latest
oyster-cvm -- deploy \
--region us-west-1 \
--wallet-private-key <wallet-secret> \
--duration-in-minutes 60 \
--docker-compose ./docker-compose.yml
The following variables are set automatically during initialization:
OPENAI_API_KEY
: OpenAI API key for LLM interactionsRPC_URL
: Solana RPC URL for blockchain interactionsSOLANA_PRIVATE_KEY
: Wallet's private key derived from the local server (base58 encoded)SOLANA_PUBLIC_KEY
: Wallet's public key (base58 encoded)
Instead of generating random keys, this server uses a deterministic key derivation approach:
- The server fetches an Ed25519 private key from a localhost derive server
- The key is requested with a specific path parameter (
signing-server
) - Solana's
Keypair.fromSeed()
creates a keypair from the 32-byte private key - This approach ensures consistent key generation across server restarts
The wallet secret key is persistent across deployments -- even if you stop / redeploy your instance, as long as it's the same code -- the wallet will be the same. This feature enables:
- Secure, as only the ai agent can access the private key when run inside the Oyster CVM
- Consistent identity for your AI agent on-chain
- Ability to keep funds in the same wallet across deployments
- No need to re-fund or re-authorize a new wallet when restarting
- Seamless continuity of operations for long-running AI agents
This persistent identity makes AI agents all the more practical on Oyster TEE, enabling autonomous on-chain agents with stable, long-term blockchain identities.