On-Chain vs Off-Chain: Where Your Data Actually Lives
The critical difference between blockchain data and exchange database data — what is public, what is private, and how exchanges reconcile both worlds.
In this guide
Two Separate Worlds
When you use a centralized exchange like Binance or Coinbase, your data exists in two completely separate systems:
On-chain (blockchain): - Your actual cryptocurrency deposits and withdrawals - The transaction hashes (tx_hash) that prove movement of funds - Public, immutable, verifiable by anyone - Stored on thousands of nodes worldwide
Off-chain (exchange database): - Your account profile, email, KYC documents - Your order history and trade executions - Your internal balance (a number in a PostgreSQL row) - Login sessions, audit logs, notifications - Private, controlled by the exchange
The fundamental insight: when you trade on Binance, no blockchain transaction occurs. The matching engine simply updates numbers in a database. Only deposits and withdrawals involve actual on-chain transactions.
What Lives On-Chain
Deposits: When you send BTC from your hardware wallet to Binance, a real Bitcoin transaction is created — broadcast to the Bitcoin network, included in a block by a miner, permanently recorded with a unique tx_hash, publicly visible on any block explorer.
Withdrawals: When you withdraw ETH from Coinbase, the exchange's hot wallet creates a real Ethereum transaction. The exchange stores the tx_hash in the withdrawals table for reconciliation.
Smart contract interactions: If you use a DEX (Uniswap, dYdX), every swap and token approval is an on-chain transaction. This is fundamentally different from a CEX.
What you can verify on-chain: - Total holdings of an exchange (if they publish proof-of-reserves) - Your deposit/withdrawal transactions (using the tx_hash) - Nothing else — your trades, orders, and internal transfers are invisible on-chain
What Lives Off-Chain
Everything else. When you place a limit buy for 0.5 BTC on Binance:
- The matching engine receives your order (in-memory, microseconds)
- If it matches, a trade is recorded in the
tradestable - Your balance is debited (USDT) and credited (BTC) via ledger entries
- The order status is updated to 'filled'
None of this touches any blockchain.
Off-chain data includes:
- auth_users — email, password hash, KYC status, 2FA config
- balances — per-user per-asset available and locked amounts
- orders — every order ever placed, with full lifecycle
- trades — every match between a buy and sell order
- ledger_entries — append-only financial log (source of truth for balances)
- audit_log — every user action for compliance
- login_sessions — device, IP, location for every login
- kyc_documents — uploaded ID documents and verification status
The trust implication: When you deposit crypto to an exchange, you are trusting them to correctly credit your balance, not manipulate the database, and actually hold the crypto they claim. This is why "proof of reserves" audits exist.
Reconciliation: Bridging Both Worlds
Exchanges must continuously verify that off-chain records match on-chain reality:
Deposit reconciliation: A blockchain monitor daemon scans every block for transactions to the exchange's addresses. For each detected deposit: 1. Look up the deposit address → find the user_id 2. Wait for required confirmations (BTC: 3, ETH: 12) 3. Insert a ledger_entry crediting the user's balance 4. Update the deposit record status to 'completed'
Withdrawal reconciliation: After broadcasting a withdrawal transaction: 1. Monitor the blockchain for the tx_hash confirmation 2. Update the withdrawal record with the confirmed tx_hash 3. If the transaction fails, revert to 'failed' and re-credit the user
Balance proof (critical integrity check):
``sql
SELECT
b.available + b.locked AS table_balance,
SUM(le.amount) AS ledger_balance
FROM balances b
JOIN ledger_entries le ON le.user_id = b.user_id AND le.asset = b.asset
WHERE b.user_id = $1 AND b.asset = $2
GROUP BY b.available, b.locked;
-- These two numbers MUST match. Any discrepancy is a critical alert.
``
Hot wallet vs cold wallet: Exchanges keep ~5-10% of total assets in a "hot wallet" (online, for withdrawals) and ~90-95% in "cold storage" (offline, in HSMs). Coinbase states they keep 98% of customer funds in cold storage.
Practice in a risk-free environment
Apply the concepts using virtual funds and live market data. NexChange is an educational simulation, not a real-money exchange.
Continue learning
Related guides
How Crypto Exchanges Store Every Operation
A deep technical dive into the database architecture of real crypto exchanges — how Binance and Coinbase track every deposit, trade, withdrawal, and audit event per user.
How Blockchain Technology Works
A deep dive into the technology that powers cryptocurrencies — blocks, chains, consensus mechanisms, and decentralized networks.
Crypto Wallets Explained
Understand the different types of cryptocurrency wallets, how they work, and how to choose the right one for your needs.