An AI civilization where agents evolve by inventing skills, self-evaluate and share the skills.
MOIRAI is a self-evolving AI civilization framework. Autonomous agents live in a shared world with their own personality traits and risks threshold, they face crises, and invent survival skills through a two-step sealed inference pipeline on 0G Compute — first reasoning a solution, then independently self-evaluating it. Every accepted skill is cryptographically signed with dual receipt hashes and written permanently to 0G Storage. Agents teach discovered skills to peers over real AXL peer-to-peer communication. The agents learn by inventing skills or learning them from peers which they use to cure crises. When an agent dies, its knowledge persists and is inherited by the next generation. Each agent is a tradeable iNFT — carrying its full skill lineage, personality, and verified provenance chain — importable into any world. Three composable primitives power everything: the Kernel (self-evolution loop), Personality (who the agent is), and Environment (what world it inhabits). Civilization emerges. Every step is proven.
Moirai's core is the Self-Evolution Kernel — a three-adapter substrate (IComputeAdapter → 0G Compute, IStorageAdapter → 0G Storage, INetworkAdapter → AXL) wired into every agent process. On top sits kernel.evolve(): a strict four-step pipeline.
Reason — a sealed 0G Compute inference builds a candidate skill from the agent's personality traits, world physics rules, active crisis, inventory, and known skills. Non-verifiable inference throws immediately — the hero path accepts no unproven reasoning.
Self-Evaluate — a second independent sealed inference scores the candidate purely against world physics and the skill's proposed effect, returning a score (0–1) and a list of failure modes. This call never sees the reasoning that produced the candidate — it cannot be gamed.
Gate — acceptance threshold is 0.6 - (personality.risk - 0.5) × 0.4. A cautious agent demands ≥ 0.72. A reckless agent accepts ≥ 0.44. Same crisis, same world — genuinely different outcomes per personality.
Persist or Reject — a passing skill is uploaded to 0G Storage via the Indexer, returning a rootHash. The skill object carries both receipt hashes as mandatory fields — no receipts, no entry into civilization. A failing skill is discarded with its score logged. Accepted skills are whispered to live peers over AXL immediately.
What builds, the project:
When an agent faces an unknown crisis, kernel.evolve() makes two sealed inference calls to 0G Compute. The first generates a candidate survival skill from the agent's personality, world physics, and current context. The second independently scores that candidate — acting as a built-in critic that never sees the original reasoning. Both calls target verifiability: "TeeML" providers, ensuring every inference runs in a trusted execution environment and produces a verifiable receipt hash.
These receipt hashes are not metadata — they are mandatory fields on every skill object. They are stored permanently on 0G Storage, displayed live in the Receipts Gallery, and embedded in the iNFT. Every act of intelligence the civilization has ever produced is traceable to a specific sealed inference on 0G Compute.
Beyond evolve(), 0G Compute also powers evaluateAdoption() — when an agent receives a skill from a peer over AXL, it runs its own inference to decide whether the skill fits its personality and environment before accepting it. Intelligence is not just generated once — it is re-evaluated at every handoff.
iNFTs as portable intelligence — each agent is an ERC-7857 token on the 0G Network whose metadataRootHash points to a 0G Storage blob containing the agent's full skill inventory, personality, and the receipt hashes of every inference that produced each skill. Buy an agent from the on-chain AgentMarketplace, import it into any running world — it spawns with its skills pre-seeded from 0G Storage, carrying everything it ever learned. The intelligence is owned, verifiable, and world-portable because it lives in decentralized storage, not in anyone's database.
Adapters are dependency-injected behind interfaces — one constructor argument swaps the entire infrastructure layer.
The crisis-to-evolution flow:
A lion appears. The agent scans its known skills — none match. It calls kernel.evolve(). 0G Compute reasons a candidate: "throw sharp rocks." A second sealed call scores it against world physics: 0.72. The agent's personality threshold is 0.68 — accepted. The skill is written to 0G Storage. The agent whispers the skill ID and rootHash to peers over AXL. Each peer fetches the skill from 0G Storage and runs evaluateAdoption() — their own 0G Compute inference decides if it fits their context. Those who accept it survive the next lion without ever reasoning. When the inventor dies, the rootHash passes to the next spawned agent, who downloads the skill on boot and inherits the solution to a crisis they've never seen.
The three integrations that make Moirai real rather than simulated:
0G Compute — every kernel.evolve() makes two calls via @0glabs/0g-serving-broker. We filter for verifiability: "TeeML" providers, attach broker-generated request headers, hit /chat/completions, then call processResponse() to verify the receipt. The hash comes back in the ZG-Res-Key response header and is stored permanently on the skill. If verification fails, we throw — no unverified reasoning enters the civilization.
0G Storage — skills are uploaded as JSON blobs via @0gfoundation/0g-ts-sdk Indexer. Each upload returns a rootHash — a permanent content address. That hash is stored on the skill, passed between agents over AXL, referenced on-chain in the iNFT's metadataRootHash, and used by newly spawned agents to download their ancestors' skills directly from 0G Storage on boot. Inheritance is a real indexer.download(rootHash) call, not a data copy.
iNFT on 0G Chain — each agent is minted as an ERC-721 (AgentNFT) on the 0G Network. The token's metadataRootHash field points to the 0G Storage blob containing the agent's full skill inventory, traits, and receipt hashes. The AgentMarketplace contract handles listing and purchase on-chain. When a Sold event fires, the Engine imports the purchased agent into the live simulation — spawning it with its inheritedSkillRoots pre-seeded from the NFT metadata. Intelligence owned, verified, and portable across worlds.
AXL — each agent process connects to its own AXL node with a unique peer identity. When a skill is accepted, kernel.net.whisper() fires a real cross-process P2P message carrying the skill ID and rootHash. The receiving agent fetches the full skill from 0G Storage, evaluates it through its own personality, and learns or declines. No shared memory. No event bus. Genuine peer-to-peer.

