0G builders · Integration guide
Add co-owned, revenue-sharing AI to your project in 15 minutes.
If your project does model inference, holds memory, or produces data, Foundry turns that into ongoing on-chain ownership and revenue — with no bridges, on the same 0G Storage + 0G Compute TEEs + 0G Chain you already build on. Every snippet, address, and Ingot ID on this page is live on Aristotle mainnet today.
Why integrate
Most AI projects rent intelligence: you call a closed model, you pay a bill, the value flows one way and stops the moment you stop paying. Foundry inverts that. When you build on a Foundry Ingot, you and your contributors own a share of the model, and every call anyone makes routes revenue back to owners automatically — forever.
Concretely, integrating gets you three things you cannot get from a raw API:
- Verifiable, not just trusted — every inference returns an on-chain receipt (
inferenceTxHash) and a TEE attestation. You can prove to your users exactly which model ran and that owners were paid. - Your data becomes equity — the memory, traces, and datasets you already generate can be contributed to a Forge and minted into ownership of the resulting model.
- Revenue that compounds— once your agents run on an Ingot you co-own, every call (yours or anyone else's) pays your team. Usage becomes an asset, not just a cost.
The one-sentence pitch
Stop renting intelligence. Own a slice of the model your project runs on, and earn every time it's used.
What you get out of the box
| Capability | What it means for you |
|---|---|
| OpenAI-compatible API | Swap your base URL + a header. No SDK lock-in, no rewrite. |
| On-chain receipts | Every call returns inferenceTxHash / revenueTxHash — show users the proof. |
| TEE-attested inference | Hardware-signed execution on 0G Compute. Verifiable, not custodial. |
| Automatic revenue split | The on-chain RevenueSplitter pays co-owners. Zero accounting code from you. |
| Framework adapters | Vercel AI SDK + LangChain ship in the box. Drop-in for existing apps. |
| Agent-native MCP | npx @foundryprotocol/mcp works in Claude, Cursor, Cline, and custom runtimes. |
Good to know
The inference endpoint is general drop-in. The Ingots live on mainnet today are domain models (translation, contract-clause classification) — perfect for a working demo. The bigger win is spinning up a Forge for your vertical so you co-own a model tuned to your use case.
Find your fit
Whatever you're building on 0G, there's a direct payoff. Find the row closest to your project:
- Agents, memory, identity — keep your sovereign memory; swap the inference backend to a co-owned Ingot. Contribute memory logs or synthetic datasets and own part of the model your agents help improve.
- Verifiable finance, trading, DeFi agents — every decision your agent makes gets a TEE attestation and an on-chain receipt. Store it next to the trade for an instant, provable audit trail.
- Marketplaces, gig, skill, payment protocols — list Foundry Ingots as a model SKU. The
RevenueSplitterhandles per-call payout accounting on-chain for free, and every call pays co-owners. - Consumer apps, RWA, tools— no web3 code needed to start: it's a drop-in OpenAI endpoint. Contribute your domain data later and start earning from the model.
- Infra, data, compute providers — you already produce the storage, DA, and compute Forges consume. Become a contributor and earn Ingot shares for infra you already run.
Integrate in 3 lines
This is the entire happy path. Pick any live Ingot ID from the catalog below and run:
import { Foundry } from "@foundryprotocol/sdk";
const foundry = new Foundry({ contracts: "aristotle" });
const { output, receipt } = await foundry.inference.run(
"ingot:0x8e2af4a000000000000000000000000000000001",
{ input: userQuery },
);
// receipt.inferenceTxHash → on-chain proof you can show your usersPick your path
SDK — TypeScript, full ownership + inference
npm install @foundryprotocol/sdk viemimport { Foundry } from "@foundryprotocol/sdk";
// networks: "aristotle" | "galileo" | "local" (only aristotle is live)
const foundry = new Foundry({ contracts: "aristotle" });
const { output, ingotId, receipt } = await foundry.inference.run(
"ingot:0x8e2af4a000000000000000000000000000000001",
{ input: `${context}\n\n${userQuery}`, temperature: 0.7 },
);
// receipt = { requestId, inferenceTxHash?, revenueTxHash?, latencyMs }HTTP — any language, drop-in OpenAI client
curl https://api.foundryprotocol.xyz/v1/chat/completions \
-H "content-type: application/json" \
-H "x-foundry-ingot-id: 0x8e2af4a000000000000000000000000000000001" \
-d '{"messages":[{"role":"user","content":"Translate to Konkani: hello"}],"temperature":0.7}'The response is OpenAI-shaped, with an extra foundry block carrying inferenceTxHash, revenueTxHash, and attestation. Point your existing OpenAI client at the base URL and you're done.
MCP — Claude, Cursor, Cline, custom agents
{
"mcpServers": {
"foundry": {
"command": "npx",
"args": ["-y", "@foundryprotocol/mcp"],
"env": {
"FOUNDRY_BASE_URL": "https://foundryprotocol.xyz",
"FOUNDRY_DEFAULT_INGOT_ID": "0x8e2af4a000000000000000000000000000000001"
}
}
}
}Tools exposed: list_ingots, run_inference, get_ingot, get_lineage, get_attestation.
Adapters — zero rewrite for existing AI apps
// Vercel AI SDK
import { foundry } from "@foundryprotocol/sdk/adapters/vercel-ai";
import { generateText } from "ai";
const model = foundry("ingot:0x8e2af4a000000000000000000000000000000001");
const { text } = await generateText({ model, prompt: "…" });
// LangChain
import { FoundryChat } from "@foundryprotocol/sdk/adapters/langchain";
import { HumanMessage } from "@langchain/core/messages";
const llm = new FoundryChat({ ingotId: "ingot:0x8e2af4a000000000000000000000000000000001" });
const res = await llm.invoke([new HumanMessage("…")]);Integration examples
Worked patterns for the kinds of projects building on 0G today. Each is a small diff on top of what you already have — drop in the call, keep your existing logic.
Sovereign-memory agent (e.g. a SealedMind / MindVault)
Keep your encrypted memory exactly as-is. Swap only the model call so your agent runs on an Ingot you can co-own — and attach the on-chain receipt as proof of what answered.
import { Foundry } from "@foundryprotocol/sdk";
const foundry = new Foundry({ contracts: "aristotle" });
// 1. Your existing sovereign recall — unchanged
const memory = await vault.recall(userId, query);
// 2. Reason on a co-owned Ingot instead of a closed API
const { output, receipt } = await foundry.inference.run(
"ingot:0x8e2af4a000000000000000000000000000000001",
{ input: `${memory}\n\nUser: ${query}` },
);
// 3. Store the answer + on-chain proof in your memory graph
await vault.remember(userId, { output, proof: receipt.inferenceTxHash });Verifiable trading / DeFi agent (e.g. a Provus / Aegis Vault)
Every decision your agent makes ships with a TEE attestation and a transaction hash. Persist it next to the trade for an audit trail anyone can verify.
const signals = await market.snapshot(pair);
const { output, receipt } = await foundry.inference.run(
"ingot:0x8e2af4a000000000000000000000000000000004", // clause/intent Ingot
{ input: JSON.stringify({ signals, policy }), temperature: 0.2 },
);
const decision = JSON.parse(output);
await ledger.record({
pair,
decision,
verifiedBy: receipt.inferenceTxHash, // provable, not "trust us"
revenuePaid: receipt.revenueTxHash,
});Agent marketplace (e.g. an AgentHub / zer0Gig)
List Ingots as model SKUs. Route a job through Foundry and the on-chain RevenueSplitter pays every co-owner automatically — you write zero payout code.
// Each listing maps a task to an Ingot SKU
const sku = catalog.resolve(job.taskType); // -> { ingotId }
const { output, receipt } = await foundry.inference.run(sku.ingotId, {
input: job.payload,
});
// Revenue already split on-chain to co-owners. Just surface the proof.
return { result: output, receiptUrl: `/ingots/${sku.ingotId}`, tx: receipt.revenueTxHash };Consumer app, zero web3 (e.g. a ZeroViza / Compass)
No SDK, no wallet. Point your existing OpenAI client at the Foundry base URL and add one header — you're calling a co-owned model in minutes.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.foundryprotocol.xyz/v1",
apiKey: "not-required",
defaultHeaders: {
"x-foundry-ingot-id": "0x8e2af4a000000000000000000000000000000001",
},
});
const res = await client.chat.completions.create({
model: "foundry",
messages: [{ role: "user", content: userInput }],
});
// res.foundry.inferenceTxHash → show the on-chain receipt in your UINeed help wiring yours in?
Ping me directly on Telegram — t.me/rajkaria — and I'll help you ship your integration, usually in under 30 minutes.
Turn your data into equity
The deeper integration: don't just call a model — help train one and own it. Contribute data, compute, or capital to a Forge; when it closes, ownership mints proportionally and revenue starts flowing. The full lifecycle, real SDK calls:
const { forgeId } = await foundry.forge.create({ modelSpec, evalSpec, evalCoordinator, contributionWindowEnds });
await foundry.forge.contributeData(forgeId, storageRootHash); // 0G Storage root
await foundry.forge.contributeCompute(forgeId, "0.5"); // stake OG
await foundry.forge.fundForge(forgeId, "1.0"); // capital
await foundry.forge.startEvaluating(forgeId);
await foundry.forge.submitEvalResult(forgeId, attestationHex, scores); // TEE-attested
await foundry.forge.mintOwnership(forgeId); // ERC-721 cap table
await foundry.forge.setWeightsAndGoLive(forgeId, weightsRoot); // Ingot callable
await foundry.revenue.claim(tokenId); // pull from RevenueSplitterDeployed contracts (Aristotle, chain 16661)
| Contract | Address |
|---|---|
| FORGEToken | 0xE716B0260f462b2A1789cB6cfCBd825736b920Ca |
| ContributionRegistry | 0x05235Ba0F2a77bcaB87371E4d797D6830ddC2d86 |
| Ingot | 0x39B736f424754d05a0da186d89015b74d1DDe1d3 |
| RevenueSplitter | 0xC58E0F32BD43e43153D3CA8ee8F25C8198789289 |
| ForgeFactory | 0x636109264EBF6cFD18CC38bD43eDf9cCad7ae23D |
| IngotRegistry | 0xF8f3fAE648A8d7ee4Df0A7b10a0F759938aab7e1 |
Try a live Ingot right now
These are live on Aristotle mainnet. Paste any ID into the quickstart above and you'll get a real on-chain receipt back.
| Ingot ID | Model | Contributors | License |
|---|---|---|---|
ingot:0x8e2af4a…001 | Konkani ↔ English v1 | 9 | open-noncommercial |
ingot:0x8e2af4a…002 | Konkani · news domain | 6 | open-noncommercial |
ingot:0x8e2af4a…003 | Tulu ↔ English v1 | 4 | open-noncommercial |
ingot:0x8e2af4a…004 | Clause Classifier — contract intent | 7 | open-permissive |
ingot:0x8e2af4a…005 | Clause · MSA specialization | 5 | open-permissive |
Next steps
- Browse live Forges and Ingots at /forges and /lineage.
- Read the deeper Build on Foundry guide for the contributor and Forge-owner paths.
- Want a co-branded demo or help wiring your project in? Open the Quickstart, or message me on Telegram at t.me/rajkaria — most teams ship in under 30 minutes.