GitHub Link

1. System Overview

AI agents on Solana are evolving from passive signal processors into autonomous on-chain actors. To execute trades, manage liquidity, and interact with dApps without manual intervention, each agent needs a wallet it can control directly through code. This project implements that model as an agentic wallet system on Solana devnet, where agents can autonomously make policy decisions, sign transactions, and interact with protocols end-to-end.

The system is powered by Groq's llama3-70b-8192 model through the OpenClaw decision engine, giving agents blazing-fast inference for real-time DeFi decision-making — while a deterministic fallback engine ensures the system never stalls.

Architecture Layers

The system is organized into four clearly separated layers:

┌──────────────────────────────────────────────────────────────┐
│                    CLI / Dashboard UI                        │
├──────────────────────────────────────────────────────────────┤
│   Agent Decision Layer                                       │
│   ┌──────────────────┐  ┌────────────────────────────────┐  │
│   │  ThresholdEngine │  │  OpenClawDecisionEngine (AI)    │  │
│   │  (deterministic) │◄─┤  Groq llama3-70b + fallback     │  │
│   └──────────────────┘  └────────────────────────────────┘  │
├──────────────────────────────────────────────────────────────┤
│   Agent Execution Layer                                      │
│   ┌────────────────┐  ┌──────────────────┐  ┌────────────┐ │
│   │ ScriptedAgent  │  │ AgentOrchestrator │  │ Guardrails │ │
│   └────────────────┘  └──────────────────┘  └────────────┘ │
├──────────────────────────────────────────────────────────────┤
│   Wallet & Protocol Layer                                    │
│   ┌──────────────┐  ┌────────────────────┐  ┌────────────┐ │
│   │ AgentWallet  │  │ SolTransferProtocol│  │ SplToken   │ │
│   └──────────────┘  └────────────────────┘  │ Protocol   │ │
│                                              └────────────┘ │
├──────────────────────────────────────────────────────────────┤
│   Security Layer                                             │
│   ┌──────────────────────────────────────────────────────┐  │
│   │  Keystore (AES-256-GCM encrypted, 0o600 permissions) │  │
│   └──────────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────┘

Agent Decision Layer: A pluggable DecisionEngine interface allows swapping between a deterministic threshold-based strategy and an AI-powered OpenClaw engine backed by Groq's llama3-70b-8192 LLM. The OpenClaw engine sends structured prompts to the Groq-powered runtime, passing LLM_PROVIDER, LLM_MODEL, and GROQ_API_KEY as environment variables. JSON responses are parsed back into typed decisions with Zod schema validation. If OpenClaw fails or returns invalid output, it automatically falls back to the threshold engine — ensuring the agent always has a decision path.

Agent Execution Layer: The ScriptedAgent class bridges decisions and wallet operations. It queries the decision engine, enforces guardrails (balance floor, daily spend cap, target allowlist), and then delegates to the protocol layer. The AgentOrchestrator schedules multiple agents across rounds in a round-robin peer pairing model.

Wallet & Protocol Layer: The AgentWallet class wraps a Solana Keypair and Connection, providing methods for programmatic creation, balance queries, airdrops, and signed transfers with memo metadata for on-chain traceability. Protocol adapters (SolTransferProtocol, SplTokenProtocol) translate high-level intent into concrete Solana instructions.

Security Layer: The keystore module handles persistent key management with optional AES-256-GCM encryption at rest, scrypt-derived keys, and restrictive file permissions (0o600).

2. Wallet Design

Programmatic Creation and Loading

Wallets are created and loaded through AgentWallet.fromKeystore(id, connection). Under the hood, this calls loadOrCreateKeypair() which:

  1. Checks if a keyfile for the given agent ID already exists in .keystore/.
  2. If not, generates a fresh Keypair via Keypair.generate() and persists it.
  3. If a passphrase is set via AGENT_KEYSTORE_PASSPHRASE, the secret key is encrypted before writing to disk.
  4. Returns a loaded AgentWallet instance ready for on-chain operations.

This means wallet provisioning is fully automatic — an agent only needs an ID string, and the system handles the rest.

Automated Transaction Signing