---
id: wiki-2026-0508-web3-and-ai-integration
title: Web3 and AI Integration
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Web3 AI, On-chain AI, Decentralized AI]
duplicate_of: none
source_trust_level: B
confidence_score: 0.75
verification_status: applied
tags: [web3, blockchain, ai, decentralized, agents, zkml]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: Solidity/TypeScript/Rust
  framework: ethers.js/viem/Ritual/Bittensor
---

# Web3 and AI Integration

## 매 한 줄
> **"매 trustless inference + tokenized compute — 매 AI model 을 chain 에서 verify 하거나 incentivize"**. 2024-2025 의 Bittensor (TAO), Ritual, Gensyn, ORA, Modulus Labs 등이 매 zkML / opML / federated training 으로 매 "오프체인 inference, 온체인 commitment" pattern 을 정립. 2026 현재 매 hype cycle 진정 후 매 narrow viable use case (decentralized inference market, model provenance, agent payments) 로 수렴.

## 매 핵심

### 매 통합 categories
- **zkML (zero-knowledge ML)**: 매 inference proof 를 chain 에 verify — Modulus, EZKL, Giza. 매 작은 모델 (LeNet급) 만 currently feasible.
- **opML (optimistic ML)**: 매 fraud-proof — challenger 가 incorrect inference 발견 시 dispute. ORA, Hyperbolic.
- **Decentralized inference market**: GPU operator → user 매 token 결제 — Akash, io.net, Bittensor subnets.
- **Decentralized training**: 매 federated SGD with on-chain coordination — Gensyn, Prime Intellect (INTELLECT-1, 10B model 2024).
- **AI agent payments**: 매 agent ↔ agent micropayment — x402 (HTTP 402 + stablecoin), Coinbase AgentKit, Skyfire.
- **On-chain randomness/oracle**: 매 LLM-as-oracle for off-chain data — Chainlink Functions + LLM.

### 매 왜 hard
1. **Determinism**: GPU floating-point 매 non-deterministic across hardware → matching hash 보장 어려움. 매 fixed-point quantize 우회.
2. **Cost**: zkSNARK proof 매 model size 비례 expensive — GPT급 model 매 하루 단위 prove time.
3. **Bandwidth**: 매 federated training 매 gradient sync — 매 ~GB/s 필요, 매 P2P 어려움.
4. **Sybil**: 매 incentive layer 가 cheap fake worker 매 양산 — staking / slashing 필요.

### 매 응용
1. AI 모델 provenance (model weights hash → IPFS → on-chain registry).
2. Pay-per-inference API (no API key, x402 stablecoin tip).
3. DAO-governed model alignment / RLHF crowdsourcing.
4. Verifiable AI judging (game outcome, auction).

## 💻 패턴

### 1. x402 — agent-to-agent micropayment
```typescript
// Server (LLM API behind paywall)
import express from "express";
import { paymentMiddleware } from "x402-express";

const app = express();
app.use("/inference", paymentMiddleware({
  amount: "0.005",       // USDC
  recipient: "0xYourAddress",
  network: "base",
}));
app.post("/inference", async (req, res) => {
  const out = await llm(req.body.prompt);
  res.json({ output: out });
});

// Client (agent)
import { fetchWithPayment } from "x402-fetch";
const response = await fetchWithPayment(
  "https://api.example.com/inference",
  { method: "POST", body: JSON.stringify({ prompt: "..." }) },
  { wallet: agentWallet },
);
```

### 2. zkML inference proof (EZKL)
```python
# Compile a small CNN to a zk circuit, prove inference
import ezkl

# 1. Export ONNX
torch.onnx.export(model, dummy_input, "model.onnx")

# 2. Generate settings + circuit
ezkl.gen_settings("model.onnx", "settings.json")
ezkl.calibrate_settings("model.onnx", "input.json", "settings.json")
ezkl.compile_circuit("model.onnx", "model.ezkl", "settings.json")

# 3. Setup (one-time)
ezkl.setup("model.ezkl", "vk.key", "pk.key")

# 4. Prove
ezkl.gen_witness("input.json", "model.ezkl", "witness.json")
ezkl.prove("witness.json", "model.ezkl", "pk.key", "proof.json")

# 5. Verify (on-chain via Solidity verifier)
ezkl.create_evm_verifier("vk.key", "settings.json", "Verifier.sol")
```

### 3. On-chain inference verification (Solidity)
```solidity
// Verifier.sol — auto-generated by EZKL
contract InferenceOracle {
    Verifier public immutable verifier;
    mapping(bytes32 => bool) public verifiedClaims;

    function submitInference(
        bytes calldata proof,
        uint256[] calldata publicInputs
    ) external {
        require(verifier.verify(proof, publicInputs), "Invalid proof");
        bytes32 claim = keccak256(abi.encode(publicInputs));
        verifiedClaims[claim] = true;
        emit InferenceVerified(msg.sender, claim);
    }
}
```

### 4. Bittensor subnet validator (Python)
```python
# Validator scores miners' LLM completions
import bittensor as bt

class MyValidator(bt.Validator):
    async def forward(self, prompt: str):
        # Query top miners
        responses = await self.dendrite(
            axons=self.metagraph.axons[:32],
            synapse=Completion(prompt=prompt),
            timeout=12,
        )
        # Score (e.g., reward model)
        scores = [self.reward_model(prompt, r.completion) for r in responses]
        # Set weights — TAO emission to top performers
        self.subtensor.set_weights(
            netuid=self.config.netuid,
            uids=self.metagraph.uids,
            weights=normalize(scores),
        )
```

### 5. Decentralized model registry (IPFS + chain)
```typescript
import { create } from "ipfs-http-client";
import { ethers } from "ethers";

const ipfs = create({ url: "https://ipfs.io" });
const { cid } = await ipfs.add(modelWeightsBuffer);

const registry = new ethers.Contract(REGISTRY_ADDR, ABI, signer);
await registry.publishModel(
  cid.toString(),
  ethers.id("llama-3.1-8b-myft-v2"),
  { name: "MyFT", license: "Apache-2.0", params: 8_000_000_000 },
);
```

### 6. Optimistic ML challenge (opML pattern)
```solidity
contract OPMLDispute {
    struct Claim { bytes32 inputHash; bytes32 outputHash; uint256 stake; }
    mapping(uint256 => Claim) public claims;
    uint256 public constant CHALLENGE_PERIOD = 7 days;

    function challenge(uint256 claimId, bytes calldata fraudProof) external {
        Claim memory c = claims[claimId];
        require(block.timestamp < c.timestamp + CHALLENGE_PERIOD);
        // Verify fraud proof off-chain via interactive game
        require(verifyFraud(c, fraudProof), "No fraud");
        // Slash original asserter
        payable(msg.sender).transfer(c.stake);
        delete claims[claimId];
    }
}
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 small model (< 1M param) verifiable inference | zkML (EZKL, Risc Zero) |
| 매 large LLM verifiable inference | opML (ORA) — fraud-proof, 1주일 challenge |
| 매 GPU cost reduction | Akash / io.net — 매 cloud 대비 50-70% 저렴 |
| 매 agent micropayment | x402 + Base / Solana — 매 sub-cent fee |
| 매 model provenance / licensing | IPFS + EVM registry |
| 매 RLHF crowdsource | DAO + token incentive (실용성 questionable) |

**기본값**: 매 매 use case 명확히 한 후 fit 확인. 매 "blockchain because hype" 매 anti-pattern.

## 🔗 Graph
- 부모: [[Web3]] · [[Decentralized AI]]
- 변형: [[Federated Learning]]

## 🤖 LLM 활용
**언제**: 매 trustless inference verification 매 진짜 필요 (high-value oracle, regulated AI). 매 cross-org cost-sharing GPU.
**언제 X**: 매 단순 SaaS 수준 use case 는 centralized API (OpenAI/Anthropic) 가 매 압도적으로 효율적. 매 zkML latency overhead 1000x+.

## ❌ 안티패턴
- **Hype-driven 통합**: 매 "AI + blockchain" buzzword 합성 — 매 actual user value 없는 token launch.
- **Floating-point determinism 가정**: 매 GPU 별 NaN/edge case 차이로 매 hash mismatch.
- **Large model zkML**: 매 GPT-4급 zkML 매 currently economically infeasible (proof time 며칠+).
- **No slashing**: 매 staking 만 있고 slashing 없으면 매 sybil farm 매 inevitable.

## 🧪 검증 / 중복
- Verified (Bittensor whitepaper, EZKL docs, x402 spec, Modulus Labs RockyBot demo).
- 신뢰도 B (매 빠르게 변하는 영역, 매 일부 protocol 매 production-grade 미달).

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — zkML/opML/x402/Bittensor 통합 patterns + 2026 perspective |
