Decentralized Agent Memory

0G-Memory

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.

Try AgentBillArchitectureSDK Docs
KV
Fast agent context reads
Log
Immutable invoice archive
Chain
0G Chain escrow settlement
Memory Architecture
Verifiable
Root hash proof
Decentralized
0G Network
Drop-in SDK
Three methods
01

The Decentralized Memory Architecture

Why not a database?

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.

0G-Memory writes every agent memory to 0G Storage — a decentralized storage network. Each write returns a Merkle root hash. The hash is your cryptographic proof: anyone can verify the data on StorageScan, forever.

Traditional Agent Memory vs 0G-Memory

Capability
Traditional (DB/File)
0G-Memory
Persistent across sessions
(if DB is up)
Always
Cryptographically verifiable
No proof
Root hash
Decentralized storage
Central DB
0G Network
Tamper-proof archive
No
Log layer
Vendor lock-in
High
None
On-chain settlement
No
0G Chain
StorageScan proof link
No
Yes

Memory Layers

Layer 01 — Fast Reads

KV Stream

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.

Layer 02 — Immutable

Storage Log

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.

Layer 03 — Settlement

0G Chain

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.

02

How it Works

01
Agent calls remember()
KV write + Log archive
02
Root hash returned
0G Storage anchors the data
03
Any session calls recall()
Data retrieved from 0G network
04
On-chain settlement
AgentPayment escrow on 0G Chain
Agent
calls remember()
0G Storage
KV + Log write
0G Chain
registerInvoice()
StorageScan
verifiable proof
03

SDK Reference

Three methods. Complete memory.

The entire 0G-Memory API surface is three async methods. Initialize once with your 0G credentials, then drop it anywhere in your agent pipeline.

remember(key, value)

Write to KV stream + Log layer. Returns root hash.

recall(key)

Retrieve from 0G Storage via root hash. Returns value or null.

archive({ type, data })

Append-only log write. Returns rootHash + StorageScan URL.

Works with any LLM framework. Initialize with your 0G credentials once — the same instance is reused across the agent's lifetime via a singleton pattern.
remember()
recall()
archive()
// 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
Install
npm install 0g-memory-sdk
npmjs.com/package/0g-memory-sdk
Initialization
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',
});
04

Built with 0G-Memory: AgentBill

Autonomous Invoice Agent

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.

The key demonstration: generate an invoice for a client, then generate a second one for the same client. The agent surfaces their full history — total invoiced, past jobs, invoice IDs — retrieved from 0G Storage, not a database.
Try AgentBill Demo
0G-Memory
Client history recalled across sessions from 0G Storage. Returning clients are surfaced automatically.
0G Compute
Qwen inference via 0G Compute Router with TEE verification. Structured invoice generation from natural language.
0G Storage
Every invoice archived permanently to 0G Storage Log layer. Root hash returned as cryptographic proof.
0G Chain
Payment escrow via AgentPayment.sol on 0G Chain (chainId 16602). ChainScan link on every invoice.