Building a Decentralized AI Platform with Verifiable Inference

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1All 1305 services
Building a Decentralized AI Platform with Verifiable Inference
Complex
from 2 weeks to 3 months
Frequently Asked Questions

Blockchain Development Services

Blockchain Development Stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1250
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_logo-advance_0.webp
    B2B Advance company logo design
    646
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929

GPU computing is concentrated among cloud giants—AWS, GCP, Azure. Model inference is dominated by OpenAI, Anthropic, Google. This creates risks of vendor lock-in, price dictation, and censorship. Decentralized AI platforms offer an alternative: a marketplace for computing resources, models, and data on the blockchain. But the key technical challenge is how to verify AI computation results without trusting the provider. A smart contract cannot run a neural network: the EVM is deterministic, while neural networks use floating point and GPUs. This fundamental contradiction defines the entire platform architecture.

In this article, we break down the main verification approaches (optimistic, ZK, TEE), the architecture of a decentralized marketplace, tokenomics, and the development process. You'll learn how to design a platform that solves real problems of AI centralization, and what trade-offs are inevitable. Our team has over 10 years of blockchain development experience and 50+ delivered projects in DeFi, NFT, and AI.

How to Verify AI Computations in a Decentralized Network?

Optimistic Verification

Model similar to Optimistic Rollups: assume the provider is honest. The result is accepted without verification, but there is a dispute window. A challenger can dispute the result by presenting an alternative computation. When disputed, on-chain arbitration or a verifier committee is invoked.

Application: Bittensor uses a network of validators that evaluate output quality through a similarity measure. This is not cryptographically strict, but sufficiently robust against random providers.

Dispute mechanism implementation:

contract OptimisticAIVerifier {
    struct Task {
        bytes32 requestHash;
        bytes32 responseHash;
        address provider;
        uint256 stake;
        uint256 deadline;        // when it can be finalized
        bool disputed;
        bool finalized;
    }
    
    mapping(bytes32 => Task) public tasks;
    uint256 public constant DISPUTE_WINDOW = 7200; // ~24 hours on Ethereum
    
    function submitResult(bytes32 taskId, bytes32 responseHash) external {
        Task storage task = tasks[taskId];
        require(msg.sender == task.provider, "Not provider");
        task.responseHash = responseHash;
        task.deadline = block.number + DISPUTE_WINDOW;
    }
    
    function dispute(bytes32 taskId, bytes calldata alternativeResponse) external {
        Task storage task = tasks[taskId];
        require(block.number < task.deadline, "Dispute window closed");
        // Send to arbitration — committee or on-chain verification
        _initiateArbitration(taskId, alternativeResponse);
    }
    
    function finalize(bytes32 taskId) external {
        Task storage task = tasks[taskId];
        require(block.number >= task.deadline, "Still in dispute window");
        require(!task.disputed, "Under dispute");
        require(!task.finalized, "Already finalized");
        task.finalized = true;
        // Release provider's stake, pay for task
        _releasePayment(task.provider, task.stake);
    }
}

Problem: for complex models, there is no simple way to verify an alternative result on-chain. Arbitration via a committee introduces a new centralization vector.

ZK Verification of Inference

ZK verification is a mathematically rigorous approach: prove in zero-knowledge that the model with weights W on input X produced output Y, without revealing computation details. This allows verifying inference on-chain or through a public verifier.

Projects: Gensyn (own consensus for ML), EZKL (ZK proofs for ONNX models), Risc Zero (general purpose ZK-VM).

EZKL generates a ZK circuit from an ONNX model and proves correctness of the forward pass:

import ezkl
import torch
import onnx

# Export model to ONNX
model = MyMLModel()
dummy_input = torch.randn(1, 128)
torch.onnx.export(model, dummy_input, "model.onnx")

# Generate proof
ezkl.gen_settings("model.onnx", "settings.json")
ezkl.calibrate_settings("input.json", "model.onnx", "settings.json")
ezkl.compile_circuit("model.onnx", "compiled_model", "settings.json")
ezkl.gen_pk("compiled_model", "pk.key", "settings.json")
ezkl.gen_vk("compiled_model", "vk.key", "settings.json")
ezkl.prove("input.json", "witness.json", "compiled_model", "pk.key", "proof.json")
ezkl.verify("proof.json", "settings.json", "vk.key")  # can be done on-chain

Limitations: ZK-proof generation for GPT-2 (117M parameters) takes hours on powerful hardware. For production models like LLaMA-3, this is not yet practical. Applicable for small specialized models: classifiers, embeddings, small transformers.

Trusted Execution Environments (TEE)

TEE, such as Intel SGX, AMD SEV, AWS Nitro Enclaves, are hardware-isolated environments where code executes inside a secure enclave. Attestation is a mechanism that allows remote verification that specific code runs in a TEE.

Ritual Network uses TEE for inference verification. The provider runs the model in an enclave, which generates an attestation report verified on-chain.

Trade-off: requires trust in the CPU manufacturer (Intel, AMD). This is not "trustless", but significantly reduces attack surface compared to "trust the provider unconditionally".

Method Security Performance Applicability
Optimistic Medium (depends on dispute window) High (no overhead) MVP, small models
ZK-proof High (cryptographic guarantee) Low (hours for proof generation) Small specialized models
TEE Medium (trust in CPU manufacturer) Medium (enclave overhead) Production, medium models

Architecture of a Decentralized AI Marketplace

Model and Provider Registry

Registry contract — a registry of providers and models:

contract ModelRegistry {
    struct Model {
        address provider;
        bytes32 modelHash;        // IPFS CID or weights hash
        string endpoint;          // where the model is hosted
        uint256 pricePerToken;    // price per 1k tokens in wei
        uint256 stake;            // provider's stake (skin in the game)
        uint256 reputationScore;
        bool active;
    }
    
    mapping(bytes32 => Model) public models;
    
    function registerModel(
        bytes32 modelId,
        bytes32 modelHash,
        string calldata endpoint,
        uint256 pricePerToken
    ) external payable {
        require(msg.value >= MIN_STAKE, "Insufficient stake");
        models[modelId] = Model({
            provider: msg.sender,
            modelHash: modelHash,
            endpoint: endpoint,
            pricePerToken: pricePerToken,
            stake: msg.value,
            reputationScore: 0,
            active: true
        });
    }
}

Task Router — an off-chain service that routes requests to providers based on criteria: price, latency, reputation, model specialization.

Payment Channel — for inference micropayments, it is better to use payment channels (State Channel or zkSync-style) rather than an on-chain transaction per request. A typical inference request costs fractions of a cent—on-chain gas would kill it.

// Simplified unidirectional payment channel
contract InferenceChannel {
    address public user;
    address public provider;
    uint256 public expiry;
    
    // User signs vouchers off-chain
    // Provider closes the channel with the last signed voucher
    function close(
        uint256 amount,
        bytes calldata userSignature
    ) external {
        require(msg.sender == provider, "Only provider");
        bytes32 message = keccak256(abi.encodePacked(address(this), amount));
        address signer = ECDSA.recover(message.toEthSignedMessageHash(), userSignature);
        require(signer == user, "Invalid signature");
        
        payable(provider).transfer(amount);
        payable(user).transfer(address(this).balance);
    }
}

Platform Tokenomics

A two-sided market requires balanced tokenomics:

Utility token functions:

  • Pay for inference (or ETH/USDC—depending on audience)
  • Staking for providers (skin in the game, slashing for fraud)
  • Governance (protocol parameters)
  • Reward for providing compute

Problem of inflationary rewards: if providers are rewarded with tokens, inflation dilutes value. Bittensor addresses this through emission tied to real utility (output quality). The better the validators' evaluations, the more TAO.

Emission curve: for a new platform, a deflationary design with buyback/burn from protocol revenue is more sustainable long-term than inflationary subsidies.

Data Marketplace: Monetizing Training Data

A separate but related vertical: data providers want to monetize datasets for model fine-tuning without revealing the data itself.

Federated Learning on Blockchain

The model is trained distributedly: each participant trains on their own data, sends only gradients (not data). Gradients are aggregated (Federated Averaging), improving the model without centralizing data.

The blockchain records each participant's contribution (via gradient hash), and a smart contract distributes rewards proportionally to contribution.

Problem: gradients can be inverted to reconstruct part of the training data (gradient inversion attacks). For sensitive data, Differential Privacy (adding noise to gradients) is additionally needed.

Compute-to-Data (Ocean Protocol approach)

Data remains with the owner, the algorithm "comes" to the data. A smart contract records access conditions, computation occurs in TEE, and the result (trained model or analytics) is the only thing that exits.

What Is Included in the Work

  • Requirements audit and platform architecture design
  • Development of smart contracts in Solidity 0.8.x using Foundry and OpenZeppelin
  • Integration with ZK tools (EZKL, Risc Zero) or TEE (Intel SGX, AWS Nitro)
  • Deployment on chosen network (Ethereum, Arbitrum, Base, or app-chain)
  • API and smart contract documentation
  • Training of the client's team on platform operation
  • Technical support for 3 months

Development Process and Timelines

  1. Analysis and design (2–4 weeks): requirements definition, stack selection, architecture.
  2. MVP development (3–4 months): centralized registry, optimistic verification, ERC-20 payments, basic provider SDK.
  3. Production v1 (6–9 months): payment channels, reputation system, dispute resolution, ZK verification for small models, governance token.
  4. Scaling (12+ months): custom app-chain or L2, TEE integration, federated learning, cross-chain operations.

Using decentralized computing reduces infrastructure costs by up to 70%. Gas savings when using L2 are about 90%.

Why the Choice of Deployment Network Matters

Criterion Ethereum mainnet Arbitrum/Base App-chain (Cosmos/OP Stack)
Trust High Medium Low (sovereign)
Gas High Low Minimal (own)
Throughput ~15 tx/s ~1000 tx/s Customizable
When to choose Governance, registry Payment, routing >100k tx/day, special requirements

Development Stack

Component Technology
Smart contracts Solidity 0.8.x + Foundry + OpenZeppelin 5.x
ZK verification EZKL / Risc Zero / Noir
TEE integration Intel SGX + Gramine or AWS Nitro
Off-chain services Go or Rust (high concurrency)
Model registry IPFS + on-chain hash
Payment channels State channels or Arbitrum/zkSync
Monitoring Prometheus + Grafana + on-chain events

Key limitation: ZK verification of large models is not yet production-ready. Realistically, optimistic verification with TEE as an intermediate step, with ZK added as infrastructure matures (Gensyn, Risc Zero).

Contact us to evaluate your project and get a detailed development plan. Order turnkey development with a guaranteed result.

Blockchain Infrastructure Deployment: Nodes, RPC, Indexing

Subgraph fell at 3:47 AM. By morning users saw outdated balances, transactions "hung" in the UI, support received 47 tickets in an hour. Cause: the handler in the subgraph failed on a transaction with a non-standard event log — and the entire index stopped. We have encountered such situations dozens of times. Our experience shows: blockchain infrastructure does not forgive gaps in observability. Guaranteeing uptime without multi-layered monitoring and fault-tolerant architecture is impossible. Over 8 years working with Ethereum, Polygon, and Solana, we have developed an approach that allows predictable deployment of infrastructure of any scale — from a single node to a multichain grid with dozens of subgraphs.

RPC Layer Architecture

Every dApp interaction with the blockchain goes through RPC — the JSON-RPC API provided by a node. Three options:

Managed providers — Alchemy, QuickNode, Infura, Ankr. Minimal operational costs, SLA, built-in monitoring. Limits: rate limits (Alchemy Free: 300 RU/sec), vendor lock, potential downtime during provider incidents. For most projects — the right choice at the start.

Self-owned nodes — full control, no rate limits, no third-party dependence. Cost: archive Ethereum node requires 2.5–3TB SSD, a strong server, and DevOps support. Sync from scratch on Ethereum via Geth/Nethermind — 3–7 days. Justified under high load or latency requirements.

Hybrid — self-owned node as primary, managed provider as fallback. Standard for protocols with high TVL. Proper load balancing can reduce costs by 20–30% compared to pure managed setup. Under high monthly request volume, hybrid saves significantly.

Provider Strength Limitation
Alchemy Supernode, Enhanced APIs, webhooks Expensive on high-volume
QuickNode Low latency, multi-chain More expensive than Alchemy on basic plan
Infura Historical reliability Rate limits on free, one major incident halted half of DeFi
Ankr Cheap, 40+ chains Less stable

How to Set Up an RPC Layer Without a Single Point of Failure?

At least two providers, DNS round-robin with health check every 5 seconds, automatic fallback when latency >500 ms. In practice, this gives 99.99% availability during any provider failure. For protocols with high TVL, we recommend a custom HA-proxy (nginx or Envoy) in front of two managed providers.

Why Is a Hybrid RPC Scheme More Cost-Effective Than Pure Managed?

At high request volumes, managed providers can be very expensive; a hybrid using a self-owned node as primary and a managed fallback cuts costs significantly without losing SLA.

Ethereum Node Clients

Execution clients: Geth (most used), Nethermind (C#, fast sync), Besu (Java, enterprise), Erigon (fastest sync, efficient archive mode ~2TB instead of 3TB).

Consensus clients (post-Merge): Lighthouse (Rust), Prysm (Go), Teku (Java), Nimbus (Nim). Each node after The Merge requires a pair of execution + consensus clients.

For DevOps: eth-docker — Docker Compose configurations for all client combinations. Setting up monitoring via Grafana + Prometheus is mandatory; a standard dashboard is available in each client's repository.

The Graph: Event Indexing

The Graph Protocol — decentralized indexing. A subgraph describes which events from which contracts to index and how to transform them into a GraphQL schema.

Subgraph structure:

  • subgraph.yaml — manifest: contract addresses, startBlock, events to handle
  • schema.graphql — GraphQL schema of entities
  • src/mapping.ts — AssemblyScript event handlers
dataSources:
  - kind: ethereum
    name: UniswapV3Pool
    network: mainnet
    source:
      address: "0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640"
      abi: UniswapV3Pool
      startBlock: 12370624
    mapping:
      eventHandlers:
        - event: Swap(indexed address,indexed address,int256,int256,uint160,uint128,int24)
          handler: handleSwap

AssemblyScript handlers — not TypeScript. No nullable types, no closures, no many standard APIs. An error in the handler stops the subgraph indexing on that transaction. Important: add try-catch for operations that can fail (e.g., store.get() for an entity that may not exist).

How to Avoid Subgraph Indexing Stops?

Graph Node logs are monitored in real-time; on hasIndexingErrors = true an alert fires and an automatic node restart (via systemd or Kubernetes). Typical downtime on error — 150–300 seconds to recover. Additionally, for production we set up a watchdog that restarts Graph Node if subgraph lag exceeds 50 blocks.

Choosing Between Hosted Service and Decentralized Network

Graph Hosted Service (free, centralized) is deprecated in favor of Subgraph Studio + Graph Network. For production: deploy on Graph Network with GRT curation signal — the subgraph gets indexers proportional to curation.

Alternatives to The Graph: Ponder (TypeScript, self-hosted, easier to debug), Envio (ultra-fast indexer, supports EVM + non-EVM), Subsquid (TypeScript, own network), Moralis Streams (managed, webhook-based). Our experience shows: for high-load projects with unique logic, Ponder or Envio are more effective — they give full control over the process and do not require GRT tokenomics.

Webhooks and Real-Time Notifications

Alchemy Webhooks and QuickNode Streams allow receiving events in real-time via HTTP webhook or WebSocket. For monitoring addresses, new transactions, mints — this is faster than polling RPC.

Tenderly — platform for monitoring and alerts. You can set up an alert for a specific contract event, balance change, function call with certain parameters. Transaction simulation via Tenderly API is invaluable for debugging.

Monitoring and Observability

Minimum monitoring stack for a protocol:

On-chain: OpenZeppelin Defender Sentinel — watches contract events, triggers webhook or Autotask when conditions are met. Forta Network — community-maintained bots detect anomalies (large withdrawals, flash loans, governance attacks).

Infrastructure: Grafana + Prometheus for nodes, Datadog or Grafana Cloud for managed metrics. Alerts on: node is 10+ blocks behind, RPC latency >500ms, subgraph lag >100 blocks.

Uptime: Better Uptime or PagerDuty on RPC endpoint and subgraph health endpoint (The Graph provides _meta { hasIndexingErrors, block { number } }).

Why Is Monitoring Without Tenderly Insufficient?

Tenderly provides transaction simulation and detailed traces — critical for debugging subgraph and smart contract errors. Forta focuses on network anomalies, not your infrastructure. The combination of Tenderly plus a custom Grafana dashboard covers 90% of incident scenarios.

Multichain Infrastructure

A protocol on 5 chains = 5 separate RPC endpoints, 5 subgraphs, 5 monitoring configs. Manageable but requires deployment automation.

For subgraph multi-network deployment: graph deploy --network mainnet, graph deploy --network arbitrum-one etc. with a unified codebase and network-specific addresses in separate config files.

Chainlink CCIP and LayerZero for cross-chain messaging require monitoring of both chains and transactions on intermediate relayers. A reorg on the source chain after a confirmed mint on the target chain is a classic bridge problem. Solution: wait for finality (on Ethereum ~15 minutes after Merge for economic finality) before confirming on the target chain.

Infrastructure Setup Process

  1. Audit current stack — determine chains, request volume, latency and availability requirements.
  2. Architecture design — select providers, load balancing, redundancy.
  3. Subgraph development — manifest → schema → handlers → testing on local Graph Node → deploy to testnet → mainnet.
  4. Monitoring configuration — Tenderly alerts, Grafana dashboard, PagerDuty integration.
  5. Documentation and runbook — what to do when: subgraph falls behind, RPC downtime, node desync.
  6. Handover to operations — team training, access transfer, first month support.

What's Included

  • Deployment of managed or self-hosted Ethereum, Polygon, BNB Chain nodes
  • RPC layer setup with primary/fallback and load balancing
  • Subgraph development and deployment for your protocol
  • Monitoring connection (Tenderly, Grafana, alerts)
  • Runbook and operations documentation
  • Team training (up to 4 hours online)
  • 30-day support after delivery

Timeline

Task Duration
RPC and basic monitoring setup 1–2 weeks
Subgraph for one protocol 2–4 weeks
Self-hosted node with monitoring 2–3 weeks
Full infrastructure (multi-chain, monitoring, runbooks) 6–10 weeks

All projects are managed in a GitHub/GitLab repository with CI/CD; configuration code stays with you. Order infrastructure deployment — we'll show how to cut costs by 20–30% without losing reliability. Get a consultation — we'll demonstrate how we deployed infrastructure for a protocol with large TVL on Ethereum and Arbitrum. Contact us.