What is onchain and offchain
What is onchain and offchain
Onchain means that an action, record, or computation is executed and stored directly on a blockchain, where it is verified by the network's nodes and becomes part of the permanent, publicly auditable ledger. Offchain means that the action happens outside the blockchain — on traditional servers, local machines, or separate networks — and is not directly recorded in or verified by the blockchain's consensus process.
The distinction matters because it determines what is independently verifiable and what requires trust. Anything onchain can be checked by anyone with access to a block explorer. Anything offchain requires trusting the party that performed the computation or stored the data, unless additional mechanisms (such as cryptographic proofs) bridge the gap.
In short: onchain means recorded and verified on the blockchain; offchain means it happens elsewhere — and in crypto AI, understanding where the AI actually runs is the key to evaluating a project's Onchain necessity.
How onchain and offchain work
What happens onchain
When something happens onchain, it goes through the full blockchain lifecycle:
- A user or application submits a transaction to the network.
- The transaction is broadcast to nodes across the network.
- Validators include the transaction in a block according to the chain's consensus mechanism.
- Every node independently verifies that the transaction follows protocol rules.
- Once the block is confirmed, the transaction becomes part of the permanent, immutable ledger.
Onchain operations include: transferring tokens, deploying or calling smart contracts, recording data in contract storage, minting NFTs, casting governance votes, and registering proofs or hashes.
The critical property of onchain activity is independent verifiability. Anyone can query the blockchain, inspect any transaction, and verify its validity without relying on a third party. This is what makes blockchain useful as a trust layer.
What happens offchain
Offchain operations are everything that does not go through the blockchain's consensus process. This includes:
- Traditional computation — running software on servers, cloud instances, or personal machines. The vast majority of the world's computation is offchain.
- Offchain data storage — storing files, databases, or model weights on centralized servers, IPFS, Arweave, or other storage systems that are not part of a blockchain's state.
- Offchain messaging and coordination — communication between parties via APIs, message queues, or peer-to-peer protocols outside the blockchain.
- AI inference and training — running machine learning models, which is computationally intensive and typically too expensive to perform inside a blockchain's execution environment.
Offchain operations are not inherently inferior to onchain ones. They are faster, cheaper, and more flexible. The trade-off is that they require trust in whoever performs them, unless the results are anchored back to the blockchain through verification mechanisms.
The cost equation
A central reason why most computation stays offchain is cost. On Ethereum, every operation inside a smart contract costs gas — a fee paid to validators for executing and verifying the computation. Running a simple token transfer might cost a fraction of a dollar. Running a machine learning model with millions of parameters inside a smart contract would cost thousands or millions of dollars in gas fees, assuming it were even technically possible within block gas limits.
This cost structure means that blockchains are optimized for verification, not for computation. They excel at confirming that something happened correctly, not at performing the heavy lifting. This is why the dominant architecture in crypto AI is hybrid: heavy computation offchain, verification and settlement onchain.
Hybrid architectures
Most real-world crypto AI projects use a hybrid model:
- AI computation happens offchain — on GPU clusters, decentralized compute networks, or cloud providers. This is where model training, inference, data processing, and analysis take place.
- Results and proofs are posted onchain — the outputs, cryptographic proofs, model hashes, or decision checkpoints are recorded on the blockchain for verification and auditability.
- Economic settlement happens onchain — token payments, rewards, staking, and governance actions are handled by smart contracts on the blockchain.
This hybrid approach is not a compromise or a failure of decentralization. It is a rational architecture that uses each layer for what it does best: blockchains for trust-minimized verification and economic coordination, offchain systems for high-performance computation.
Some projects go further with technologies like zero-knowledge proofs (ZK) or trusted execution environments (TEE), which allow offchain computation to produce cryptographic guarantees that the computation was performed correctly — effectively borrowing onchain-level verifiability for offchain operations.
Why it matters for crypto AI projects
The onchain-offchain distinction is the technical foundation for one of DecAIHub's three core assessment axes: Onchain necessity.
Most AI is offchain — and that is normal
A common misconception is that a "crypto AI" project should run its AI model onchain. In practice, this is neither feasible nor desirable for most applications. Neural networks require massive amounts of sequential floating-point computation that blockchain virtual machines are not designed for. Running GPT-scale inference inside an Ethereum smart contract is not a reasonable expectation.
What is reasonable to expect is that the project uses the blockchain meaningfully: for verifiable result logging, for decentralized coordination of compute resources, for transparent token-based incentive mechanisms, or for governance of the AI system itself.
The critical question: does onchain add value?
DecAIHub's Onchain necessity assessment asks: if you removed the blockchain component from this project, would the product fundamentally change? If the answer is "the AI would work identically without any blockchain involvement," then the onchain component may be cosmetic — added for narrative purposes rather than functional necessity.
Projects with strong Onchain necessity typically show patterns like:
- The blockchain coordinates a decentralized network of compute providers who contribute resources for AI tasks.
- AI model outputs or decision checkpoints are recorded onchain for independent verification.
- Token incentives align the behavior of data providers, validators, or model contributors in a way that would be difficult to replicate without a blockchain.
- Governance of the AI model or its parameters is conducted through on-chain mechanisms.
Projects with weak Onchain necessity might show patterns like:
- A standard AI product with a token added for fundraising, where the product would function identically without the token or blockchain.
- An AI chatbot whose responses are not logged, verified, or influenced by any onchain mechanism.
- A project that issues a token but performs all operations on centralized infrastructure with no meaningful on-chain integration.
Separating the technical question from the methodological one
It is important to distinguish between two related but different questions:
- Technical: Is this operation onchain or offchain? — This is a factual, observable question about where computation and data reside.
- Methodological: Does this project's use of blockchain serve a necessary purpose? — This is the Onchain necessity question in DecAIHub's framework, and it involves judgment about the project's architecture and value proposition.
This explainer covers the first question. For the second, see AI reality, Onchain necessity and Token necessity.
Where this appears in DecAIHub project cards
The onchain-offchain distinction influences how several project card fields are interpreted:
- Onchain necessity — this is the direct methodological application of the onchain-offchain concept. It evaluates whether the project's on-chain activity serves a genuine function.
- Main chain — specifies where the project's onchain activity is recorded. If a project lists
Ethereumas its main chain, its onchain transactions and smart contracts live on the Ethereum network. - AI component — the AI component field describes what the project's AI actually does (inference, compute, analytics, training, agents). Understanding onchain vs. offchain helps determine where this AI component runs and how its outputs are verified.
- Type and Category — architectural distinctions like L1, L2, protocol, and dApp imply different onchain-offchain balances. An L1 (typically
Type: Appchain) is fully onchain infrastructure. A dApp (typicallyType: EVMornon-EVM) might be primarily offchain with onchain settlement. - Evidence table — Tier-1 evidence such as code repositories, deployed contracts, and verifiable model endpoints helps establish whether onchain claims are backed by actual on-chain activity.
When reading a project card, ask: what exactly is onchain? Is it just the token, or does the blockchain play a functional role in the AI workflow? The answer to this question is central to the Onchain necessity assessment.
What onchain alone does not prove
Having onchain activity — transactions, smart contracts, token transfers — tells you that the project interacts with a blockchain, but it does not prove:
- AI reality — a project can have extensive onchain activity (token transfers, staking contracts, governance votes) with zero AI functionality. Onchain activity and AI reality are independent axes.
- Decentralization of AI — posting AI results onchain does not mean the AI itself is decentralized. The model might run on a single centralized server, with only its outputs recorded on-chain.
- Correctness of offchain computation — unless the project uses cryptographic verification (such as ZK proofs), recording results onchain proves only that someone submitted those results, not that the underlying computation was performed correctly.
- User value — onchain activity can be generated artificially. A project can create large volumes of transactions without providing meaningful service. Transaction count alone is not evidence of product-market fit.
- Token necessity — the presence of onchain smart contracts does not explain why the project needs a token. A useful onchain application can operate purely with the base chain's native token for gas fees without requiring its own token.
Do not confuse with
- Decentralized — "onchain" and "decentralized" are related but different concepts. An operation can be onchain (recorded on a blockchain) without being decentralized (if the blockchain has only a few validators). And a system can be decentralized (distributed across many independent nodes) without using a blockchain at all (peer-to-peer file sharing, for example).
- Open-source — open-source code is publicly available for inspection. Onchain data is publicly available for verification. These are complementary but distinct: a project can have open-source code that runs offchain, or closed-source code that generates onchain transactions.
- Onchain necessity (DecAIHub metric) — the term "onchain" describes where something happens. "Onchain necessity" is a DecAIHub assessment that evaluates whether the blockchain usage serves a genuine purpose. This explainer covers the technical concept; the methodology is covered in AI reality, Onchain necessity and Token necessity.
- Layer 2 (L2) — L2 networks process transactions offchain (or on a separate chain) and periodically settle proofs or state roots back to the L1. From the user's perspective, L2 transactions feel "onchain," but they involve a different trust model than L1 transactions. Understanding the nuances requires knowing which layer a project's activity lives on.
Frequently asked questions
Can AI run onchain?
For most practical purposes, not yet. Running a neural network inside a smart contract is prohibitively expensive on general-purpose blockchains. Ethereum's execution environment charges gas for every computational step, and even simple ML models would exceed block gas limits. Some specialized approaches — such as compiling small models into smart contract logic or using ZK proofs to verify offchain computation — are being explored, but the standard architecture for crypto AI is offchain computation with onchain verification and settlement.
If AI runs offchain, what is the point of blockchain?
The blockchain serves as the verification and coordination layer. Even though the AI computation happens offchain, the blockchain can: record the results for independent auditing, manage payments between compute providers and consumers, enforce incentive rules through smart contracts, govern model parameters through on-chain voting, and provide a censorship-resistant interface for accessing AI services. The value is in what the blockchain verifies and coordinates, not in what it computes.
How can I verify that offchain computation was done correctly?
Several approaches exist: (1) Cryptographic proofs — zero-knowledge proofs can mathematically prove that a computation was performed correctly without revealing the underlying data. (2) Redundant computation — multiple independent parties perform the same computation and the results are compared. (3) Trusted execution environments (TEE) — hardware enclaves that provide attestation that code ran as specified. (4) Reputation and staking — compute providers stake tokens that can be slashed if they produce incorrect results. None of these are perfect, and each involves trade-offs between cost, speed, and trust assumptions.
What does it mean when a project says it is "fully onchain"?
It typically means that the project's core logic, state, and governance are implemented as smart contracts on a blockchain, rather than relying on offchain servers for critical functions. For a simple DeFi protocol (like a token swap or lending pool), being "fully onchain" is feasible and meaningful. For an AI project, "fully onchain" is a much stronger claim that should be examined carefully — does it mean the AI model itself runs onchain (extremely rare and expensive), or that the token mechanics and governance are onchain while the AI remains offchain?
Does offchain mean centralized?
Not necessarily. Offchain computation can be distributed across a decentralized network of independent providers. Decentralized compute networks coordinate offchain GPU resources through blockchain-based marketplaces, achieving decentralized execution without running computation inside smart contracts. Offchain simply means "not on the blockchain" — it says nothing about whether the operation is centralized or distributed.
External references
- Ethereum.org — Transactions — official documentation explaining onchain transactions on Ethereum.
- On-chain vs. off-chain transactions (Wikipedia) — overview of the fundamental distinction in blockchain architecture.
- Ethereum.org — Scaling — explanation of scaling approaches including offchain computation with onchain verification.
No comments to display
No comments to display