Skip to content
ON CHAIN
Menu

What Does On-Chain Mean? On-Chain vs Off-Chain Data, Transactions and Trading

On-chain is a claim about who can verify something, not where it is stored. Here is how to tell on-chain from off-chain data, and how to check the link between them.

By OnChain Team7 min read

On-chain means a piece of data or an action is recorded in a blockchain's shared ledger, where anyone running the network can verify it without trusting a company. Off-chain means everything else: your database, a JSON file on a server, an order sitting in an exchange's matching engine. The twist is that most things people call "on-chain" are a mix. A token's balance is on-chain, but its name and picture usually are not, and the only thing tying them together is a pointer. Knowing where that line sits is the difference between a product users can verify and one they merely have to believe.

This post explains the three places the word shows up (data, transactions, trading), draws the boundary, and gives two short TypeScript examples: reading a transaction straight from a node, and checking that an off-chain file still matches what the chain points to.

What "on-chain" actually guarantees

A blockchain is a ledger that many independent computers keep and check. On Ethereum, blocks are batches of transactions that carry a hash of the previous block, so altering an old block would invalidate every block after it. That chaining is why on-chain history is hard to rewrite, and why anyone can recompute it instead of asking you.

Three properties follow, and they are the whole point:

  • Public. Anyone can read it. That includes your competitors, and it includes every wallet's full history.
  • Verifiable. You can check a claim yourself against the ledger, with no support ticket.
  • Final, eventually. "Recorded" is not one moment. On Solana's RPC (the node's query interface), a processed block is the node's newest view and can still be skipped, while finalized needs a certificate of validator votes. That page also says confirmed currently maps to the same block as finalized, a change from older behaviour, so check which commitment level your client library assumes (we read the page on 2026-12-04, and it may change).

What on-chain does not guarantee is that the data is true. It guarantees that the data is recorded, ordered and unaltered. A wallet can record a false statement forever.

On-chain vs off-chain, by example

Thing Where it lives Who can verify it
Token balance, ownership On-chain Anyone, from the ledger
A swap that executed On-chain (a transaction) Anyone, by signature
Token name, symbol, URI On-chain (a metadata account) Anyone
Token image, description Off-chain, referenced by the URI Only if you also check a hash
An order on a centralised exchange Off-chain, in their database Only the exchange
Charts, search, "top traders" Off-chain, built from chain data You, if you re-derive them

The token metadata row is the instructive one. In Metaplex's Token Metadata program, a metadata account stores on-chain attributes, and its URI points to an off-chain JSON file so the project avoids paying on-chain storage for it. The same page notes that turning off Is Mutable freezes the URI, name and creators, and that the JSON can sit on permanent storage such as Arweave. A frozen pointer to a file on an ordinary web server still points at something its owner can change.

The chain holds the proof; everything around it holds the convenience
ON-CHAINUSERWalletSigns, holds keysApp backendBuilds thetransactionON-CHAINTransactionOrdered, signed,publicON-CHAINAccountsBalances, metadataURIFAILURE PATHDroppedExpired beforeinclusionIndexerDecodes ledger dataDATADatabaseCharts, search,historyEXTERNALOff-chain fileImage, JSON, docsrequestunsigned txsigned txstate changenot includedreadURI + hash

Main flowSecondaryFailure pathSwipe to see the whole diagram →

Read the red edge as a fact about the medium. A transaction that nobody includes simply never happened, and you only learn that by checking, not by being told.

Transactions: on-chain actions

A transaction is a signed instruction set that changes ledger state. The signature proves the wallet's owner approved it, and the ledger orders it against everyone else's. For trading, this is the real distinction. On a centralised exchange your order lives in the operator's matching engine, and settlement is a database update you cannot independently audit. On-chain, the swap and the settlement are the same event, visible to everyone, with the trade-offs that come with that: public ordering invites front-running (we cover it in our Solana MEV guide), and fees are part of the price.

Here is how to read one directly from a node, with no SDK, so you can see what the ledger itself returns. It uses Solana's getTransaction JSON-RPC method.

readTx.tsTypeScript
const RPC_URL = process.env.RPC_URL!; // any Solana RPC endpoint

async function rpc<T>(method: string, params: unknown[]): Promise<T> {
  const res = await fetch(RPC_URL, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  });
  const body = await res.json();
  if (body.error) throw new Error(body.error.message);
  return body.result as T;
}

export async function checkTransaction(signature: string) {
  const tx = await rpc<any>("getTransaction", [
    signature,
    // finalized: the strictest level; version 0 covers modern transactions
    { commitment: "finalized", maxSupportedTransactionVersion: 0 },
  ]);

  // null means this node has no such transaction at this commitment.
  // It may be unfinalized, dropped, or older than the node keeps.
  if (tx === null) return { found: false as const };

  return {
    found: true as const,
    slot: tx.slot,
    blockTime: tx.blockTime, // unix seconds, can be null
    succeeded: tx.meta.err === null, // a failed tx is still on-chain
    feeLamports: tx.meta.fee,
  };
}

Two things bite people here. A transaction that failed is still recorded, and you still paid its fee, so meta.err matters more than "found". And null is ambiguous: the node may simply not keep history that far back, which is why serious products run their own indexer (the pipeline we describe here) instead of asking a public endpoint about last year.

Data: closing the gap between on-chain and off-chain

When a contract points to a file, store a hash of the file next to the pointer. Anyone can then fetch the file and confirm it is the one the project committed to. NFT metadata is the common case, but the same pattern works for documents, reports and model weights. Without a hash, "on-chain" ends at the URI and the rest is trust.

verifyOffchain.tsTypeScript
import { createHash } from "node:crypto";

// expectedSha256 is what the on-chain record committed to (hex string).
export async function matchesCommitment(url: string, expectedSha256: string) {
  const res = await fetch(url, { redirect: "error" }); // no silent redirects
  if (!res.ok) return false;

  const bytes = Buffer.from(await res.arrayBuffer());
  const actual = createHash("sha256").update(bytes).digest("hex");

  // Hash the raw bytes. Re-serialising JSON first changes the hash.
  return actual === expectedSha256.toLowerCase();
}

This only helps if the hash is written on-chain by a party you trust, and if you hash raw bytes rather than a parsed-and-reformatted object. It also says nothing about whether the file's contents are honest, only that they have not changed since commitment.

Where off-chain still wins

In all fairness, putting less on-chain is usually the right call. Writing costs fees, everything is public, and a ledger is a poor search engine. Order books, notifications, user profiles and analytics belong in ordinary systems, fed by chain data. Our dApp guide walks through that split with a working contract. The mistake is not using off-chain systems. It is describing them as on-chain, or letting them quietly override what the ledger says.

What we would do

Ask one question of every component: if this lied, could a user detect it from the ledger alone? If yes, it can stay off-chain as a cache or index. If no, either move the rule on-chain, commit a hash of it, or be honest in the product that users are trusting you. Run your own indexer for anything you show users as fact, and re-derive it from the chain when numbers look odd.

If you need chain data turned into a reliable product feed, see our Solana data scrapers page.

Key takeaways

  • On-chain means public and verifiable, not true.
  • Treat a URI as a promise. Store a hash if the content matters.
  • Check commitment levels and meta.err before calling a transaction done.
  • Keep search, charts and profiles off-chain, and say so.

This post is engineering guidance, not investment, legal or tax advice. Commitment semantics and RPC behaviour change between releases; sources were read on 2026-12-04.

Contact

Need this built for your product?

Tell us what you are building and where you are stuck. Email is the fastest way to reach the team.

contact@onchain.ro