Skip to content

DeFi, Tokens and NFTs Interview Questions for Blockchain

25 DeFi, Tokens and NFTs questions with answers for blockchain roles — 8 easy, 9 medium, 8 hard.

About DeFi, Tokens and NFTs

Understand the token standards ERC-20, ERC-721, ERC-1155 and ERC-4626, and the maths behind automated market makers, impermanent loss, lending health factors and staking rewards. Study stablecoins, oracles, governance attacks, NFT minting design and tokenisation of real-world assets within Indian regulation and tax rules.

Sheet progressStart 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

What is DeFi?

Save to ▾
Show answer
DeFi, decentralised finance, means financial services such as trading, lending, borrowing, stablecoins and derivatives built as smart contracts on public blockchains. Anyone with a wallet can use them without a bank account or approval, contracts are transparent, and protocols can be combined like building blocks. Examples are automated market maker exchanges, overcollateralised lending markets and liquid staking. The risks are smart contract bugs, oracle failures, volatile collateral and unclear regulation.
02

Compare ERC-20, ERC-721 and ERC-1155 tokens.

Save to ▾
Show answer
ERC-20 defines fungible tokens where every unit is identical, with functions like transfer, approve, transferFrom and balanceOf; used for currencies, stablecoins and governance tokens. ERC-721 defines non-fungible tokens where each tokenId is unique, used for NFTs like art, tickets or certificates. ERC-1155 is a multi-token standard where one contract manages many token types, fungible or not, with batch transfers; it is popular in games where items have quantities.
03

What types of stablecoins exist?

Save to ▾
Show answer
Fiat-backed stablecoins hold cash and short-term government bonds off-chain, one dollar per token, and depend on the issuer's audits and redemptions. Crypto-collateralised stablecoins are minted against overcollateralised crypto in smart contracts, such as vaults requiring 150 percent collateral. Algorithmic stablecoins try to hold the peg with supply rules and incentives; several have collapsed, the most famous in 2022. Choose based on trust model, liquidity, transparency and regulatory status.
04

Write a basic ERC-721 NFT contract using OpenZeppelin.

Save to ▾
Show answer
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {ERC721} from '@openzeppelin/contracts/token/ERC721/ERC721.sol'; import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; contract CertificateNFT is ERC721, Ownable { uint256 public nextId; string private baseURI; constructor(string memory uri) ERC721('Course Cert', 'CERT') Ownable(msg.sender) { baseURI = uri; } function mint(address to) external onlyOwner { _safeMint(to, nextId++); } function _baseURI() internal view override returns (string memory) { return baseURI; } }
05

How do you approve and transfer ERC-20 tokens from a script with ethers.js?

Save to ▾
Show answer
import { Contract, parseUnits } from 'ethers'; const abi = [ 'function approve(address spender, uint256 amount) returns (bool)', 'function decimals() view returns (uint8)', 'function allowance(address owner, address spender) view returns (uint256)' ]; const token = new Contract(TOKEN_ADDRESS, abi, signer); const dec = await token.decimals(); const amount = parseUnits('25', dec); const tx = await token.approve(SPENDER, amount); await tx.wait(); console.log(await token.allowance(signer.address, SPENDER)); The spender contract then calls transferFrom to pull exactly that amount.
06

How should NFT metadata and tokenURI be structured?

Save to ▾
Show answer
tokenURI(id) returns a URI, usually ipfs://<CID>/<id>.json, pointing to JSON that marketplaces read: { "name": "Course Certificate #12", "description": "Completed Blockchain Developer course", "image": "ipfs://bafy.../12.png", "attributes": [ { "trait_type": "Grade", "value": "A" }, { "trait_type": "Year", "value": 2026 } ] } Store images and JSON on IPFS or Arweave rather than a normal server, so metadata cannot silently change or disappear.
07

A retail brand wants to give customers loyalty points as blockchain tokens. How would you design it?

Save to ▾
Show answer
Keep it simple for non-crypto users. Use a low-fee Layer 2 or a permissioned chain, and create wallets automatically with account abstraction or embedded wallets linked to phone login, so customers never handle seed phrases. Sponsor gas through a paymaster. Make points a non-transferable or restricted ERC-20 if resale is not intended, to avoid VDA tax and securities issues. Keep customer data off-chain and show points in the brand's normal app.
08

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.
09

How does a constant product automated market maker work, and what is impermanent loss?

Save to ▾
Show answer
A constant product AMM holds two tokens with reserves x and y and keeps x times y equal to k. A trader adds one token and removes the other so that k stays constant after fees, which makes price equal to the reserve ratio and rise with trade size. Liquidity providers earn fees, but when prices move, arbitrage rebalances the pool, leaving them worse off than simply holding; that gap is impermanent loss.
10

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.
11

How do you calculate a borrower's health factor in a lending protocol?

Save to ▾
Show answer
Health factor = (sum of collateral value x liquidation threshold) / total debt value. Below 1, the position can be liquidated. Example: collateral 10 ETH at 3,000 dollars = 30,000 dollars, liquidation threshold 80 percent, debt 18,000 dollars of stablecoins. HF = (30,000 x 0.80) / 18,000 = 1.33. If ETH falls to 2,250, collateral is 22,500, so HF = 18,000 / 18,000 = 1.0 and liquidation begins. Users raise HF by repaying debt or adding collateral.
12

How do you read a Chainlink price feed in Solidity safely?

Save to ▾
Show answer
import {AggregatorV3Interface} from '@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol'; AggregatorV3Interface public feed; uint256 constant MAX_DELAY = 1 hours; function getPrice() public view returns (uint256) { (, int256 answer, , uint256 updatedAt, ) = feed.latestRoundData(); require(answer > 0, 'bad price'); require(block.timestamp - updatedAt <= MAX_DELAY, 'stale price'); return uint256(answer); // scale using feed.decimals(), often 8 } Always check staleness, sign and decimals; on L2s also check the sequencer uptime feed.
13

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.
14

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.
15

Users complain they received far fewer tokens than expected on large swaps. What is happening and how do you help?

Save to ▾
Show answer
Large trades in shallow pools suffer price impact, and wide slippage settings let sandwich bots extract extra value. Show the expected output, price impact and minimum received before confirming. Set sensible default slippage, such as 0.5 percent for major pairs, and warn when impact is high. Use a router or aggregator that splits trades across pools, and offer private transaction submission so bots cannot see the swap in the public mempool.
16

A user lost funds on our DeFi app due to their own mistake and is angry. How would you handle it?

Save to ▾
Show answer
Situation: a user sent tokens to the contract address directly instead of using deposit, and they were stuck. Task: support him honestly. Action: I listened, explained calmly what happened without blaming him, checked whether a recovery function existed, and escalated to the team. We had a rescue function for stray tokens behind the multisig, so after verification we returned them. Result: he thanked us publicly, and we added a front-end warning.
17

Tell me about working with product, legal or compliance teams on a blockchain feature.

Save to ▾
Show answer
Situation: we planned a token reward feature for Indian users, and legal raised VDA tax and securities concerns. Task: as tech lead I had to find a compliant design. Action: I ran workshops to understand their constraints, proposed non-transferable points that convert to vouchers, and documented the data flow for compliance. Result: we launched a month later than planned but with sign-off from all teams, and avoided a costly redesign after launch.
18

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; _; }
19

How do you build a tokenised vault using ERC-4626?

Save to ▾
Show answer
ERC-4626 standardises yield vaults: users deposit an asset and receive shares, and share price rises as the vault earns yield. import {ERC4626} from '@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol'; import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; contract YieldVault is ERC4626 { constructor(IERC20 asset_) ERC20('Vault Share', 'vSHR') ERC4626(asset_) {} function totalAssets() public view override returns (uint256) { return IERC20(asset()).balanceOf(address(this)); // plus deployed funds } } OpenZeppelin uses virtual shares to defend against the first-depositor inflation attack.
20

Calculate impermanent loss when one token's price doubles.

Save to ▾
Show answer
Formula: IL = 2 x sqrt(r) / (1 + r) - 1, where r is the price ratio change. For r = 2: sqrt(2) = 1.414, so IL = 2 x 1.414 / 3 - 1 = -0.057, about 5.7 percent. Example: deposit 1 ETH plus 3,000 USDC when ETH is 3,000 (6,000 dollars). ETH goes to 6,000. Holding would be 9,000 dollars; the pool position is worth about 8,485. Fees earned must exceed the 515 dollar gap for providing liquidity to beat holding.
21

A stablecoin used as collateral in your protocol loses its peg. How do you respond?

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

A sharp market fall causes cascading liquidations in your lending protocol and bad debt. How do you design against it?

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

A client in India wants to tokenise real estate for fractional ownership. What do you consider?

Save to ▾
Show answer
Regulation comes first: fractional real estate is likely a security or collective investment, so SEBI rules, including those for fractional ownership platforms, apply, and crypto-like tokens are taxed as virtual digital assets at 30 percent with 1 percent TDS. Use a permissioned token with KYC-gated transfers, such as ERC-3643, and a legal SPV that holds the property. Keep title documents off-chain, put hashes on-chain, and plan for rent distribution, transfer restrictions and recovery.
24

A fee-on-transfer token breaks your DEX's accounting. What happened and how do you fix it?

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

An attacker borrows governance tokens with a flash loan to pass a malicious DAO proposal. How do you prevent it?

Save to ▾
Show answer
Use snapshot-based voting power: count votes from token balances at a past block, as ERC20Votes does, so tokens acquired in the same transaction have no weight. Add a voting delay before voting starts, a quorum, and a timelock between approval and execution so the community can react or a guardian can veto. Require a proposal threshold, and keep critical actions such as treasury transfers behind additional safeguards like spending limits.

Frequently asked questions

How important is DeFi, Tokens and NFTs in Blockchain interviews?

Understand the token standards ERC-20, ERC-721, ERC-1155 and ERC-4626, and the maths behind automated market makers, impermanent loss, lending health factors and staking rewards. Study stablecoins, oracles, governance attacks, NFT minting design and tokenisation of real-world assets within Indian regulation and tax rules.

How should I use the DeFi, Tokens and NFTs sheet?

Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.