On-chain agentic management for Solana, powered by x402
$NEMO
L8tRGqXDnLsvw3nY3qYgvWCnjbQFYerDGNF9dVsnemo
Architecture • Getting Started • On-Chain Loops • x402 Integration • Contributing
NemoClaw is an open-source operating system for AI agents on Solana. Inspired by OpenClaw, it brings agentic infrastructure on-chain — where agent execution loops, state transitions, and payments are all recorded and verified on Solana.
Instead of running opaque agent loops on a server, NemoClaw anchors every cycle to the blockchain. Agents pay for tools via x402, and their execution history is an auditable, immutable ledger.
- Verifiable agent behavior — Every loop iteration is an on-chain transaction. You can audit exactly what your agent did, when, and what it paid.
- Native x402 payments — Agents pay for APIs, tools, and services using USDC on Solana via the x402 protocol. No accounts, no sessions — just signed HTTP payments.
- Composable tool marketplace — Publish and monetize agent tools as x402 endpoints. Other agents discover and pay-per-call automatically.
- Powered by Claude — Agent runtime uses the Anthropic API with full tool use support.
┌─────────────────────────────────────────────────────────┐
│ NemoClaw │
├──────────┬──────────┬──────────┬────────────────────────┤
│ Gateway │ Runtime │ Tools │ On-Chain Loops │
│ │ │ │ │
│ WebSocket│ Claude │ Local │ ┌─────────────────────┐ │
│ REST API │ Context │ x402 │ │ Solana Program │ │
│ x402 │ Memory │ MCP │ │ (Anchor) │ │
│ Middleware│ │ │ │ │ │
│ │ │ │ │ - Loop Registry │ │
│ │ │ │ │ - State Machine │ │
│ │ │ │ │ - Payment Escrow │ │
│ │ │ │ │ - Execution Log │ │
│ │ │ │ └─────────────────────┘ │
├──────────┴──────────┴──────────┴────────────────────────┤
│ Solana (L1) │
│ USDC Payments | Agent Registry | Loop State │
└─────────────────────────────────────────────────────────┘
| Component | Description |
|---|---|
| Gateway | WebSocket + REST control plane. Routes messages to the agent runtime. Supports real-time loop subscriptions via WebSocket. |
| Runtime | Executes the think/act/observe loop using Claude. Pluggable context engine with selective tool injection and persistent memory. Enforces timeouts. |
| Tools | Registry with selective injection — only relevant tools are sent to the LLM each turn. Tools can be local functions or remote x402 endpoints. |
| On-Chain Loops | Anchor program that records every agent step on Solana. State hashes, action logs, and payment records are committed as transactions. Falls back to local tracking if the program isn't deployed. |
| x402 Layer | Official Coinbase x402 SDK. CDP facilitator handles USDC payment verification and settlement — no self-hosting required. |
The defining feature of NemoClaw. Agent execution loops are anchored to Solana:
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ INIT │───>│ THINK │───>│ ACT │───>│ OBSERVE │──┐
│ │ │ │ │ │ │ │ │
│ tx: init │ │ tx: hash │ │ tx: hash │ │ tx: hash │ │
└──────────┘ └──────────┘ └──────────┘ └──────────┘ │
^ │
└─────────────────────────────────────────┘
Each state transition is a Solana transaction containing:
- State hash — SHA-256 of the agent's context at that point
- Action log — What tool was called and its result hash
- Payment record — Any x402 payments made during the step
- Timestamp — On-chain clock for ordering
This gives you a fully auditable, tamper-proof record of agent behavior.
// Anchor program
#[program]
pub mod nemo_loops {
pub fn init_loop(ctx: Context<InitLoop>, config: LoopConfig) -> Result<()>;
pub fn record_step(ctx: Context<RecordStep>, step: StepData) -> Result<()>;
pub fn complete_loop(ctx: Context<CompleteLoop>, summary: Vec<u8>) -> Result<()>;
pub fn abort_loop(ctx: Context<AbortLoop>, reason: String) -> Result<()>;
}NemoClaw uses the official Coinbase x402 SDK with the CDP facilitator — no self-hosted infrastructure needed. Coinbase handles payment verification and on-chain settlement.
import { X402Client } from 'nemoclaw';
const client = new X402Client({
privateKey: process.env.SOLANA_PRIVATE_KEY!,
maxPaymentUsdc: '1.00',
});
// Automatic 402 handling — SDK signs USDC payment, CDP settles on-chain
const response = await client.fetch('https://api.example.com/premium-data');
const data = await response.json();import express from 'express';
import { createX402Middleware } from 'nemoclaw';
const app = express();
app.use(createX402Middleware({
network: 'devnet',
routes: {
'GET /api/premium': {
price: '$0.001',
payTo: 'YourSolanaAddress...',
description: 'Premium agent data',
},
},
}));
app.get('/api/premium', (req, res) => {
res.json({ data: 'Paid content unlocked' });
});Agent Server CDP Facilitator Solana
│ │ │ │
│── GET /resource ──────>│ │ │
│<── 402 + PAYMENT-REQ ──│ │ │
│ │ │ │
│ (SDK signs USDC tx) │ │ │
│ │ │ │
│── GET + PAYMENT-SIG ──>│ │ │
│ │── verify + settle ──────>│ │
│ │ │── submit tx ──────>│
│ │ │<── confirmed ──────│
│ │<── settlement proof ─────│ │
│<── 200 + data ─────────│ │ │
- Free tier: 1,000 transactions/month via CDP (no API keys needed)
- Settlement: ~400ms on Solana, ~$0.00025 per transaction
- No self-hosting: CDP handles all blockchain complexity
- Node.js >= 20
- An Anthropic API key (console.anthropic.com)
- Solana CLI with a funded wallet (for on-chain features)
- Rust & Anchor CLI (for deploying the Solana program)
git clone https://github.com/nemoclaw/nemoclaw.git
cd nemoclaw
npm installcp .env.example .envRequired:
ANTHROPIC_API_KEY— for the Claude-powered agent runtimeSOLANA_PRIVATE_KEY— for x402 payments (base58 encoded)
Optional:
CDP_API_KEY_ID/CDP_API_KEY_SECRET— for higher x402 rate limitsSOLANA_RPC_URL— defaults to devnet
# Start the gateway (REST + WebSocket)
npm run gateway
# Deploy the on-chain loop program (devnet)
npm run deploy:devnet
# Development mode with auto-reload
npm run dev:watchimport {
AgentRuntime,
LoopExecutor,
X402Client,
ToolRegistry,
Gateway,
} from 'nemoclaw';
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
// Set up Solana connection
const connection = new Connection('https://api.devnet.solana.com');
const wallet = Keypair.generate();
const programId = new PublicKey('NeMoC1aw...');
// Create components
const loopExecutor = new LoopExecutor(connection, wallet, programId);
const x402Client = new X402Client({ privateKey: '...' });
const toolRegistry = new ToolRegistry();
// Register a tool
toolRegistry.register(ToolRegistry.createTool(
'get_weather',
'Get the current weather for a city',
{ type: 'object', properties: { city: { type: 'string' } }, required: ['city'] },
async (input: any) => ({ temperature: 72, city: input.city }),
));
// Create and run agent
const runtime = new AgentRuntime({
config: {
model: 'claude-sonnet-4-6',
apiKey: process.env.ANTHROPIC_API_KEY!,
maxLoops: 10,
loopTimeoutMs: 30000,
},
loopExecutor,
x402Client,
toolRegistry,
});
const response = await runtime.run('What is the weather in San Francisco?');
console.log(response);npm test # Unit tests
npm run test:integration # Integration tests (requires devnet)
npm run test:e2e # End-to-end testsnemoclaw/
├── src/
│ ├── main.ts # Application bootstrap (loads env, wires components)
│ ├── index.ts # Public API exports
│ ├── types.ts # Shared type definitions
│ ├── gateway/ # WebSocket + REST control plane
│ ├── runtime/
│ │ ├── agent/ # Claude-powered agent loop (Anthropic SDK)
│ │ ├── context/ # Context assembly + selective tool injection
│ │ └── memory/ # Persistent memory (atomic file writes)
│ ├── tools/
│ │ ├── registry.ts # Tool registry with Anthropic format export
│ │ └── builtins.ts # Built-in tools (http_fetch, calculate, etc.)
│ ├── loops/
│ │ └── executor/ # On-chain loop recording (Anchor instructions)
│ ├── x402/
│ │ ├── client/ # x402 fetch wrapper (auto 402 handling)
│ │ ├── facilitator/ # CDP facilitator setup
│ │ └── middleware/ # Express middleware for paid endpoints
│ └── solana/
│ ├── programs/ # Anchor program (nemo_loops.rs)
│ └── client/ # Solana helpers + PDA derivation
├── tests/
│ └── unit/ # Unit tests (registry, context, memory, builtins)
├── Anchor.toml
├── .github/workflows/ci.yml
└── .env.example
- Project scaffolding & architecture
- Gateway with WebSocket + REST (loop subscriptions, agent message routing)
- Agent runtime with Claude integration (Anthropic API, tool use)
- Pluggable context engine with selective tool injection
- Persistent agent memory with atomic writes
- x402 client for Solana via CDP facilitator
- x402 Express middleware for monetizing endpoints
- On-chain loop executor with Anchor instruction encoding
- Tool registry with Anthropic tool format export
- Anchor program for on-chain loops (init, record, complete, abort)
- Anchor program deployment + IDL generation
- Agent registry (on-chain)
- Multi-agent routing
- MCP server integration for external tools
- Dashboard / Mission Control UI
- Mainnet launch
NemoClaw is open source and we welcome contributions. See CONTRIBUTING.md for guidelines.
# Fork, clone, branch
git checkout -b feature/my-feature
# Make changes, test
npm test
# Submit a PRMIT License. See LICENSE for details.

