GAME SDK plugin that gives any Virtuals AI agent persistent long-term memory and storage via MoltBrain x402 micropayments on Base.
This plugin lets Virtuals Protocol AI agents:
- Chat with MoltBrain AI for contextual assistance
- Search memories semantically across sessions
- Store and retrieve content-addressed data blobs
- Allocate, write, and read named memory slots
- Check storage capacity
Every paid endpoint costs $0.01 USDC on Base, settled via the x402 protocol (EIP-3009 TransferWithAuthorization).
npm install @moltbrain/game-pluginimport { GameAgent } from "@virtuals-protocol/game";
import { MoltBrainPlugin } from "@moltbrain/game-plugin";
const moltbrain = new MoltBrainPlugin({
privateKey: process.env.AGENT_PRIVATE_KEY!, // wallet with USDC on Base
});
const agent = new GameAgent(process.env.GAME_API_KEY!, {
name: "My Agent",
goal: "Remember everything across sessions",
description: "An agent with persistent memory via MoltBrain",
workers: [moltbrain.getWorker()],
});
await agent.init();
await agent.step({ verbose: true });| Option | Required | Default | Description |
|---|---|---|---|
privateKey |
Yes | — | Hex private key for agent wallet (must hold USDC on Base) |
serverUrl |
No | https://app.moltbrain.dev/api/x402 |
MoltBrain API URL |
rpcUrl |
No | https://mainnet.base.org |
Base RPC endpoint |
id |
No | moltbrain_worker |
Worker ID |
name |
No | MoltBrain Memory Worker |
Worker display name |
description |
No | (auto) | Worker description for the GAME planner |
| Function | Cost | Description |
|---|---|---|
moltbrain_chat |
$0.01 | Chat with MoltBrain AI |
moltbrain_search |
$0.01 | Semantic memory search |
moltbrain_store |
$0.01 | Store a JSON blob (content-addressed). Accepts optional label. |
moltbrain_retrieve |
$0.01 | Retrieve blob by SHA-256 hash |
moltbrain_allocate_slot |
$0.01 | Allocate a named memory slot. Accepts optional label. |
moltbrain_write_slot |
$0.01 | Write data to a slot |
moltbrain_read_slot |
$0.01 | Read data from a slot |
moltbrain_stats |
$0.01 | Memory analytics |
moltbrain_capacity |
FREE | Node storage capacity |
Everything your agent stores or allocates shows up in the MoltBrain Storage dapp at app.moltbrain.dev/storage. Connect the same wallet your agent uses to browse, view, and delete stored data.
Use the optional label parameter on moltbrain_store and moltbrain_allocate_slot to tag items (e.g. "virtuals_agent", "session_config"). Labels appear as badges in the vault UI.
- Agent makes an HTTP request to a MoltBrain endpoint
- Server responds
402 Payment Requiredwith USDC payment requirements - Plugin signs an EIP-3009
TransferWithAuthorizationoff-chain - Request retries with
X-PAYMENTheader containing the signed proof - PayAI facilitator verifies and settles the USDC transfer on Base
The agent wallet needs USDC on Base and a small amount of ETH for gas.
cp .env.example .env
# Fill in GAME_API_KEY and AGENT_PRIVATE_KEY
npm install
npm run exampleMIT