How do you decide what logic and data should live on chain versus off chain in a dApp?
What the interviewer wants to hear
- On chain for trust-critical state, ownership and value transfer
- Off chain for large data, private data and heavy computation
- Use hashes, Merkle roots or proofs to link off-chain data to on-chain state
- Cost, latency, privacy and censorship trade-offs
- Layer 2s, data availability and ZK proofs as middle grounds
Model answer
I ask what users need to trust without trusting us. Ownership of assets, balances, and rules about moving value belong on chain, because that is the reason to use a blockchain. Large data like images, documents or game assets goes off chain on IPFS or Arweave, with only a content hash on chain so anyone can verify it has not changed. Private data, like personal details, should never be on a public chain at all, because it is permanent. Heavy computation, such as matching orders or calculating airdrops, can run off chain, with results committed as a Merkle root so users claim with a proof, or verified with a ZK proof. Things like search and analytics come from an indexer. Cost and latency also matter: Layer 2 rollups and blob data have made on-chain writes much cheaper, which moves the line. Each off-chain piece adds a trust or availability assumption, which I document clearly for users.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Blockchain Developer questions
- You are designing a new lending protocol. What are the biggest security risks and how do you address them?
- Why have cross-chain bridges been a common target for large hacks, and how would you design a safer cross-chain system?
- What is MEV, and how would you protect your protocol's users from harmful MEV?
- How do you prepare a codebase for a security audit, and what happens after the audit?
- Your protocol is being exploited right now on mainnet. What do you do in the first hour and afterwards?
- How does EIP-7702 change assumptions that smart contracts and dApps make about EOAs, and what would you change in your code?
- How do you make sure an upgrade to a proxy-based contract does not corrupt storage or break the system?
- You are building an ERC-4626 yield vault. What design and security issues do you consider?
- Your team wants to deploy the same protocol to five EVM chains, including L2s. What can go wrong and how do you prepare?