




















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















































































Question 1. Which Ethereum network is primarily used for testing smart contracts without spending real ETH? A) Mainnet B) Sepolia C) Polygon D) Binance Smart Chain Answer: B Explanation: Sepolia is an official Ethereum testnet that provides a safe environment for developers to test contracts without using real Ether. Question 2. In the EVM, which component holds temporary values during execution of a transaction? A) Storage B) Stack C) Memory D) Calldata Answer: B Explanation: The EVM stack is a LIFO data structure used for intermediate values during opcode execution. Question 3. How is an Externally Owned Account (EOA) address derived? A) From the contract bytecode hash B) From the public key of the account holder C) Randomly generated by the network D) From the transaction nonce Answer: B
Explanation: An EOA address is the last 20 bytes of the Keccak‑256 hash of the account’s public key. Question 4. Under EIP‑1559, what does the baseFee represent? A) The maximum fee a user can set B) A fee burned by the protocol that changes each block C) The tip paid directly to miners D) The fixed network fee for all transactions Answer: B Explanation: baseFee is a protocol‑determined fee that is burned and automatically adjusts based on block demand. Question 5. Which client is responsible for block proposal and attestation in post‑Merge Ethereum? A) Geth B) Nethermind C) Prysm D) Besu Answer: C Explanation: Prysm is a consensus client that participates in the Proof‑of‑Stake consensus layer, handling block proposals and attestations. Question 6. Which Solidity type is stored directly in the stack and has a fixed size of 32 bytes? A) bytes B) string
B) tx.origin C) block.coinbase D) address(this) Answer: A Explanation: msg.sender is the immediate caller of the current function, which may be an EOA or contract. Question 10. Which low‑level call bypasses Solidity’s return data size checks? A) call B) delegatecall C) staticcall D) callcode Answer: A Explanation: call forwards all remaining gas and does not enforce return data size, requiring manual checks. Question 11. Which Solidity construct is used to share reusable code without inheritance? A) Interface B) Abstract contract C) Library D) Modifier Answer: C Explanation: Libraries contain stateless functions that can be called directly or via using for. Question 12. Which statement reverts the transaction with a custom error message?
A) require(condition, "msg") B) assert(condition) C) revert("msg") D) Both A and C Answer: D Explanation: Both require (with a message) and revert with a string abort execution and return the message. Question 13. The Checks‑Effects‑Interactions pattern helps prevent which vulnerability? A) Integer overflow B) Reentrancy C) Front‑running D) Gas limit attacks Answer: B Explanation: By updating state before external calls, the pattern mitigates reentrancy exploits. Question 14. Which Solidity version introduced built‑in overflow/underflow checks? A) 0.6. B) 0.7. C) 0.8. D) 0.5. Answer: C Explanation: Starting with 0.8.0, arithmetic operations automatically revert on overflow/underflow.
Explanation: Pull payments require the beneficiary to call a withdraw function, reducing reentrancy risk. Question 18. Which static analysis tool is specifically designed to detect reentrancy and unchecked low‑level calls? A) Slither B) Mythril C) Echidna D) Truffle Answer: B Explanation: Mythril performs symbolic execution to uncover vulnerabilities such as reentrancy and unsafe low‑level calls. Question 19. Which Hardhat task compiles Solidity contracts? A) hardhat test B) hardhat run C) hardhat compile D) hardhat deploy Answer: C Explanation: hardhat compile processes the contracts and generates artifacts. Question 20. In Remix IDE, which tab allows you to debug a transaction step‑by‑step? A) Solidity Compiler B) Deploy & Run Transactions C) Debugger D) Files
Answer: C Explanation: The Debugger tab provides a UI to step through transaction execution. Question 21. Which JavaScript library provides a provider abstraction that works with MetaMask and Infura? A) web3.js B) ethers.js C) Truffle Contract D) OpenZeppelin SDK Answer: B Explanation: ethers.js includes Web3Provider that can wrap MetaMask or remote JSON‑RPC endpoints like Infura. Question 22. Which JSON‑RPC method retrieves the current block number? A) eth_getBalance B) eth_blockNumber C) eth_getBlockByNumber D) net_version Answer: B Explanation: eth_blockNumber returns the latest block number on the chain. Question 23. An event in Solidity is primarily used for: A) Storing data on‑chain permanently B) Emitting logs that off‑chain listeners can filter C) Triggering other contracts automatically
A) balanceOf B) allowance C) totalSupply D) decimals Answer: B Explanation: allowance(owner, spender) reports the approved amount left for spender. Question 27. Which ERC‑721 function is responsible for returning the metadata URI of a token? A) tokenURI(uint256 tokenId) B) uri(uint256 tokenId) C) metadata(uint256 tokenId) D) getURI(uint256 tokenId) Answer: A Explanation: tokenURI is defined in ERC‑721 to retrieve the token’s metadata location. Question 28. Which OpenZeppelin contract provides a circuit‑breaker mechanism? A) Pausable B) ReentrancyGuard C) AccessControl D) Ownable Answer: A Explanation: Pausable adds whenNotPaused and whenPaused modifiers to halt contract functionality.
Question 29. In Solidity, what does the immutable keyword indicate? A) Variable can never be changed after deployment B) Variable can be changed only by the owner C) Variable is stored in calldata D) Variable is a constant compile‑time value Answer: A Explanation: immutable variables are assigned once in the constructor and then become read‑only. Question 30. Which opcode pushes the current block timestamp onto the stack? A) TIMESTAMP B) BLOCKTIMESTAMP C) NOW D) TIME Answer: A Explanation: The EVM opcode TIMESTAMP (0x42) pushes block.timestamp onto the stack. Question 31. What is the primary purpose of the selfdestruct opcode? A) Freeze contract execution B) Delete contract code and send remaining Ether to a beneficiary C) Pause the contract D) Upgrade the contract logic Answer: B Explanation: selfdestruct(address payable) removes the contract from the state and transfers its balance.
Explanation: All mapping entries default to the zero value of the value type; for uint it is 0. Question 35. Which Hardhat plugin enables automatic deployment to a network using a deploy script? A) hardhat-deploy B) hardhat-ethers C) hardhat-gas-reporter D) hardhat-truffle5 Answer: A Explanation: hardhat-deploy provides a structured deployment workflow with scripts. Question 36. Which Solidity statement is the most gas‑efficient for clearing a dynamic array? A) delete arr; B) arr = new uint[](0); C) while(arr.length > 0) arr.pop(); D) arr.length = 0; Answer: D Explanation: Directly setting arr.length = 0 clears the array without iterating, saving gas. Question 37. Which function signature is required for a contract to be considered ERC‑ 1155 compliant? A) function safeTransferFrom(address, address, uint256, uint256, bytes calldata) external; B) function transfer(address, uint256) external; C) function mint(address, uint256) external; D) function approve(address, uint256) external;
Answer: A Explanation: ERC‑1155 defines safeTransferFrom (and safeBatchTransferFrom) with the shown signature. Question 38. Which tool generates Solidity coverage reports from Hardhat tests? A) solidity-coverage B) nyc C) coveralls D) truffle-coverage Answer: A Explanation: The solidity-coverage plugin instruments contracts and reports line‑by‑line coverage. Question 39. In ethers.js, which method creates a contract instance without connecting to a signer? A) new ethers.Contract(address, abi, provider) B) ethers.getContractFactory(name) C) ethers.ContractFactory.deploy() D) ethers.getSigner() Answer: A Explanation: Passing a provider (instead of a signer) creates a read‑only contract instance. Question 40. Which of the following best describes a DAO’s governance token utility? A) Provides staking rewards only B) Grants voting power proportional to token holdings C) Acts as a stablecoin for transactions
B) It can be overridden in derived contracts C) It cannot be overridden D) It makes the function immutable after deployment Answer: B Explanation: virtual indicates that a function may be overridden by child contracts. Question 44. Which of the following is a correct way to convert a uint256 to a bytes32 in Solidity? A) bytes32(x) B) bytes32(uint256(x)) C) abi.encodePacked(x) D) keccak256(abi.encodePacked(x)) Answer: A Explanation: Simple casting bytes32(x) truncates or pads the uint256 to 32 bytes. Question 45. Which of the following is NOT a built‑in Solidity unit? A) wei B) gwei C) ether D) finney Answer: D Explanation: Solidity supports wei, gwei, ether, szabo, and finney is not a built‑in unit (the correct unit is finney? Actually Solidity includes finney. Wait, Solidity includes finney. The non‑existent unit is cents. Let's correct: The incorrect option should be something else. Let's adjust:
Revised Question 45. Which of the following is NOT a built‑in Solidity unit? A) wei B) gwei C) ether D) bit Answer: D Explanation: bit is not a Solidity denomination; the language defines wei, gwei, ether, szabo, and finney. Question 46. Which consensus mechanism does Ethereum use after the Merge? A) Proof‑of‑Work (PoW) B) Proof‑of‑Authority (PoA) C) Proof‑of‑Stake (PoS) D) Delegated Proof‑of‑Stake (DPoS) Answer: C Explanation: The Merge transitioned Ethereum from PoW to PoS. Question 47. In a Solidity struct, which storage location does it default to when declared inside a contract? A) Memory B) Calldata C) Storage D) Stack Answer: C Explanation: State‑level structs are stored in contract storage.
Answer: A Explanation: getGasPrice() returns the suggested gas price in wei. Question 51. Which of the following is a recommended practice when using delegatecall? A) Call untrusted contracts directly B) Ensure the called contract’s storage layout matches the caller’s C) Use delegatecall for transferring Ether D) Avoid checking return values Answer: B Explanation: delegatecall executes code in the context of the calling contract, so storage layout must align to avoid corruption. Question 52. What does the tx.gasprice global variable represent? A) The gas price set by the transaction sender B) The average gas price of the last block C) The base fee of the current block D) The max priority fee the miner can collect Answer: A Explanation: tx.gasprice is the gas price the sender specified (or the effective price after EIP‑1559). Question 53. Which Solidity error type should be used for conditions that should never be false, and will consume all remaining gas when triggered? A) require B) revert C) assert
D) error Answer: C Explanation: assert is meant for internal invariants; failing it triggers a panic and consumes all gas. Question 54. Which of the following is NOT a feature of the OpenZeppelin AccessControl contract? A) Role‑based permissioning B) Enumerating role members C) Ownership transfer D) Admin role hierarchy Answer: C Explanation: AccessControl does not provide an owner concept; ownership transfer is handled by Ownable. Question 55. In the context of Chainlink oracles, what does the fulfillRandomWords function do? A) Requests random numbers from the VRF coordinator B) Receives and stores the random numbers generated off‑chain C) Validates the signature of the oracle response D) Pays the oracle for its service Answer: B Explanation: fulfillRandomWords is the callback that the VRF coordinator calls to deliver random numbers to the consumer contract. Question 56. Which opcode consumes the most gas when executed?