Blockchain Interview Questions for 5 Years Experience
40 questions with answers for candidates with 5 years of experience — 1 easy, 24 medium, 15 hard.
What interviewers expect: 5 years experience
At five years, interviews test architecture and leadership. You may design an end-to-end protocol or enterprise solution, choose between chains, rollups and permissioned networks, and plan key management, governance and incident response. Expect questions on audits you led, production incidents, cross-team work with product and compliance, and how you set coding standards for a team.
This set is weighted towards dApp Development (8), Cryptography for Blockchain (6), Consensus and Scaling (5), DeFi, Tokens and NFTs (5).
Architecture and chain selection Security leadership Incident response Team standards
Solved at this levelStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
✓ 3 questions free • Unlock the rest in seconds
01
How do you handle a user on the wrong network in your dApp?
Optimistic rollups assume batches are valid and allow a challenge window, typically about seven days, during which anyone can submit a fraud proof; this makes them EVM-compatible and simpler but slows native withdrawals. Zk-rollups submit a validity proof with each batch, so L1 verifies correctness mathematically and withdrawals finalise once the proof is accepted. Zk proving is computationally heavy and EVM equivalence was harder, though zkEVMs have matured a lot by 2026.
03
How do you listen to contract events and query past events with ethers?
Use contract.on for live events and queryFilter for history.
const abi = ['event Transfer(address indexed from, address indexed to, uint256 value)'];
const token = new Contract(TOKEN, abi, provider);
token.on('Transfer', (from, to, value, event) => {
console.log(from, to, value.toString(), event.log.blockNumber);
});
const filter = token.filters.Transfer(null, MY_ADDRESS);
const past = await token.queryFilter(filter, -5000); // last 5000 blocks
console.log(past.length);
Use a WebSocket provider for live events, and page large ranges because providers limit block spans.
04
Calculate the output of a swap in a constant product pool with a 0.3 percent fee.
Formula: amountOut = (amountIn x 997 x reserveOut) / (reserveIn x 1000 + amountIn x 997).
Example: reserves 1,000 ETH and 3,000,000 USDC, swap 10 ETH.
amountInWithFee = 10 x 997 = 9,970
numerator = 9,970 x 3,000,000 = 29,910,000,000
denominator = 1,000 x 1000 + 9,970 = 1,009,970
amountOut = 29,615 USDC (approx)
The spot price is 3,000, but the trader gets about 2,961.5 per ETH because of fee and price impact.
The trilemma says a blockchain finds it hard to maximise decentralisation, security and scalability at the same time on a single layer. Raising block size or using few validators increases throughput but reduces decentralisation. Ethereum's answer is a rollup-centric roadmap: keep the base layer decentralised and secure, and move execution to Layer 2 rollups that post data back to Layer 1. Many high-throughput chains instead accept fewer, more powerful validators.
06
How do flash loans enable oracle manipulation attacks?
A flash loan lets anyone borrow huge amounts without collateral if it is repaid in the same transaction. An attacker borrows, makes a large trade in a thin DEX pool to move its spot price, then uses a protocol that reads that pool as its price oracle, for example borrowing too much against inflated collateral, and finally reverses the trade and repays. Defend with decentralised oracles like Chainlink, TWAPs, multiple sources and sanity bounds.
07
Which tools do you use for static analysis and fuzzing of smart contracts?
Slither performs static analysis and quickly flags reentrancy, unchecked calls, shadowing and more. Aderyn is another fast static analyser. Foundry provides fuzz and invariant testing, where random sequences of calls try to break properties you define. Echidna and Medusa are property-based fuzzers. Mythril and Halmos use symbolic execution, and Certora offers formal verification. Combining them with manual review and high test coverage catches far more than any single tool.
08
How do you test against real mainnet contracts using a fork?
Anvil or Foundry tests can fork a live chain at a block, so you interact with real tokens and protocols locally.
# Start a local fork
anvil --fork-url $MAINNET_RPC --fork-block-number 21000000
# Or fork inside a test
function setUp() public {
vm.createSelectFork(vm.envString('MAINNET_RPC'), 21000000);
}
# Give yourself tokens or impersonate a whale
deal(address(usdc), alice, 1_000e6);
vm.prank(whale);
Pinning the block number keeps results reproducible and makes RPC caching effective.
09
How have you mentored junior developers on a smart contract team?
Situation: our team hired three freshers who knew Solidity syntax but not security. Task: get them productive safely. Action: I created a two-week plan with Ethernaut challenges, pair-programmed their first features, and made them write tests before code. In reviews I explained why, not just what, and kept a shared checklist of common bugs. Result: within two months they shipped features independently, and one found a rounding bug during an internal review.
10
How do you verify a signed message inside a Solidity contract?
Recompute the message hash, add the Ethereum signed message prefix, recover the signer and compare it.
import {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import {MessageHashUtils} from '@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol';
function verify(address signer, uint256 amount, uint256 nonce, bytes calldata sig) public view returns (bool) {
bytes32 h = keccak256(abi.encode(address(this), block.chainid, amount, nonce));
bytes32 eth = MessageHashUtils.toEthSignedMessageHash(h);
return ECDSA.recover(eth, sig) == signer;
}
Track used nonces to block replays.
11
Design a blockchain solution for farm-to-store supply chain traceability. What goes on-chain?
I would use a permissioned or low-cost chain where farmers, transporters, warehouses and retailers are known members. On-chain I would record batch IDs, ownership handovers, timestamps, signer identity and hashes of certificates or sensor data. Large documents, images and IoT streams stay off-chain in object storage or IPFS, referenced by hash. QR codes on packs link consumers to the trail. The main risk is bad input data, so I would add signed device readings and audits.
12
A stablecoin used as collateral in your protocol loses its peg. How do you respond?
Activate the risk plan: pause new borrowing against that asset and freeze its use as new collateral through governance or the guardian. Switch its oracle to a market price rather than a hard-coded one dollar, so positions are valued honestly, which may trigger liquidations. Reduce its loan-to-value and supply caps. Communicate clearly with users. Longer term, cap exposure per stablecoin, diversify collateral and model depeg scenarios in risk dashboards.
13
Your RPC provider starts rate-limiting and the dApp breaks during peak traffic. What do you do?
Short term, add a fallback transport with multiple providers so requests fail over automatically, and use retries with backoff. Reduce load: batch calls with multicall, cache read results, use WebSockets instead of tight polling, and move history queries to an indexer. Long term, upgrade the plan, spread traffic across providers or run your own node for critical paths, and monitor error rates and latency with alerts so you learn of issues before users do.
14
What is ECDSA and why does Ethereum use the secp256k1 curve?
ECDSA is the Elliptic Curve Digital Signature Algorithm. It gives strong security with short keys: a 256-bit key is roughly as strong as a 3072-bit RSA key, which keeps transactions small. Bitcoin and Ethereum use the secp256k1 curve, whose simple structure allows efficient computation. A signature has values r and s plus a recovery id v, which lets nodes recover the signer's public key from the signature, so the sender address need not be included separately.
15
You are launching a 10,000-piece NFT collection and fear gas wars and bots. How do you design the mint?
Avoid a first-come public rush. Use an allowlist phase with Merkle proofs or signatures, per-wallet limits, and staggered time slots. Consider a Dutch auction or raffle so price, not gas, decides allocation. Use ERC-721A or efficient batch minting to cut gas. Reveal traits later with Chainlink VRF so bots cannot snipe rare items. Load-test the front-end and RPC, and keep pause functions ready in case something goes wrong.
16
What are front-running and sandwich attacks, and how do you mitigate them?
Pending transactions are public, so bots can copy or outbid them. Front-running is placing a transaction ahead of a victim's, for example buying before a large purchase. A sandwich attack buys before the victim's swap and sells right after, profiting from the price impact. Mitigations include slippage limits and deadlines, commit-reveal schemes, batch auctions, private transaction relays, and design that does not reward ordering, such as using time-weighted prices.
17
What is the difference between receive and fallback functions?
receive() external payable runs when a contract receives plain ETH with empty calldata, for example a transfer from a wallet. fallback() runs when calldata matches no function, or when ETH arrives with data and no receive exists; it must be payable to accept ETH. Proxies use fallback to delegatecall all unknown calls to the implementation. Keep both simple, since a reverting or gas-heavy receive can break senders that use transfer with its 2300 gas stipend.
A sidechain is an independent blockchain with its own validators and consensus, connected to the main chain by a bridge. Its security depends on its own validator set, so if they collude, funds can be stolen. A rollup posts its transaction data and state roots to Ethereum and relies on fraud or validity proofs, so it inherits Layer 1 security for correctness. Sidechains are usually cheaper and more flexible, but rollups give stronger guarantees.
19
Show a contract vulnerable to reentrancy and a fixed version.
Fee-on-transfer tokens deduct a percentage on every transfer, so when your contract calls transferFrom for 100 tokens it may receive only 98. If the code assumes 100 arrived, balances and reserves drift and can be exploited. Fix it by measuring the actual amount received: read the contract's balance before and after the transfer and use the difference. Also decide whether to support such tokens at all and document unsupported token behaviours like rebasing.
21
How would you implement Sign-In with Ethereum on a web back-end?
Follow EIP-4361. The server generates a random nonce and stores it in the session. The front-end builds a SIWE message with domain, address, statement, URI, chain ID, nonce and issued-at time, and the wallet signs it. The server verifies the signature with a SIWE library, checks domain, nonce, expiry and chain, then issues a session cookie or JWT and deletes the nonce. For smart contract wallets, verify via ERC-1271 isValidSignature.
22
What is a digital signature and what does it guarantee?
A digital signature is a value produced by signing a message hash with a private key. Anyone with the public key can verify it. It guarantees authentication (the holder of the key signed it), integrity (the message was not changed, since any change breaks verification) and non-repudiation (the signer cannot later deny it). In blockchain, every transaction is signed, so nodes accept a transfer only if the signature matches the sending account.
23
How do you manage deployer private keys in a CI/CD pipeline?
Never commit keys or put them in plain environment files. For testnets, use CI secret storage with restricted access. For mainnet, avoid hot keys in CI entirely: have CI produce a transaction proposal that signers approve in a multisig, or use a cloud KMS or HSM signer so the key never leaves secure hardware. Separate deployer and admin roles, transfer ownership to a multisig immediately after deployment, and log and review every deployment.
EIP-4844, shipped in the Dencun upgrade in March 2024, added blob-carrying transactions. Blobs are large data chunks of about 128 KB that rollups use to post batch data, priced in a separate fee market and pruned by nodes after roughly 18 days. Contracts cannot read blob contents, only their KZG commitments. This cut L2 data costs dramatically. Later upgrades raised blob capacity, and PeerDAS in the Fusaka upgrade lets nodes sample data instead of downloading every blob.
25
What is a Merkle Patricia Trie and why does Ethereum use it?
A Merkle Patricia Trie combines a Patricia (compressed prefix) trie with Merkle hashing. Ethereum uses it to store world state, account storage, transactions and receipts, with each root stored in the block header. It allows efficient insert, update and lookup by key, and any value can be proven against the root with a proof. Its weakness is large proof size, which is why Ethereum researchers plan to move to Verkle or binary hash trees for stateless clients.
26
How do you read a contract's storage slot directly with Foundry's cast?
Use cast storage with the contract address and slot number. For mappings, compute the slot as keccak256(key . slot).
# Read slot 0 (often the first state variable)
cast storage 0xContractAddress 0 --rpc-url $RPC_URL
# balanceOf mapping stored at slot 2, key = user address
cast index address 0xUserAddress 2
cast storage 0xContractAddress <slot-from-above> --rpc-url $RPC_URL
This shows that private variables are not secret: anyone can read storage.
27
What is account abstraction, and how do ERC-4337 and EIP-7702 differ?
Account abstraction makes accounts programmable, so wallets can support batching, gas paid in tokens or by sponsors, passkeys, spending limits and social recovery. ERC-4337 does this without protocol changes: users send UserOperations to an alternate mempool, bundlers submit them to an EntryPoint contract, and paymasters can sponsor gas. EIP-7702 is a protocol change that lets an existing EOA point to smart account code, so users keep their address while gaining these features.
Track on-chain activity in real time: alert on admin actions, large transfers, unusual withdrawal rates, paused states, oracle deviations and failed transactions. Use monitoring services or custom bots reading events, with alerts to on-call channels. Monitor invariants, such as total assets matching total shares, and automate responses like pausing through a guardian. Also watch the front-end, RPC health and DNS for hijacking. Review alerts weekly to reduce noise and test the incident runbook.
29
A simulated eth_call succeeds but the real transaction reverts. What could cause this?
The state can change between simulation and inclusion: price moved beyond slippage limits, a deadline passed, another user took the last item, or a bot front-ran the trade. Other causes are a different msg.sender or value in the simulation, a gas limit too low for the real path, block-dependent logic like block.timestamp, or a different block tag. Debug by tracing the failed transaction with cast run or a tracer and comparing inputs and state.
30
Describe a time you found a security problem in code and how you handled it.
Situation: while reviewing a teammate's staking contract, I saw it sent tokens before updating the user's balance. Task: confirm the risk without blaming anyone. Action: I wrote a Foundry test with a malicious receiver that re-entered withdraw and drained extra funds, then shared it privately with a suggested fix using checks-effects-interactions and a reentrancy guard. Result: the fix merged before the audit, and we added reentrancy tests to our standard checklist.
31
What is storage packing, and what are other key gas optimisations?
The EVM stores data in 32-byte slots, so consecutive small variables like uint128, uint64, address and bool can share a slot if declared next to each other, saving expensive SSTOREs. Other optimisations: use calldata for external arrays, cache storage reads in local variables, use immutable and constant, prefer custom errors over strings, avoid unbounded loops, use events instead of storing history, and use unchecked for counters that cannot overflow. Always measure with forge snapshot.
32
A developer accidentally pushed a private key to a public GitHub repo. What do you do?
Treat the key as compromised immediately, because bots scan GitHub within seconds. Move all funds and tokens to a new secure wallet, revoke token approvals, and if the key owns contracts, transfer ownership or roles to a new multisig. Removing the commit is not enough since history and forks keep it. Then rotate any related API keys, add secret scanning and pre-commit hooks, and load keys from environment variables or a secrets manager.
Cross-function reentrancy happens when an attacker re-enters a different function that shares state with the one making the external call, so a guard on only one function does not help. Read-only reentrancy happens when a view function, such as a pool's price getter, returns inconsistent state mid-execution, and another protocol reads it during the callback and misprices assets. Mitigate by guarding all state-sharing functions, updating state before calls, and checking a reentrancy lock in view functions other protocols rely on.
34
Write a minimal Python example showing how blocks are linked by hashes.
Each block stores the previous hash, so changing any earlier data breaks the chain.
import hashlib, json
def block_hash(block):
data = json.dumps(block, sort_keys=True).encode()
return hashlib.sha256(data).hexdigest()
chain = [{'index': 0, 'data': 'genesis', 'prev': '0'}]
for i, tx in enumerate(['A pays B 5', 'B pays C 2'], 1):
chain.append({'index': i, 'data': tx, 'prev': block_hash(chain[-1])})
valid = all(chain[i]['prev'] == block_hash(chain[i-1]) for i in range(1, len(chain)))
print(valid)
35
You are asked to design a cross-chain bridge. What are the main risks and design choices?
Bridges hold large pooled funds, so they are top hacking targets. Main risks are compromised validator or multisig keys, faulty message verification, and replay of messages across chains. Prefer verification based on light clients or zk proofs over a small trusted multisig. Use rate limits, per-transfer caps, pausing, monitoring of mint-versus-lock balances, and a delay for large transfers. Get multiple audits, run a bug bounty, and consider established messaging protocols instead of building from scratch.
36
What is the difference between an execution client and a consensus client, and why does client diversity matter?
Since the Merge, an Ethereum node runs two pieces of software. The execution client, such as Geth, Nethermind, Besu, Erigon or Reth, runs the EVM, holds state and handles transactions. The consensus client, such as Lighthouse, Prysm, Teku, Nimbus or Lodestar, runs Proof of Stake. They talk over the Engine API. Client diversity matters because a bug in a client used by over two-thirds of validators could finalise an invalid chain and cause mass slashing.
37
Tell me about a time you explained blockchain to a non-technical stakeholder.
Situation: a business head wanted 'blockchain' in a vendor portal because competitors mentioned it. Task: help him decide. Action: I compared it to a shared online spreadsheet that nobody can secretly edit, then showed cost, speed and privacy trade-offs against a normal database with audit logs. Result: we agreed to keep the portal on a database and anchor monthly hashes of invoices on a chain for proof, saving months of work while meeting the trust goal.
38
A sharp market fall causes cascading liquidations in your lending protocol and bad debt. How do you design against it?
Set conservative loan-to-value ratios and liquidation thresholds per asset based on volatility and on-chain liquidity. Use supply and borrow caps for illiquid tokens, isolation mode for risky assets, and a liquidation bonus that attracts liquidators without over-penalising users. Allow partial liquidations so positions shrink gradually. Keep reliable oracles, an insurance or reserve fund to absorb bad debt, and run stress tests simulating 30 to 50 percent price drops.
39
What is the difference between a soft fork and a hard fork?
A soft fork tightens the rules so that new blocks are still valid for old nodes; it is backward compatible, like Bitcoin's SegWit upgrade. A hard fork changes the rules so that old nodes reject new blocks, so every node must upgrade or the chain splits, as with Ethereum and Ethereum Classic in 2016. Planned network upgrades on Ethereum, such as Dencun and Pectra, are coordinated hard forks that all clients adopt together.
40
How do you handle unclear or changing requirements from a client?
Situation: a client asked for a marketplace dApp but kept changing royalty and fee rules. Task: deliver without endless rework. Action: I wrote a short spec with examples and edge cases, got sign-off, and made fees configurable parameters with limits instead of hard-coded logic. Changes went through a simple change log with impact estimates. Result: we delivered in eight weeks, and later fee changes needed only a governance transaction, not a redeployment.
Frequently asked questions
What is asked in Blockchain interviews for 5 years of experience?
At five years, interviews test architecture and leadership. You may design an end-to-end protocol or enterprise solution, choose between chains, rollups and permissioned networks, and plan key management, governance and incident response. Expect questions on audits you led, production incidents, cross-team work with product and compliance, and how you set coding standards for a team.
How many questions should I practise before a Blockchain interview?
Work through all 40 questions here, then the company-wise sets for the employers you are targeting. Quality matters more than count: be able to explain why each answer is right.
Which topics matter most for 5 years of experience?
Focus first on Architecture and chain selection, Security leadership, Incident response, Team standards.