The persistent memory layer
for autonomous AI agents.
A drop-in SDK that gives any AI agent verifiable, cross-session memory backed by 0G Storage — KV for fast context, Log for immutable archival, and 0G Chain for on-chain settlement. No databases. No vendor lock-in.
Traditional AI agents store memory in centralized databases — a single point of failure, a vendor dependency, and an untrusted black box. If the database goes down, the agent loses its context. If the vendor changes terms, you migrate or lose everything. There is no proof the data was not modified.
Agent context, client profiles, and session state. Key-value pairs written to 0G's KV stream layer. Overwritable. Indexed by the agent's stream ID. Best for frequently read, mutable data.
Invoices, events, and audit trails. Files uploaded to 0G Storage return a Merkle root hash. Append-only — data cannot be modified after upload. StorageScan provides a public URL for every archived record.
The AgentPayment contract anchors invoice IDs and storage root hashes on-chain. Clients pay into escrow on 0G Chain. The owner releases funds. Every invoice has a ChainScan link.
The entire 0G-Memory API surface is three async methods. Initialize once with your 0G credentials, then drop it anywhere in your agent pipeline.
Write to KV stream + Log layer. Returns root hash.
Retrieve from 0G Storage via root hash. Returns value or null.
Append-only log write. Returns rootHash + StorageScan URL.
// Write agent context to 0G Storage (KV + Log layers) await memory.remember('client:acme', { budget: 50000, preferredStack: 'TypeScript', timezone: 'Asia/Singapore', }); // → KV write: on-chain stream tx // → Log write: returns root hash // → Local index: key → rootHash mapping
import { ChainMemory } from '0g-memory-sdk'; const memory = new ChainMemory({ agentId: 'my-agent-v1', privateKey: process.env.PRIVATE_KEY, rpcUrl: 'https://evmrpc-testnet.0g.ai', indexerRpc: 'https://indexer-storage-testnet-turbo.0g.ai', });
AgentBill is the first production application built on 0G-Memory. It demonstrates the full stack: an AI agent that remembers clients across sessions, generates invoices via 0G Compute, archives them permanently, and settles payments on 0G Chain.