




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This certification exam preparation focuses on developing smart contracts using Solidity. Topics include Ethereum fundamentals, Solidity syntax, contract security, testing, deployment, and optimization. Learners gain blockchain development expertise required for certification exams and professional Solidity developer roles.
Typology: Exams
1 / 104
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. What is the primary purpose of a consensus mechanism in a blockchain? A) To encrypt transaction data B) To ensure all nodes agree on the state of the ledger C) To store smart contract code D) To provide a user interface for wallets Answer: B Explanation: Consensus mechanisms like PoW or PoS enable distributed nodes to reach agreement on the correct ledger state without a central authority.
Question 2. Which statement correctly distinguishes Proof of Work (PoW) from Proof of Stake (PoS)? A) PoW selects validators based on token holdings, PoS uses computational puzzles. B) PoW requires solving cryptographic puzzles, PoS selects validators proportionally to stake. C) PoW is used only in private blockchains, PoS only in public blockchains. D) PoW consumes no electricity, PoS is energy-intensive. Answer: B Explanation: PoW validators (miners) solve hash puzzles, while PoS validators are chosen based on the amount of cryptocurrency they lock up as stake.
Question 3. In Ethereum, what does “gas” represent? A) The amount of Ether held by an account B) The computational work required to execute an operation C) The size of a block in bytes D) The network latency between nodes Answer: B Explanation: Gas quantifies the computational resources needed for a transaction or contract execution; users pay gas in Ether.
Question 4. Which component of an Ethereum transaction determines how much the sender is willing to pay per unit of gas? A) Gas limit B) Gas price C) Nonce D) Data field Answer: B Explanation: Gas price is the amount of Ether the sender pays per gas unit; together with gas limit it defines the total fee.
Question 5. What is the role of the Ethereum Virtual Machine (EVM)? A) To mine new Ether blocks
C) EOAs can store data, Contract Accounts cannot. D) EOAs are only used on private blockchains. Answer: B Explanation: Contract Accounts contain bytecode and automatically execute it when they receive a transaction; EOAs simply forward transactions.
Question 8. In a Solidity source file, which pragma directive is used to specify the compiler version? A) pragma solidity ^0.8.0; B) import "solidity"; C) version solidity 0.8.0; D) #include solidity Answer: A Explanation: The pragma solidity line tells the compiler which Solidity versions are compatible with the source file.
Question 9. Which of the following is a correct way to import a library from another file in Solidity? A) import "./SafeMath.sol"; B) include SafeMath; C) using "./SafeMath.sol";
D) require "./SafeMath.sol"; Answer: A Explanation: The import statement pulls in external Solidity files, allowing reuse of contracts, libraries, or interfaces.
Question 10. What is the default value of an uninitialized uint256 variable in Solidity? A) 0 B) 1 C) - D) Undefined (causes a compile error) Answer: A Explanation: All value types in Solidity are automatically initialized to zero (or false for booleans) if not explicitly set.
Question 11. Which statement about the address type in Solidity is true? A) It can store arbitrary strings. B) It has built-in functions like balance and transfer. C) It is a signed integer type. D) It can be used to store large arrays directly.
Explanation: Enums assign human-readable names to integer values, making state machines and option sets clearer.
Question 14. Which of the following statements about Solidity arrays is correct? A) Dynamic arrays can be declared with a fixed length, e.g., uint[5]. B) Fixed-size arrays cannot be passed to external functions. C) Dynamic arrays reside in storage by default when declared at contract level. D) Arrays cannot contain structs. Answer: C Explanation: State-level arrays are stored in contract storage; they can be dynamic (uint[]) or fixed (uint[5]).
Question 15. What is the purpose of the mapping type in Solidity? A) To store an ordered list of values B) To create a hash table that maps keys to values with O(1) lookup C) To serialize data for off-chain use D) To define a contract’s inheritance hierarchy Answer: B Explanation: mapping(keyType => valueType) provides a key-value store with constant-time access, but keys are not iterable.
Question 16. When should you use the memory data location for a function parameter? A) For variables that need to persist across transactions B) For temporary variables that exist only during function execution C) For storing data on the blockchain permanently D) For variables that must be accessible by other contracts Answer: B Explanation: memory creates a temporary copy that lives only for the duration of the external call, saving gas compared to storage.
Question 17. Which global variable provides the address of the account that called the current function? A) tx.origin B) block.coinbase C) msg.sender D) blockhash Answer: C Explanation: msg.sender is the immediate caller of the function, whether an EOA or another contract.
Question 20. What is the effect of calling assert(false); in Solidity 0.8+? A) Consumes all remaining gas but does not revert state B) Reverts the transaction and refunds remaining gas C) Triggers a panic error that consumes all gas and reverts state D) Emits a custom error event without reverting Answer: C Explanation: assert failures generate a panic error (error code 0x01) that consumes all remaining gas and reverts all state changes.
Question 21. Which visibility specifier makes a function callable only from within the contract and its derived contracts? A) public B) private C) internal D) external Answer: C Explanation: internal functions are accessible to the contract itself and any contracts that inherit from it.
Question 22. When should a function be marked as payable? A) When it reads from storage
B) When it can receive Ether as part of the call C) When it only returns a value without modifying state D) When it is intended to be called only by the contract owner Answer: B Explanation: payable functions can accept Ether; without this modifier, any attached Ether causes the transaction to revert.
Question 23. What does the view modifier indicate about a Solidity function? A) The function can modify state variables. B) The function can read state but cannot modify it. C) The function can receive Ether. D) The function is only callable by the contract itself. Answer: B Explanation: view functions promise not to alter the blockchain state, allowing them to be called without a transaction.
Question 24. Which of the following is a correct example of a function modifier that restricts access to the contract owner? A) modifier onlyOwner { require(msg.sender == owner, "Not owner"); _; } B) modifier onlyOwner { if (msg.sender != owner) revert(); } C) modifier onlyOwner { require(tx.origin == owner); _; }
Answer: C Explanation: Abstract contracts serve as base contracts with at least one function lacking implementation; they cannot be instantiated until all functions are overridden.
Question 27. What is the purpose of an interface in Solidity? A) To provide storage layout for contracts B) To define a set of function signatures without implementation, enabling interaction with external contracts C) To inherit state variables from multiple contracts D) To automatically generate getters for all public variables Answer: B Explanation: Interfaces declare external contract functions, allowing a contract to call them without needing the full source code.
Question 28. How does the using X for Y; directive affect Solidity code? A) It imports library X into the global namespace. B) It attaches library functions of X as member functions to type Y. C) It creates a new contract that inherits from X and Y. D) It makes X a parent contract of Y.
Answer: B Explanation: using Library for Type; enables library functions to be called as if they were methods of the specified type.
Question 29. Which special function is executed only once when a contract is created? A) fallback() B) receive() C) constructor() D) init() Answer: C Explanation: The constructor runs during deployment and cannot be called again.
Question 30. When does the receive() function get triggered? A) When a contract receives Ether with empty calldata. B) When a contract receives a call to a non-existent function. C) When a contract is created. D) When a contract sends Ether to another contract. Answer: A Explanation: receive() is a payable fallback that executes on plain Ether transfers (no data) to the contract.
Question 33. How can a dApp efficiently listen for a specific Transfer event emitted by an ERC-20 contract? A) By scanning every block manually. B) By using eth_getLogs with the event’s topic hash and indexed address filters. C) By calling the contract’s Transfer getter function. D) By querying the transaction pool for pending events. Answer: B Explanation: eth_getLogs (or libraries like ethers.js) can filter logs using the event’s topic hash and indexed parameters, delivering only relevant events.
Question 34. What is the advantage of using custom errors (e.g., error InsufficientBalance();) over require with a string message? A) Custom errors are more readable on block explorers. B) They consume less gas because the error selector is cheaper than storing a string. C) They allow returning values to the caller. D) They automatically trigger a contract upgrade. Answer: B Explanation: Custom errors encode only the selector and optional data, saving gas compared to the full string stored in a revert reason.
Question 35. Which ERC-20 function returns the total supply of the token? A) balanceOf(address account) B) totalSupply() C) allowance(address owner, address spender) D) decimals() Answer: B Explanation: totalSupply() provides the aggregate number of tokens in existence.
Question 36. In the ERC-20 standard, what does the approve function do? A) Transfers tokens to another address. B) Sets an allowance that a spender can use on behalf of the token holder. C) Burns tokens permanently. D) Mints new tokens to the caller. Answer: B Explanation: approve(spender, amount) authorizes spender to transfer up to amount tokens from the caller’s balance.
Question 39. Which development tool allows you to compile, deploy, and debug Solidity contracts directly in a web browser? A) Hardhat B) Truffle C) Remix IDE D) Ganache Answer: C Explanation: Remix is a browser-based IDE that provides compilation, deployment, and debugging without local setup.
Question 40. What is the primary advantage of using Hardhat over Remix for large projects? A) Hardhat runs in the browser, Remix requires installation. B) Hardhat provides a flexible JavaScript/TypeScript environment, scriptable deployments, and advanced testing utilities. C) Hardhat automatically generates UI components. D) Hardhat eliminates the need for Solidity at all. Answer: B Explanation: Hardhat’s plugin system, local network, and test framework make it suitable for complex, automated workflows.
Question 41. Which library would you import to interact with Ethereum from a JavaScript frontend? A) web3.js B) ethers.js C) Both A and B are valid choices. D) solc-js Answer: C Explanation: Both Web3.js and Ethers.js are popular JavaScript libraries for sending transactions and reading data from Ethereum.
Question 42. How does MetaMask facilitate user interaction with a dApp? A) By providing a decentralized storage layer. B) By acting as a browser extension that injects a Web3 provider, allowing the dApp to request signatures and send transactions. C) By compiling Solidity contracts on the client side. D) By hosting the dApp’s backend APIs. Answer: B Explanation: MetaMask injects window.ethereum, enabling dApps to request accounts, sign messages, and broadcast transactions securely.