Blockchain Technology Smart Contracts and dApps 4 — Questions and Answers
Question 1: What is 'flash loan' arbitrage in DeFi?
- Borrowing tokens with collateral locked for 24 hours for low interest
- Borrowing and repaying assets within a single transaction to profit from price differences (Correct answer)
- A governance mechanism to fund protocol upgrades instantly
- A cross-chain bridge that transfers value in one block
Correct answer: Borrowing and repaying assets within a single transaction to profit from price differences
Flash loans allow uncollateralized borrowing within one atomic transaction; if not repaid with fees in the same block, the entire transaction reverts.
Question 2: Which tool is most commonly used to test Solidity smart contracts locally?
- Remix IDE online compiler only
- Hardhat or Foundry local development frameworks (Correct answer)
- MetaMask developer mode
- Etherscan contract verifier
Correct answer: Hardhat or Foundry local development frameworks
Hardhat and Foundry provide local Ethereum node emulation, test runners, and debugging tools for smart contract development and testing.
Question 3: What is 'front-running' in the context of Ethereum smart contracts?
- Deploying a contract before a competitor
- Inserting a transaction ahead of a known pending transaction to profit from it (Correct answer)
- Calling a contract function with priority gas pricing
- Racing to claim a limited NFT mint before others
Correct answer: Inserting a transaction ahead of a known pending transaction to profit from it
Front-running occurs when a miner or bot spots a profitable pending transaction in the mempool and submits their own transaction with higher gas to execute first.
Question 4: In Solidity, what does the 'modifier' keyword allow developers to do?
- Override inherited functions from parent contracts
- Reuse pre- and post-condition checks across multiple functions (Correct answer)
- Declare immutable state variables
- Define custom error types with parameters
Correct answer: Reuse pre- and post-condition checks across multiple functions
Modifiers wrap functions with reusable logic (e.g., access checks), using the '_' placeholder to indicate where the modified function's body executes.
Question 5: What is the 'Merkle tree' used for in the context of smart contracts and NFT whitelists?
- Generating random numbers for NFT trait assignment
- Efficiently verifying membership in a large set without storing the full list on-chain (Correct answer)
- Encoding token URIs for metadata storage
- Computing gas fees for batch minting
Correct answer: Efficiently verifying membership in a large set without storing the full list on-chain
A Merkle tree allows a contract to verify whether an address is in a whitelist by checking a small proof against a root hash stored on-chain, saving gas.
Question 6: What is 'slippage tolerance' in a DEX swap transaction?
- The maximum gas fee increase accepted before a swap is rejected
- The maximum acceptable price change between submitting and executing a swap (Correct answer)
- The percentage fee charged by liquidity providers per trade
- The time limit before an unconfirmed transaction is dropped
Correct answer: The maximum acceptable price change between submitting and executing a swap
Slippage tolerance sets a floor on the minimum tokens received; if market movement causes the output to fall below it, the transaction reverts.
Question 7: Which Ethereum scaling solution uses fraud proofs and requires a challenge period for withdrawals?
- ZK-Rollup
- Plasma Chain
- Optimistic Rollup (Correct answer)
- State Channel
Correct answer: Optimistic Rollup
Optimistic Rollups assume transactions are valid by default and rely on fraud proofs during a 7-day challenge window before finality on L1.
What is 'flash loan' arbitrage in DeFi?