Cookbook
End-to-end tutorials. Pick an archetype, follow it from npm create to a
running app, then graduate to production hardening. Every tutorial uses only
the published @foundryprotocol/0gkit-* packages — nothing fabricated, every
command verified.
These are deeper than the template READMEs — they walk you through why each piece exists, not just what the code does.
Tutorials
Chat app
A real-time chat where every message is persisted to 0G Storage and the
on-chain MessagePosted event log is the source of truth for the message
list. Teaches: SP3 wallet (server), SP4 typed contracts, SP6 indexer with
reorg-safe useEvent, SP3 storage upload + download.
Stack: Next.js 16 App Router · React 19 · 0gkit-storage ·
0gkit-indexer · 0gkit-react · 0gkit-contracts.
AI agent with TEE-attested inference
A LangChain-style ReAct agent where every step is paid through 0G
Compute, gated on a TEE attestation, and orchestrated as a durable job.
Survives worker crashes when you point the runner at sqlite or redis.
Teaches: Compute.inference, attestation envelopes, durable jobs, webhook
delivery, swappable backends.
Stack: 0gkit-compute · 0gkit-attestation · 0gkit-wallet ·
0gkit-jobs.
NFT minter with media + metadata on 0G Storage
Mint an ERC-721 token whose metadata JSON and media file both live
on 0G Storage. tokenURI resolves to 0g-storage://<root>. Teaches: SP4
Foundry codegen, two-step storage uploads with cross-referencing roots,
typed contract write.mint(...) calls, marketplace gateway design.
Stack: Foundry · 0gkit-storage · 0gkit-contracts · 0gkit-wallet.
What you need before starting
- Node 20.10+ (CI tests 20, 22, 24).
- A funded testnet key for
galileo— grab one fromfaucet.0g.ai. You never need real funds. - A terminal, an editor, and
npm(orpnpm/yarn/bun).
The AI-agent tutorial additionally needs a 0G Compute prepaid balance; the NFT tutorial additionally needs Foundry installed. Each tutorial spells these out at the top.
How these are structured
Every tutorial follows the same shape:
- What you're building — a screenshot or sample output of the end state.
- Prerequisites — exact versions and key requirements.
- Scaffold — one
npm create 0gkit-appcommand. - Walk the code, file-by-file — every line you'll touch, with the "why" inline.
- Run it — copy/paste commands; you should see the live thing.
- Extend it — one or two real upgrades, not toy modifications.
- Production hardening — the gap between "works on my laptop" and "won't page you at 3 AM".
Something missing?
If you want a tutorial for a workflow we haven't covered (e.g. a fully on-chain marketplace, a TEE-enclaved fine-tuning loop, a multi-tenant storage SaaS), open a discussion at github.com/rajkaria/0gkit/discussions.