Skip to content

Blockchain Interview Questions for 3 Years Experience

40 questions with answers for candidates with 3 years of experience — 2 easy, 34 medium, 4 hard.

What interviewers expect: 3 years experience

With three years, you are treated as a strong individual contributor. Expect DeFi design questions, AMM and lending maths, oracle risks, fuzz and invariant testing, and system design such as a staking platform or bridge. You should discuss trade-offs clearly, mentor juniors, and show how you made protocols safer through testing, monitoring and audit remediation.

This set is weighted towards Cryptography for Blockchain (7), Blockchain Fundamentals (7), Smart Contract Security (6), DeFi, Tokens and NFTs (5).

DeFi protocol design Invariant testing Oracle and MEV risks System design
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

Calculate the output of a swap in a constant product pool with a 0.3 percent fee.

Save to ▾
Show answer
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.
02

How would you check on-chain whether a user is in a 10,000-address allowlist without storing all addresses?

Save to ▾
Show answer
Build a Merkle tree off-chain from the allowlisted addresses (hashing each leaf, ideally double-hashed with amounts if needed) and store only the 32-byte root in the contract. Each user submits a proof of about 14 hashes for 10,000 leaves. The contract recomputes the root with OpenZeppelin MerkleProof.verify and compares it. This costs one storage slot instead of 10,000, and you can update the list by changing the root.
03

Which tools do you use for static analysis and fuzzing of smart contracts?

Save to ▾
Show answer
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.
04

Write a simple escrow contract where a buyer deposits and releases payment to a seller.

Save to ▾
Show answer
pragma solidity ^0.8.24; contract Escrow { address public immutable buyer; address payable public immutable seller; bool public released; constructor(address payable _seller) payable { buyer = msg.sender; seller = _seller; } function release() external { require(msg.sender == buyer, 'only buyer'); require(!released, 'done'); released = true; (bool ok, ) = seller.call{value: address(this).balance}(''); require(ok, 'transfer failed'); } } State is updated before the external call to follow checks-effects-interactions.
05

Tell me about a time you explained blockchain to a non-technical stakeholder.

Save to ▾
Show answer
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.
06

Write a Foundry unit test and a fuzz test for a contract.

Save to ▾
Show answer
Foundry tests are Solidity contracts; functions starting with test run as tests, and parameters make them fuzz tests. import {Test} from 'forge-std/Test.sol'; import {Vault} from '../src/Vault.sol'; contract VaultTest is Test { Vault v; function setUp() public { v = new Vault(); } function testDeposit() public { v.deposit{value: 1 ether}(); assertEq(v.balanceOf(address(this)), 1 ether); } function testFuzzDeposit(uint96 amt) public { vm.assume(amt > 0); vm.deal(address(this), amt); v.deposit{value: amt}(); assertEq(address(v).balance, amt); } } Run with forge test -vvv.
07

What are front-running and sandwich attacks, and how do you mitigate them?

Save to ▾
Show answer
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.
08

How do you compute a function selector and decode calldata with cast?

Save to ▾
Show answer
cast handles ABI work from the command line. # Function selector cast sig 'transfer(address,uint256)' # 0xa9059cbb # Encode calldata cast calldata 'transfer(address,uint256)' 0xAbc... 1000000 # Decode calldata from a transaction cast 4byte-decode 0xa9059cbb000000... # Decode with a known signature cast decode-calldata 'transfer(address,uint256)' 0xa9059cbb... This is useful when checking what a wallet is really asking you to sign.
09

What are the main components of Hyperledger Fabric?

Save to ▾
Show answer
Hyperledger Fabric is a permissioned enterprise framework. Peers hold the ledger and run chaincode (smart contracts written in Go, Java or JavaScript). Orderers, usually using Raft, sequence transactions into blocks. A Membership Service Provider issues identities through certificate authorities. Channels give separate private ledgers to subsets of members, and private data collections hide data inside a channel. Fabric uses an execute-order-validate flow with endorsement policies instead of mining.
10

What is a signature replay attack and how do you prevent it?

Save to ▾
Show answer
If a contract accepts a signed message to perform an action, an attacker can resubmit the same signature to repeat it, or replay it on another chain or another contract using the same code. Prevent it by including a per-user nonce that increments on use, a deadline, the chain ID and the verifying contract address in the signed data. EIP-712 typed data with a domain separator gives a standard way to include these fields.
11

You need the same contract at the same address on five chains. How do you do it?

Save to ▾
Show answer
Use CREATE2 through a deterministic deployment factory that already exists at the same address on all those chains. Keep the init code identical: same compiler version, optimiser settings, constructor arguments and metadata. Pick a salt, compute the expected address off-chain, then deploy on each chain. Foundry scripts support this by passing a salt. Avoid constructor arguments that differ per chain, or move chain-specific settings into an initialiser restricted to the deployer.
12

Your team is preparing a contract for an external audit. What do you do beforehand?

Save to ▾
Show answer
Freeze the code at a commit and stop adding features. Write clear documentation: architecture, roles, trust assumptions, invariants and known risks. Reach high test coverage including fuzz and invariant tests, and run Slither and fix its findings. Remove dead code, add NatSpec comments, and make the build reproducible. Share a scope list and a walkthrough call. A clean, well-documented codebase lets auditors spend their limited time on deep logic bugs.
13

Describe a time you disagreed with a teammate about architecture.

Save to ▾
Show answer
Situation: a teammate wanted our indexer to read every event directly from the node at request time. Task: I believed it would not scale. Action: instead of arguing, I proposed a one-day spike, measured both approaches with realistic data, and shared numbers showing the database-backed indexer answered queries 40 times faster. Result: the team chose the indexer, my teammate led its reorg handling, and we agreed to settle future debates with quick experiments.
14

What is double spending and how does a blockchain prevent it?

Save to ▾
Show answer
Double spending is trying to spend the same digital money twice, for example sending the same coins to two merchants. A blockchain prevents it by keeping one shared ordering of transactions agreed through consensus. Once a transaction is included in a block, any conflicting transaction that spends the same funds is rejected as invalid. Merchants wait for several confirmations so that the chance of the block being replaced in a reorg becomes negligible.
15

Your RPC provider starts rate-limiting and the dApp breaks during peak traffic. What do you do?

Save to ▾
Show answer
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.
16

Design a blockchain solution for farm-to-store supply chain traceability. What goes on-chain?

Save to ▾
Show answer
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.
17

What transaction types exist on Ethereum today?

Save to ▾
Show answer
Type 0 is the legacy transaction with a single gasPrice. Type 1, from EIP-2930, adds an access list. Type 2, from EIP-1559, uses maxFeePerGas and maxPriorityFeePerGas and is the default in wallets. Type 3, from EIP-4844, carries blobs for rollup data. Type 4, from EIP-7702 in the Pectra upgrade of May 2025, lets an EOA set code delegation through a signed authorisation list, enabling batching and sponsored gas for normal wallets.
18

An auditor flags that a single owner key can mint tokens and change fees. How do you address it?

Save to ▾
Show answer
This is centralisation risk: if the key is compromised or misused, users lose funds. Move ownership to a multisig with signers on separate devices, add a timelock so users can see and react to changes, set hard-coded bounds such as a maximum fee, and remove powers that are not needed, like unlimited minting. Use role-based access instead of one all-powerful owner, and document the remaining admin powers publicly.
19

What is the difference between optimistic rollups and zk-rollups?

Save to ▾
Show answer
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.
20

What is the difference between a soft fork and a hard fork?

Save to ▾
Show answer
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.
21

What is the difference between require, revert, assert and custom errors?

Save to ▾
Show answer
require(condition, message) validates inputs and conditions, reverting with a message if false. revert stops execution explicitly and is often used with custom errors, such as error InsufficientBalance(uint256 need, uint256 have); revert InsufficientBalance(x, y); which are cheaper than strings and carry data. assert checks invariants that should never fail; a failure signals a bug and raises a Panic. Since Solidity 0.8.26 you can also pass custom errors to require.
22

Compare interfaces, abstract contracts and libraries.

Save to ▾
Show answer
An interface only declares external functions, events and errors, with no state or implementation; it is used to call other contracts, like IERC20. An abstract contract can have state and implemented functions but leaves at least one unimplemented or is marked abstract, so it cannot be deployed alone. A library holds reusable functions without state; internal library functions are inlined, while external ones are deployed once and called via delegatecall. Libraries can attach to types with using for.
23

What is the difference between SHA-256 and Keccak-256?

Save to ▾
Show answer
SHA-256 is from the SHA-2 family and uses a Merkle-Damgard construction; Bitcoin uses double SHA-256 for block hashes and transaction IDs. Keccak-256 is based on the sponge construction and is what Ethereum uses for addresses, function selectors, event topics and storage slots. Ethereum's Keccak-256 is the original Keccak submission and differs from the final NIST SHA3-256 in padding, so the two give different outputs for the same input.
24

What is a mempool?

Save to ▾
Show answer
The mempool is each node's waiting area for valid transactions that have been broadcast but not yet included in a block. Block producers usually pick transactions paying the highest fees or priority tips. Every node has its own mempool, so contents can differ slightly. Because pending transactions are public, bots can watch the mempool and front-run trades, which is why private transaction relays and order-flow auctions are used for sensitive transactions.
25

Compare multisig wallets and MPC wallets.

Save to ▾
Show answer
A multisig wallet is a smart contract, such as a Safe, that needs M of N owner signatures to execute a transaction; rules are visible on-chain and easy to audit, but every action costs extra gas and works per chain. An MPC wallet splits one private key into shares held by different parties who jointly produce a normal signature; it looks like a regular address, works on any chain and allows key rotation, but the security depends on the off-chain implementation.
26

What is the difference between receive and fallback functions?

Save to ▾
Show answer
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.
27

What is a Layer 2 and why is it needed?

Save to ▾
Show answer
A Layer 2 is a network that executes transactions off the main chain and inherits security from it by posting data or proofs back to Layer 1. Ethereum Layer 1 handles only around 15 to 30 transactions per second at higher fees, so L2s batch thousands of transactions into one L1 submission, cutting fees to cents or less. Rollups are the main type. Users bridge assets from L1 to the L2 and can withdraw back.
28

Your target users in India have never used crypto wallets. How do you design onboarding?

Save to ▾
Show answer
Hide crypto complexity. Offer login with phone or email using embedded or smart contract wallets, so no seed phrase is needed at first. Sponsor gas with a paymaster so users need no tokens. Show amounts in rupees and plain language, support regional languages, and explain actions in simple terms. Provide account recovery via passkeys or guardians, and let advanced users export to self-custody later. Ensure KYC and tax requirements are clear where money is involved.
29

How do you get the latest block number from an Ethereum node using JSON-RPC?

Save to ▾
Show answer
Send a JSON-RPC POST request to the node or provider URL. The result is a hex string that you convert to decimal. curl -s -X POST https://rpc.example.org \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' # Response: {"jsonrpc":"2.0","id":1,"result":"0x15d3a1c"} # In Python: int('0x15d3a1c', 16) Other common methods are eth_getBalance, eth_call and eth_getTransactionReceipt.
30

You are launching a 10,000-piece NFT collection and fear gas wars and bots. How do you design the mint?

Save to ▾
Show answer
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.
31

Write a Python function that computes a Merkle root from a list of transactions.

Save to ▾
Show answer
Hash leaves, then hash pairs until one remains, duplicating the last hash when a level is odd (Bitcoin style). import hashlib def h(b): return hashlib.sha256(b).digest() def merkle_root(txs): level = [h(t.encode()) for t in txs] while len(level) > 1: if len(level) % 2: level.append(level[-1]) level = [h(level[i] + level[i+1]) for i in range(0, len(level), 2)] return level[0].hex() print(merkle_root(['tx1', 'tx2', 'tx3']))
32

Show how to sign and verify a message with ethers.js.

Save to ▾
Show answer
With ethers v6, a wallet signs using EIP-191 personal sign, and verifyMessage recovers the address. import { Wallet, verifyMessage } from 'ethers'; const wallet = Wallet.createRandom(); const message = 'Login nonce: 48213'; const signature = await wallet.signMessage(message); const recovered = verifyMessage(message, signature); console.log(recovered === wallet.address); // true This pattern powers Sign-In with Ethereum; the server issues a fresh nonce each time to stop replay.
33

What are common access control vulnerabilities?

Save to ▾
Show answer
Typical bugs include missing onlyOwner or role checks on sensitive functions such as mint, withdraw or setOracle, initialiser functions in upgradeable contracts that anyone can call, misconfigured roles, and a single EOA owning critical powers. Use OpenZeppelin Ownable2Step or AccessControl, give each role the minimum rights, protect admin actions with a multisig and timelock, and write tests confirming that every privileged function reverts for unauthorised callers.
34

Why do you want to work in DeFi, given its risks and volatility?

Save to ▾
Show answer
I am drawn to DeFi because it turns financial products into open, auditable code, and that combination of finance and engineering motivates me. I understand the risks: hacks, market crashes and regulatory change. That is why I have focused on security, testing and risk thinking, not just writing contracts. I see volatility as a reason to build carefully. I want to work on a team that values audits, monitoring and user protection.
35

How do you store an NFT image on IPFS and use it in your contract?

Save to ▾
Show answer
Upload the image to IPFS using a node or a pinning service, which returns a CID. Create a metadata JSON file whose image field is ipfs://<imageCID>, then upload the metadata folder to get a folder CID. Set the contract's base URI to ipfs://<folderCID>/ so tokenURI(5) resolves to the file for token 5. Pin the content with more than one provider, and use a gateway URL only for display in the front-end.
36

How do you verify a signed message inside a Solidity contract?

Save to ▾
Show answer
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.
37

Users complain they must pay gas to approve tokens before every trade. How can signatures help?

Save to ▾
Show answer
Use off-chain signed approvals. With EIP-2612 permit, the user signs a typed EIP-712 message granting an allowance, and the dApp submits it with the trade in one transaction, so no separate approve call is needed. For tokens without permit, Permit2-style contracts give the same experience after one approval. EIP-712 shows readable fields in the wallet, reducing phishing risk. Always include a nonce, deadline, chain ID and verifying contract to prevent replays.
38

How do you manage deployer private keys in a CI/CD pipeline?

Save to ▾
Show answer
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.
39

Write the core reward-per-token logic for a staking rewards contract.

Save to ▾
Show answer
uint256 public rewardRate; // tokens per second uint256 public rewardPerTokenStored; uint256 public lastUpdate; uint256 public totalStaked; mapping(address => uint256) public paid; mapping(address => uint256) public rewards; mapping(address => uint256) public staked; function rewardPerToken() public view returns (uint256) { if (totalStaked == 0) return rewardPerTokenStored; return rewardPerTokenStored + (block.timestamp - lastUpdate) * rewardRate * 1e18 / totalStaked; } modifier updateReward(address a) { rewardPerTokenStored = rewardPerToken(); lastUpdate = block.timestamp; rewards[a] += staked[a] * (rewardPerTokenStored - paid[a]) / 1e18; paid[a] = rewardPerTokenStored; _; }
40

Design token vesting for team members and early investors.

Save to ▾
Show answer
Use a vesting contract that holds allocated tokens and releases them on a schedule, typically a one-year cliff followed by monthly or linear vesting over two to four years. OpenZeppelin VestingWallet gives linear vesting per beneficiary; add a cliff and an owner-controlled revoke for employees who leave, returning unvested tokens. Make schedules public on-chain for transparency, and avoid admin functions that could release tokens early, as that erodes investor trust.

Frequently asked questions

What is asked in Blockchain interviews for 3 years of experience?

With three years, you are treated as a strong individual contributor. Expect DeFi design questions, AMM and lending maths, oracle risks, fuzz and invariant testing, and system design such as a staking platform or bridge. You should discuss trade-offs clearly, mentor juniors, and show how you made protocols safer through testing, monitoring and audit remediation.

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 3 years of experience?

Focus first on DeFi protocol design, Invariant testing, Oracle and MEV risks, System design.