A.A decentralized platform for running smart contracts
B.A social media network on the blockchain
C.A digital currency for peer-to-peer payments only
D.A centralized database for financial records
Correct Answer: A decentralized platform for running smart contracts
Explanation:
While Ethereum has its own cryptocurrency (Ether), its main innovation is being a programmable blockchain that allows developers to create and deploy decentralized applications (dApps) and smart contracts.
Incorrect! Try again.
2A 'smart contract' on Ethereum is best described as:
Ethereum and smart contracts
Easy
A.A legal document written by lawyers and stored on the blockchain
B.A computer program that automatically executes when certain conditions are met
C.A user's crypto wallet address and private key
D.A physical contract that is scanned and uploaded to a server
Correct Answer: A computer program that automatically executes when certain conditions are met
Explanation:
A smart contract is self-executing code stored on the blockchain. It runs when predetermined conditions are met, without the need for a central authority or intermediary.
Incorrect! Try again.
3What is the native cryptocurrency of the Ethereum network used to pay for transactions?
Ethereum and smart contracts
Easy
A.Ether (ETH)
B.Bitcoin (BTC)
C.Litecoin (LTC)
D.Ripple (XRP)
Correct Answer: Ether (ETH)
Explanation:
Ether (ETH) is the native digital currency used to power the Ethereum network, pay for transaction fees (gas), and reward miners/validators.
Incorrect! Try again.
4In the context of Ethereum, what is the primary purpose of 'gas'?
Ethereum and smart contracts
Easy
A.A password required to access a smart contract
B.To power the physical computers of miners
C.A unit to measure the computational effort required to execute an operation
D.A type of cryptocurrency token separate from Ether
Correct Answer: A unit to measure the computational effort required to execute an operation
Explanation:
Gas is the fee required to successfully conduct a transaction or execute a contract on the Ethereum blockchain. It measures the amount of computational work required for the operation.
Incorrect! Try again.
5What does it mean for a programming language like Solidity to be 'Turing-complete'?
The Turing completeness of smart contract languages and verification challenges
Easy
A.It can only perform a very limited set of operations
B.It was designed by the famous computer scientist Alan Turing
C.It is completely secure and free of bugs by design
D.It can be used to solve any computational problem, given enough resources
Correct Answer: It can be used to solve any computational problem, given enough resources
Explanation:
Turing completeness means the language is computationally universal. It can be used to simulate any Turing machine, which implies it can perform any computation that any other general-purpose computer can.
Incorrect! Try again.
6A major security challenge arising from the Turing completeness of smart contracts is the possibility of:
The Turing completeness of smart contract languages and verification challenges
Easy
A.Incompatibility with traditional legal systems
B.Faster than expected transaction speeds
C.Infinite loops that could potentially consume all allocated gas
D.Contracts being too simple to be useful
Correct Answer: Infinite loops that could potentially consume all allocated gas
Explanation:
Because a Turing-complete language can express complex logic, including loops, it's possible to write a contract that never terminates. On Ethereum, this would cause the contract to run until it runs out of gas, failing the transaction.
Incorrect! Try again.
7The 'Halting Problem' is a fundamental concept in computer science that proves it's impossible to:
The Turing completeness of smart contract languages and verification challenges
Easy
A.Stop a smart contract once it has been deployed
B.Build a computer that never crashes
C.Create a program that can determine if any other program will finish or run forever
D.Verify that a contract has enough gas to run
Correct Answer: Create a program that can determine if any other program will finish or run forever
Explanation:
The Halting Problem is a famous undecidable problem. It's impossible to create a single algorithm that can analyze any arbitrary program and determine if it will eventually halt or enter an infinite loop. This has implications for automatically detecting all such bugs in smart contracts.
Incorrect! Try again.
8What is the goal of 'formal verification' in smart contract development?
The Turing completeness of smart contract languages and verification challenges
Easy
A.To mathematically prove that the contract's code behaves as specified and is free of certain bugs
B.To make the code run faster on the EVM
C.To automatically translate the code into multiple programming languages
D.To get legal approval for the smart contract's deployment
Correct Answer: To mathematically prove that the contract's code behaves as specified and is free of certain bugs
Explanation:
Formal verification uses rigorous mathematical methods to check the correctness of code against a formal specification. Given the immutable and high-stakes nature of smart contracts, this is crucial for ensuring security.
Incorrect! Try again.
9What does the principle 'code is law' mean in the context of smart contracts?
Using smart contracts to enforce legal contracts
Easy
A.All software code must be reviewed by a lawyer before deployment
B.The execution of a smart contract is determined strictly by its code, without human interpretation
C.Developers can be sued for writing code with bugs
D.Smart contract code is legally binding in all jurisdictions worldwide
Correct Answer: The execution of a smart contract is determined strictly by its code, without human interpretation
Explanation:
'Code is law' suggests that the rules embedded in a smart contract's code are the final arbiters of the agreement, and the contract will execute exactly as written.
Incorrect! Try again.
10In the blockchain world, what is an 'oracle'?
Using smart contracts to enforce legal contracts
Easy
A.A person who audits smart contract code for security flaws
B.A trusted service that provides external, real-world data to a smart contract
C.The original, genesis block of a blockchain
D.A special type of smart contract that can predict future cryptocurrency prices
Correct Answer: A trusted service that provides external, real-world data to a smart contract
Explanation:
Blockchains are deterministic systems and cannot access outside information on their own. Oracles are services that act as a bridge, feeding external data (like weather or price feeds) onto the blockchain for smart contracts to use.
Incorrect! Try again.
11What is a primary benefit of using a smart contract for an agreement like an escrow?
Using smart contracts to enforce legal contracts
Easy
A.It eliminates the need for a trusted third-party intermediary, reducing costs
B.It allows for flexible, subjective interpretation of the agreement terms
C.It requires a team of expensive lawyers to operate
D.It is easy to change the terms of the agreement after deployment
Correct Answer: It eliminates the need for a trusted third-party intermediary, reducing costs
Explanation:
Smart contracts can automate the function of an escrow agent. Funds are held and released automatically based on coded conditions, removing the need to trust and pay a human intermediary.
Incorrect! Try again.
12What is a major challenge when trying to represent a traditional legal contract as a smart contract?
Using smart contracts to enforce legal contracts
Easy
A.Legal language often contains ambiguity and subjectivity, which is hard to translate into deterministic code
B.Smart contract programming languages are not powerful enough
C.Most legal contracts are too short to be coded
D.There is no way to store text in a smart contract
Correct Answer: Legal language often contains ambiguity and subjectivity, which is hard to translate into deterministic code
Explanation:
Legal agreements often rely on interpretation and context. Computer code, by contrast, must be completely explicit and unambiguous, making it difficult to capture the nuances of legal prose.
Incorrect! Try again.
13A key difference between Bitcoin's scripting language and Ethereum's smart contract languages is that Bitcoin's script is intentionally:
Comparing Bitcoin scripting vs. Ethereum smart contracts
Easy
A.Turing-complete
B.Non-Turing-complete
C.Encrypted
D.Object-oriented
Correct Answer: Non-Turing-complete
Explanation:
To maximize security and predictability while minimizing attack surfaces, Bitcoin's scripting language was designed to be non-Turing-complete. It lacks features like complex loops, which prevents many of the complex applications possible on Ethereum.
Incorrect! Try again.
14Which of the following can be easily implemented with an Ethereum smart contract but is very difficult or impossible with Bitcoin's native script?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Easy
A.A multi-signature wallet
B.A decentralized autonomous organization (DAO)
C.A time-locked transaction
D.A simple peer-to-peer payment
Correct Answer: A decentralized autonomous organization (DAO)
Explanation:
A DAO requires complex, stateful logic for voting, proposals, and treasury management. This level of complexity is well-suited for Ethereum's Turing-complete smart contracts but is beyond the capabilities of Bitcoin's simple, non-Turing-complete script.
Incorrect! Try again.
15What is the name of the sandboxed runtime environment where smart contracts are executed on the Ethereum network?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Easy
A.Bitcoin Core
B.The Ethereum Virtual Machine (EVM)
C.The Java Virtual Machine (JVM)
D.Docker Container
Correct Answer: The Ethereum Virtual Machine (EVM)
Explanation:
The EVM is the part of Ethereum that handles smart contract execution. It's a quasi-Turing-complete, isolated environment that ensures contract code cannot interfere with the rest of the network.
Incorrect! Try again.
16Compared to Ethereum's account-based model, Bitcoin's model is based on:
Comparing Bitcoin scripting vs. Ethereum smart contracts
Easy
Bitcoin tracks ownership through a ledger of UTXOs, which are like individual pieces of digital cash. Ethereum uses an account model, similar to a bank account, where each account has a balance that is directly debited or credited.
Incorrect! Try again.
17What is the most popular, high-level programming language for writing smart contracts on Ethereum?
Writing smart contracts using Solidity & JavaScript
Easy
A.JavaScript
B.Solidity
C.C#
D.Python
Correct Answer: Solidity
Explanation:
Solidity is a contract-oriented, high-level programming language specifically created for implementing smart contracts on platforms like Ethereum. Its syntax is influenced by C++, Python, and JavaScript.
Incorrect! Try again.
18In a Solidity smart contract, what does the public visibility keyword for a state variable do?
Writing smart contracts using Solidity & JavaScript
Easy
A.It ensures only the contract owner can modify the variable
B.It makes the variable a constant that cannot be changed
C.It automatically creates a 'getter' function so its value can be read from outside the contract
D.It encrypts the variable's data on the blockchain
Correct Answer: It automatically creates a 'getter' function so its value can be read from outside the contract
Explanation:
Declaring a state variable as public in Solidity instructs the compiler to generate a function that allows other contracts and external accounts to read its value without needing to write the function manually.
Incorrect! Try again.
19Which of the following are popular JavaScript libraries used to interact with the Ethereum blockchain from a web application?
Writing smart contracts using Solidity & JavaScript
Easy
A.Ethers.js and Web3.js
B.React and Vue
C.Node.js and Express
D.jQuery and Lodash
Correct Answer: Ethers.js and Web3.js
Explanation:
Ethers.js and Web3.js are comprehensive JavaScript libraries that provide the necessary tools to connect to an Ethereum node (e.g., through MetaMask) and interact with deployed smart contracts from a front-end application.
Incorrect! Try again.
20What is the purpose of the constructor function in a Solidity smart contract?
Writing smart contracts using Solidity & JavaScript
Easy
A.It is a function that must be called in every transaction to the contract
B.To destroy the contract and return funds
C.It is a special function that is executed only once when the contract is first deployed
D.To receive payments of Ether from users
Correct Answer: It is a special function that is executed only once when the contract is first deployed
Explanation:
The constructor is an optional, special function that runs only during the creation of the contract. It is typically used to initialize state variables, such as setting the owner (msg.sender) of the contract.
Incorrect! Try again.
21A smart contract deployed on Ethereum needs to be updated to fix a critical bug. What is the most common and accepted method to achieve this, considering the immutability of the blockchain?
Ethereum and smart contracts
Medium
A.Directly edit the code of the deployed contract using a special transaction.
B.Submit a network-wide vote to overwrite the specific block containing the contract.
C.Use the selfdestruct function on the old contract, which automatically transfers its logic to a new address.
D.Deploy a new version of the contract and have users/other contracts migrate to the new address.
Correct Answer: Deploy a new version of the contract and have users/other contracts migrate to the new address.
Explanation:
Smart contracts on Ethereum are immutable, meaning their code cannot be changed once deployed. The standard practice for 'updating' a contract is to deploy a new, corrected version. This often involves using a proxy pattern where a stable proxy contract points to the address of the latest implementation contract, allowing for upgrades without changing the address users interact with. Directly editing code is impossible.
Incorrect! Try again.
22In Solidity, what is the key difference between functions marked with view and pure?
Writing smart contracts using Solidity & JavaScript
Medium
A.pure functions can read from state but not from memory, while view functions can read from both.
B.view functions can read from the blockchain state but not modify it, while pure functions cannot even read from the state.
C.view functions consume gas when called externally, while pure functions do not.
D.view functions are for external calls only, while pure functions can only be called internally.
Correct Answer: view functions can read from the blockchain state but not modify it, while pure functions cannot even read from the state.
Explanation:
Both view and pure functions do not modify the blockchain state. The distinction is that view functions can read state variables (e.g., balances, stored values). In contrast, pure functions are more restrictive; they cannot read or write to the state and only operate on their input parameters and local variables (e.g., performing a mathematical calculation). Calling either externally via a node does not cost gas as it doesn't create a transaction.
Incorrect! Try again.
23Which of the following functionalities is easily achievable with an Ethereum smart contract but is practically impossible with Bitcoin's native Script language?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Medium
A.Creating a decentralized autonomous organization (DAO) where members vote on proposals and funds are managed based on voting outcomes.
B.Executing a transaction that is only valid after a certain block height (timelock).
C.Verifying a cryptographic signature against a public key.
D.Creating a multi-signature wallet that requires 2-of-3 signatures to spend funds.
Correct Answer: Creating a decentralized autonomous organization (DAO) where members vote on proposals and funds are managed based on voting outcomes.
Explanation:
A DAO requires complex, stateful logic: tracking membership, proposal details, voting status, and treasury management. This relies on Ethereum's Turing-complete nature and its account-based state model. Bitcoin Script is intentionally non-Turing-complete and primarily designed for transaction validation. While it can handle multi-sig and timelocks, it lacks the ability to manage the complex, persistent state and arbitrary logic required for a DAO.
Incorrect! Try again.
24The concept of 'gas' in Ethereum is a direct solution to which problem introduced by Turing-complete smart contract languages?
The Turing completeness of smart contract languages and verification challenges
Medium
A.The Byzantine Generals' Problem, by ensuring all nodes agree on the transaction fee.
B.The Halting Problem, by ensuring that any computation, including infinite loops, will eventually stop due to depleted resources.
C.The problem of data privacy, by making expensive computations publicly visible.
D.The challenge of formal verification, by simplifying the contract's bytecode.
Correct Answer: The Halting Problem, by ensuring that any computation, including infinite loops, will eventually stop due to depleted resources.
Explanation:
The Halting Problem states that it is impossible to create a general algorithm that can determine whether any given program will finish running or continue to run forever. Since Solidity is Turing-complete, a malicious or poorly written contract could contain an infinite loop. The gas mechanism solves this by attaching a cost to every computational step. A transaction with an infinite loop will eventually run out of gas, halt its execution, and revert, preventing it from freezing the entire network.
Incorrect! Try again.
25What is the primary role of an 'oracle' when using a smart contract to execute the terms of a real-world agreement, such as a crop insurance policy?
Using smart contracts to enforce legal contracts
Medium
A.To translate the legal prose of the contract into Solidity code.
B.To act as a legal arbitrator in case of a dispute between the parties.
C.To formally verify the smart contract code for bugs before deployment.
D.To provide reliable, off-chain data (e.g., weather reports) to the smart contract, triggering its execution.
Correct Answer: To provide reliable, off-chain data (e.g., weather reports) to the smart contract, triggering its execution.
Explanation:
Blockchains and smart contracts are deterministic systems that cannot natively access external, off-chain data like weather information, stock prices, or sports results. An oracle is a trusted third-party service that fetches and verifies external information and pushes it onto the blockchain for smart contracts to use. In a crop insurance contract, an oracle would provide rainfall data, allowing the smart contract to automatically trigger a payout if a drought condition is met.
Incorrect! Try again.
26A developer wants to notify a JavaScript frontend every time a new item is created in their smart contract. What is the most gas-efficient and standard way to achieve this in Solidity?
Writing smart contracts using Solidity & JavaScript
Medium
A.Have the Solidity function return a special string value that the JavaScript frontend can parse.
B.Write a new transaction to the blockchain containing the notification message.
C.Store a boolean flag in storage and have the JavaScript app poll this flag continuously.
D.Use the emit keyword to trigger a declared event, which the frontend can listen for.
Correct Answer: Use the emit keyword to trigger a declared event, which the frontend can listen for.
Explanation:
Events are a core feature of Solidity designed for this purpose. Emitting an event is a low-cost way to log data on the blockchain that is not directly accessible by other smart contracts but can be efficiently read by external clients (like a JavaScript frontend using web3.js or ethers.js). This is much more efficient than storing data in contract storage or creating new transactions for notification purposes.
Incorrect! Try again.
27How does the state management in Ethereum's account-based model differ from Bitcoin's UTXO model?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Medium
A.Ethereum maintains a global state that maps addresses to account balances and storage, while Bitcoin's state is the set of all unspent transaction outputs (UTXOs).
B.Ethereum uses a 'first-in, first-out' queue for transactions, whereas Bitcoin uses a UTXO-based stack.
C.Bitcoin's UTXO model is stateful, tracking account history, while Ethereum's model is stateless, recalculating balances with each block.
D.Both systems use an identical account-based model, but Ethereum's is written in a more complex language.
Correct Answer: Ethereum maintains a global state that maps addresses to account balances and storage, while Bitcoin's state is the set of all unspent transaction outputs (UTXOs).
Explanation:
This is a fundamental difference. Ethereum's 'world state' is like a global database where each address has an associated account with a balance, nonce, code, and storage. This makes it easy for smart contracts to manage and persist their own internal state. Bitcoin's state is a collection of UTXOs. A transaction consumes existing UTXOs and creates new ones. This model is simpler and excellent for payments but less suited for complex applications that require a persistent, shared state.
Incorrect! Try again.
28A common vulnerability in early smart contracts was 're-entrancy'. This type of attack is a direct consequence of which feature of smart contract execution?
The Turing completeness of smart contract languages and verification challenges
Medium
A.The use of assembly language within Solidity, which is inherently unsafe.
B.The fixed gas limit for all transactions, which forces developers to write inefficient code.
C.The ability of one contract to call another contract's public functions, combined with the execution order of state updates.
D.The immutability of contract code, which prevents patching the vulnerability.
Correct Answer: The ability of one contract to call another contract's public functions, combined with the execution order of state updates.
Explanation:
A re-entrancy attack occurs when an external contract call is made before updating the internal state (like a user's balance). The malicious external contract can then call back into the original function before the state update occurs, allowing it to drain funds repeatedly. The recommended 'Checks-Effects-Interactions' pattern, where internal state is updated before the external call, is the primary defense against this.
Incorrect! Try again.
29What is the primary function of the Ethereum Virtual Machine (EVM)?
Ethereum and smart contracts
Medium
A.To compile Solidity and other high-level languages into machine code for a specific operating system.
B.To provide a sandboxed runtime environment for executing smart contract bytecode in a deterministic way across all nodes.
C.To manage the peer-to-peer network connections between Ethereum nodes.
D.To reach consensus on the order of blocks using a Proof-of-Work algorithm.
Correct Answer: To provide a sandboxed runtime environment for executing smart contract bytecode in a deterministic way across all nodes.
Explanation:
The EVM is the core of Ethereum's smart contract execution. It is a quasi-Turing-complete state machine. When a transaction calls a smart contract, every full node on the network runs the contract's bytecode within its local EVM instance. The EVM's strict, deterministic rules ensure that every node computes the same result and arrives at the same final state, which is essential for maintaining consensus.
Incorrect! Try again.
30A key challenge in mapping legal contracts to smart contracts is handling ambiguity. Which of the following legal clauses would be the most difficult to implement directly in a smart contract without an external arbitrator?
Using smart contracts to enforce legal contracts
Medium
A."The escrow shall release funds if signatures from both Party A and Party B are provided."
B."A penalty of 1 ETH per day shall be applied for each day the payment is late after the due date."
C."Party A shall pay Party B if the goods are delivered in a 'satisfactory condition'."
D."Party A shall pay Party B 10 ETH on or before December 31st, 2024."
Correct Answer: "Party A shall pay Party B if the goods are delivered in a 'satisfactory condition'."
Explanation:
Smart contracts excel at executing objective, binary logic. Terms like 'satisfactory condition', 'reasonable effort', or 'good faith' are subjective and cannot be algorithmically determined by the contract itself. Implementing such a clause would require an oracle or a mutually trusted third party (an arbitrator) to evaluate the condition and report the binary outcome (satisfactory/not satisfactory) to the contract.
Incorrect! Try again.
31What happens to a transaction if it is submitted with a gas limit that is too low to complete its required computations?
Ethereum and smart contracts
Medium
A.The miner who includes the transaction pays the remaining gas cost out of their block reward.
B.The transaction is rejected by the network and never included in a block, and the sender is refunded the gas fee.
C.The transaction executes as many steps as it can, then fails and reverts all state changes, but the gas fee is still consumed by the miner.
D.The transaction is partially executed, and the state changes made before the gas ran out are permanently saved to the blockchain.
Correct Answer: The transaction executes as many steps as it can, then fails and reverts all state changes, but the gas fee is still consumed by the miner.
Explanation:
When a transaction runs out of gas, it triggers an 'out-of-gas' exception. The EVM halts execution and reverts any changes made to the state during that transaction's execution. However, the computational work has already been done by the validating nodes. Therefore, the sender forfeits the entire gas fee up to the gas limit to compensate the miner for their work. This prevents denial-of-service attacks where users could submit complex, non-terminating transactions without penalty.
Incorrect! Try again.
32Consider the following Solidity code snippet: uint256[] public data;. What is a potential risk associated with making an array of dynamic size public?
Writing smart contracts using Solidity & JavaScript
Medium
A.Making an array public allows anyone on the network to delete its elements without restriction.
B.Public arrays cannot store more than 256 elements, leading to unexpected data loss.
C.The public visibility keyword is deprecated for arrays and will cause a compilation error.
D.Solidity automatically creates a getter function for it. If the array becomes very large, calling this getter function from an external contract could lead to an out-of-gas error.
Correct Answer: Solidity automatically creates a getter function for it. If the array becomes very large, calling this getter function from an external contract could lead to an out-of-gas error.
Explanation:
The public keyword automatically generates a getter function that other contracts or external clients can call. For dynamic arrays, this getter function returns the entire array. If the array grows to be very large, the gas cost of copying the entire array into memory and returning it can exceed the block gas limit, making it impossible for other contracts to call this getter and causing transactions to fail.
Incorrect! Try again.
33What is the primary goal of 'formal verification' in the context of smart contract security?
The Turing completeness of smart contract languages and verification challenges
Medium
A.To translate the smart contract's bytecode back into a high-level language for manual review.
B.To run the smart contract on a test network with simulated attack scenarios.
C.To automatically generate unit tests that cover every possible execution path of the contract.
D.To mathematically prove that the smart contract's code behaves exactly as intended and adheres to certain properties, eliminating entire classes of bugs.
Correct Answer: To mathematically prove that the smart contract's code behaves exactly as intended and adheres to certain properties, eliminating entire classes of bugs.
Explanation:
Formal verification uses rigorous mathematical methods to prove or disprove the correctness of a system with respect to a formal specification. For smart contracts, this means proving properties like 'the total supply of this token can never exceed X' or 'only the owner can withdraw funds'. It is a powerful but complex technique that provides a much higher level of assurance than traditional testing, which can only show the presence of bugs, not their absence.
Incorrect! Try again.
34Which statement best describes the difference in how transaction fees are calculated in Bitcoin versus Ethereum?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Medium
A.Bitcoin transactions are free, while Ethereum transactions require a fee.
B.Ethereum fees are based on computational complexity (gas), while Bitcoin fees are primarily based on transaction size in bytes.
C.Ethereum fees are paid to a central entity, while Bitcoin fees are paid to miners.
D.Bitcoin fees are a fixed percentage of the transaction amount, while Ethereum fees are dynamic based on network congestion.
Correct Answer: Ethereum fees are based on computational complexity (gas), while Bitcoin fees are primarily based on transaction size in bytes.
Explanation:
In Bitcoin, block space is the scarce resource, so fees (satoshis/byte) are based on the data size of the transaction. In Ethereum, both block space and computational effort are scarce resources. The gas system prices every single operation (e.g., addition, storage write), so a computationally intensive transaction will cost more than a simple transfer, even if they are the same size in bytes. The total fee in Ethereum is gas used * gas price.
Incorrect! Try again.
35The principle of 'Code is Law' suggests that the execution of a smart contract is the final and binding outcome. What is a significant practical and philosophical challenge to this principle?
Using smart contracts to enforce legal contracts
Medium
A.It is incompatible with most modern programming languages like JavaScript and Python.
B.It does not account for bugs or exploits in the code, which can lead to unintended outcomes that conflict with the original intent of the agreement.
C.It requires all parties to have advanced knowledge of cryptography.
D.It cannot be implemented on public blockchains due to privacy concerns.
Correct Answer: It does not account for bugs or exploits in the code, which can lead to unintended outcomes that conflict with the original intent of the agreement.
Explanation:
The 'Code is Law' philosophy posits that a smart contract's code is the ultimate arbiter. However, this becomes problematic when the code contains a bug or is exploited in a way that the human parties did not intend (e.g., the DAO hack). In such cases, the code's execution might be valid according to the EVM's rules, but it violates the spirit and intent of the underlying agreement, creating a conflict that traditional legal systems are designed to resolve through interpretation and context.
Incorrect! Try again.
36What is the difference between an Externally Owned Account (EOA) and a Contract Account on Ethereum?
Ethereum and smart contracts
Medium
A.Only Contract Accounts can send transactions, which are then signed by EOAs.
B.An EOA has an associated code hash, while a Contract Account does not.
C.A Contract Account can hold more ETH than an EOA.
D.An EOA is controlled by a private key, while a Contract Account is controlled by its own code; only EOAs can initiate transactions.
Correct Answer: An EOA is controlled by a private key, while a Contract Account is controlled by its own code; only EOAs can initiate transactions.
Explanation:
This is a core distinction in Ethereum's account model. EOAs are the 'user' accounts, controlled by a private key that allows them to sign and initiate transactions. Contract Accounts do not have private keys; their behavior is dictated entirely by the code deployed at their address. A Contract Account can react to transactions (by running its code) and call other contracts, but it can never start a new transaction on its own. All activity on Ethereum must originate from an EOA.
Incorrect! Try again.
37A developer writes a Solidity function: function _doSomething() internal pure returns(uint) { ... }. What are the implications of the internal visibility modifier?
Writing smart contracts using Solidity & JavaScript
Medium
A.The function is part of the contract's public ABI and can be called via a transaction, but only if the caller is another contract.
B.The function can only be called by the contract's owner.
C.The function can only be called from within the same contract or by contracts that inherit from it.
D.The function is automatically inlined by the compiler to save gas.
Correct Answer: The function can only be called from within the same contract or by contracts that inherit from it.
Explanation:
Solidity has four visibility modifiers: public (callable by anyone), external (callable only from other contracts and EOAs), internal (callable from the contract and derived contracts), and private (callable only from the contract in which it is defined). internal is similar to protected in some object-oriented languages and is used for helper functions that are part of the contract's internal logic but not its public interface.
Incorrect! Try again.
38Why is Bitcoin's scripting language intentionally designed to be non-Turing-complete?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Medium
A.To make the language compatible with financial regulations that prohibit complex derivatives.
B.To enhance security by making transaction outcomes more predictable and preventing complex, potentially harmful programs like infinite loops.
C.To ensure that all Bitcoin scripts could run on low-power hardware like mobile phones.
D.Because the creators lacked the technical ability to create a Turing-complete language at the time.
Correct Answer: To enhance security by making transaction outcomes more predictable and preventing complex, potentially harmful programs like infinite loops.
Explanation:
Bitcoin's design prioritizes security and predictability for its primary use case: a peer-to-peer electronic cash system. A non-Turing-complete language, which lacks features like complex loops and recursion, has a much smaller attack surface. It makes it possible to analyze a script and predict its resource consumption and outcome with certainty, which is a crucial security feature for a system handling large amounts of value.
Incorrect! Try again.
39Integer overflow and underflow vulnerabilities were common in early Solidity contracts. This problem arises because...
The Turing completeness of smart contract languages and verification challenges
Medium
A.The Turing-complete nature of Solidity allows for recursive functions that can quickly exhaust the integer range.
B.Solidity's compiler automatically converts all integer types to uint8 to save gas, increasing the risk of overflow.
C.The EVM does not support floating-point arithmetic, forcing all calculations to use integers.
D.EVM integers are of a fixed size (e.g., uint256), and operations that exceed the maximum or go below the minimum value wrap around without throwing an error.
Correct Answer: EVM integers are of a fixed size (e.g., uint256), and operations that exceed the maximum or go below the minimum value wrap around without throwing an error.
Explanation:
In early versions of Solidity (before 0.8.0), arithmetic operations on fixed-size integers did not check for overflow or underflow. For example, if a uint8 (max value 255) holding the value 255 was incremented, it would 'wrap around' to 0. This could be exploited, for instance, in a token contract to create an infinite balance. Modern Solidity versions (0.8.0+) automatically revert on overflow/underflow, but safe math libraries were required to mitigate this in older contracts.
Incorrect! Try again.
40When a JavaScript DApp uses a library like web3.js to call a view function on a smart contract, how is this operation typically handled by an Ethereum node like Geth or Infura?
Writing smart contracts using Solidity & JavaScript
Medium
A.The call is broadcast to the network as a zero-gas transaction for miners to execute and confirm.
B.A read-only block is temporarily created to simulate the function call.
C.The JavaScript library simulates the EVM locally within the browser to get the result without contacting a node.
D.The node executes the function on its local EVM instance using the current blockchain state and returns the result directly, without creating a transaction.
Correct Answer: The node executes the function on its local EVM instance using the current blockchain state and returns the result directly, without creating a transaction.
Explanation:
Calls to view or pure functions do not modify the blockchain state. Therefore, they don't need to be packaged into a transaction, broadcast to the network, and mined. When a DApp makes such a call, the connected node simply runs the function's bytecode against its current view of the state and returns the output. This is a read operation, and because it doesn't change anything, it is free (no gas) and instantaneous.
Incorrect! Try again.
41A proxy contract at address 0xP uses delegatecall to forward calls to an implementation contract V1. V1 has a single state variable: uint256 public value;. Later, the proxy is upgraded to a new implementation V2, which introduces a new variable at the first storage slot: address public owner;. An administrator calls a function on V2 via the proxy that is meant to set the owner variable. What is the most likely consequence of this operation on the proxy contract's state?
Writing smart contracts using Solidity & JavaScript
Hard
A.The value variable in the proxy's storage is overwritten with the new owner's address, likely leading to data corruption.
B.The owner variable is set correctly in the proxy's storage context, and the original value variable is shifted to a new storage slot.
C.A new storage slot is allocated for the owner variable in the proxy, leaving the value variable untouched.
D.The transaction reverts because the storage layouts of the proxy and the V2 implementation are incompatible.
Correct Answer: The value variable in the proxy's storage is overwritten with the new owner's address, likely leading to data corruption.
Explanation:
delegatecall executes the code of the implementation contract within the context (storage, msg.sender, etc.) of the proxy contract. State variables in Solidity are assigned storage slots sequentially, starting from slot 0. In V1, value is at slot 0. In V2, owner is at slot 0. When the proxy, which has its own storage layout based on V1, calls V2, the V2 code that writes to owner (slot 0) will write to the proxy's slot 0. This overwrites the value variable with the 20-byte address data (padded to 32 bytes). This is a critical vulnerability known as a storage collision in upgradeable contracts, which must be prevented by following specific storage layout patterns like the Unstructured Storage Pattern.
Incorrect! Try again.
42Given the Turing completeness of the EVM, the Halting Problem states that it's impossible to create a general algorithm that can determine if any arbitrary smart contract will finish running or loop forever. How does the Ethereum protocol pragmatically address this undecidable problem to prevent network-wide freezes?
The Turing completeness of smart contract languages and verification challenges
Hard
A.By using a sandboxed WebAssembly (WASM) environment that can formally prove termination for most contracts.
B.By enforcing a strict wall-clock time limit (e.g., 30 seconds) on transaction execution, after which the node terminates the process.
C.By implementing a 'gas' mechanism, where every computational step has a cost, and execution halts with an exception if the transaction runs out of its prepaid gas.
D.By requiring all smart contracts to be formally verified and certified by a trusted committee before they can be deployed to the mainnet.
Correct Answer: By implementing a 'gas' mechanism, where every computational step has a cost, and execution halts with an exception if the transaction runs out of its prepaid gas.
Explanation:
The gas system is Ethereum's practical solution to the Halting Problem. While it cannot solve the problem in the theoretical computer science sense (it can't predict halting beforehand), it makes infinite loops economically impossible. Each operation (opcode) consumes a specific amount of gas. A transaction is submitted with a finite gasLimit. If the execution consumes all the available gas before completion, it triggers an out-of-gas exception, reverts all state changes, and terminates. This prevents a single malicious or buggy contract from halting the entire network.
Incorrect! Try again.
43A key architectural difference between Bitcoin and Ethereum is their state model. Bitcoin uses the UTXO (Unspent Transaction Output) model, while Ethereum uses an account-based model. How does this difference fundamentally impact the ability to create complex, multi-party stateful applications like a decentralized exchange (DEX)?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Hard
A.The UTXO model makes it extremely difficult to represent and update shared global state. A DEX requires a common state (liquidity pools, order books) that multiple agents interact with, which is natural in Ethereum's contract accounts but creates massive contention and complexity in the UTXO model.
B.There is no fundamental difference; building a DEX is equally complex on both platforms, but Ethereum has better developer tooling.
C.Bitcoin's UTXO model is better for a DEX because it prevents the double-spending of assets more effectively than Ethereum's account model.
D.Ethereum's account model is less secure for a DEX because a single contract bug can compromise all user funds, whereas in the UTXO model, funds are segregated in individual outputs.
Correct Answer: The UTXO model makes it extremely difficult to represent and update shared global state. A DEX requires a common state (liquidity pools, order books) that multiple agents interact with, which is natural in Ethereum's contract accounts but creates massive contention and complexity in the UTXO model.
Explanation:
DeFi applications like DEXs rely on a central pool of logic and state that many users can interact with concurrently. Ethereum's smart contracts act as stateful objects, making it easy to model a liquidity pool or an order book as a single entity. In Bitcoin's UTXO model, there is no concept of a shared state account. To simulate it, the entire state of the DEX would have to be encoded into a single UTXO, which is then spent and recreated in every single trade. This creates a bottleneck, as only one state change can be processed at a time, making it impractical for high-frequency, multi-user applications.
Incorrect! Try again.
44A smart contract is designed to automate payments for a supply chain agreement. A clause in the corresponding legal document states that payment is released upon "successful delivery of goods in satisfactory condition." What is the most profound challenge in encoding this clause into the deterministic logic of a smart contract?
Using smart contracts to enforce legal contracts
Hard
A.The risk of a 51% attack on the Ethereum network, which could revert the payment transaction after it has been confirmed.
B.The high gas cost associated with storing and verifying delivery confirmation data on the blockchain.
C.The inability of Solidity to handle complex data types required to represent shipping manifests.
D.The 'Oracle Problem,' compounded by the subjectivity of 'satisfactory condition.' The contract cannot intrinsically know about real-world events or interpret ambiguous, subjective criteria, requiring a trusted external data source or a decentralized dispute resolution mechanism.
Correct Answer: The 'Oracle Problem,' compounded by the subjectivity of 'satisfactory condition.' The contract cannot intrinsically know about real-world events or interpret ambiguous, subjective criteria, requiring a trusted external data source or a decentralized dispute resolution mechanism.
Explanation:
This question highlights the gap between deterministic code and ambiguous legal language. Smart contracts can only operate on data available on the blockchain. The concept of "delivery" requires an oracle to feed external data (e.g., from a GPS tracker or shipping company API) onto the chain. More challenging is the term "satisfactory condition," which is subjective and requires human judgment. A smart contract cannot make such a judgment call. This necessitates either a trusted third-party oracle that attests to the condition, or a complex system for decentralized dispute resolution (like Kleros), which reintroduces layers of human trust and interaction that pure smart contracts aim to eliminate.
Incorrect! Try again.
45What is the primary function of the CREATE2 opcode (EIP-1014), and which of the following use-cases does it uniquely enable compared to the original CREATE opcode?
Ethereum and smart contracts
Hard
A.CREATE2 allows contracts to be deployed by other contracts, a feature not available with CREATE.
B.CREATE2 reduces the gas cost of deployment by pre-calculating the contract address off-chain.
C.CREATE2 allows for the creation of upgradeable contracts by making it easier to change a contract's code after deployment.
D.CREATE2 enables 'counterfactual instantiation,' allowing users to send funds to a pre-determined address before any contract code is actually deployed there, with the guarantee that only specific code can ever exist at that address.
Correct Answer: CREATE2 enables 'counterfactual instantiation,' allowing users to send funds to a pre-determined address before any contract code is actually deployed there, with the guarantee that only specific code can ever exist at that address.
Explanation:
The key innovation of CREATE2 is that it makes contract deployment addresses deterministic and independent of the deployer's nonce. The address is calculated from a hash of the deployer's address, a salt (a user-chosen number), and the hash of the contract's creation bytecode. This means anyone can calculate the address where a specific contract will be deployed without it actually being deployed yet. This allows for powerful patterns like state channels, where an on-chain escrow/judge contract address is agreed upon, and funds can be sent there, but the contract itself is only deployed if a dispute arises, saving significant gas costs.
Incorrect! Try again.
46In Solidity, the tx.origin global variable provides the address of the Externally Owned Account (EOA) that originally started the transaction chain. Using require(tx.origin == owner) for authorization in a wallet contract is a known anti-pattern. Why is this check a severe security vulnerability?
Writing smart contracts using Solidity & JavaScript
Hard
A.It is significantly more gas-expensive than checking msg.sender, leading to potential out-of-gas errors.
B.tx.origin is not guaranteed to be consistent across different Ethereum clients, leading to unpredictable behavior.
C.It makes the wallet vulnerable to a phishing attack where the owner is tricked into calling a malicious intermediary contract, which then calls the wallet. The tx.origin check will pass, granting the malicious contract control.
D.Future EIPs related to account abstraction are expected to deprecate tx.origin, making the contract obsolete.
Correct Answer: It makes the wallet vulnerable to a phishing attack where the owner is tricked into calling a malicious intermediary contract, which then calls the wallet. The tx.origin check will pass, granting the malicious contract control.
Explanation:
This is a classic vulnerability. If a wallet contract authorizes actions based on tx.origin, an attacker can write a simple contract that calls the wallet's vulnerable function. The attacker then tricks the legitimate owner into calling any function on this malicious contract. When the owner does so, the transaction flow is: Owner EOA -> Malicious Contract -> Wallet Contract. Within the wallet's function, msg.sender is the address of the Malicious Contract, but tx.origin is the address of the Owner EOA. The authorization check passes, allowing the malicious contract's code to execute with the owner's privileges, potentially draining all funds.
Incorrect! Try again.
47Rice's Theorem, a fundamental result in computability theory, states that any non-trivial semantic property of programs is undecidable. How does this theorem directly apply to the automated security analysis of Ethereum smart contracts?
The Turing completeness of smart contract languages and verification challenges
Hard
A.It proves that no Solidity compiler can be completely free of bugs.
B.It mandates that all smart contracts must include a gas limit to ensure termination.
C.It implies that creating a universal tool that can definitively prove the absence or presence of a complex vulnerability (e.g., 'can this contract ever be re-entered?') for any possible smart contract is theoretically impossible.
D.It guarantees that the EVM's state space is infinite, making full formal verification impractical.
Correct Answer: It implies that creating a universal tool that can definitively prove the absence or presence of a complex vulnerability (e.g., 'can this contract ever be re-entered?') for any possible smart contract is theoretically impossible.
Explanation:
Rice's Theorem is a generalization of the Halting Problem. A 'non-trivial semantic property' is any property about the program's behavior or function (e.g., 'does this function ever return zero?', 'is this contract vulnerable to a flash loan attack?'). The theorem states that no algorithm can exist that can correctly decide such properties for all possible input programs (smart contracts). This means that while security analysis tools can find specific, known patterns of bugs, they can never be perfect. There will always be smart contracts for which the tool will either fail to terminate, give a wrong answer, or report that it cannot decide.
Incorrect! Try again.
48When Contract A makes an external call to Contract B with a value transfer using address(B).call{value: v}(""), the EVM forwards a limited gas stipend of 2300 gas if a specific gas amount isn't provided. What is the primary security rationale behind this specific, low gas stipend?
Ethereum and smart contracts
Hard
A.To provide just enough gas for the recipient to emit a single event log, but not enough to perform a state-changing external call, thus mitigating most common reentrancy attacks.
B.To prevent the recipient contract from consuming all the gas of the parent call, which would cause the entire transaction to revert unnecessarily.
C.To minimize the overall gas cost of simple ether transfers between contracts, making the network more efficient.
D.To create a standardized gas cost for value transfers that simplifies the calculations for gas estimation tools.
Correct Answer: To provide just enough gas for the recipient to emit a single event log, but not enough to perform a state-changing external call, thus mitigating most common reentrancy attacks.
Explanation:
The 2300 gas stipend was an early, protocol-level defense against reentrancy vulnerabilities. A typical reentrancy attack involves the recipient contract calling back into the original caller before the original function has finished its state updates. An external call costs a minimum of 700 gas, and any storage write costs much more. The 2300 gas stipend is intentionally too small to allow the recipient to make another external call or perform significant state changes. It is generally only enough to log an event. This breaks the attack pattern. While the modern best practice is the Checks-Effects-Interactions pattern, the gas stipend serves as a historical and partial safeguard.
Incorrect! Try again.
49Bitcoin's OP_CHECKSIG opcode verifies a signature against a public key provided in the script. Ethereum has a similar capability via the ecrecover precompiled contract. What is a critical functional difference that allows ecrecover to enable complex mechanisms like meta-transactions, which are not natively possible with OP_CHECKSIG?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Hard
A.ecrecover supports more modern and efficient cryptographic signature schemes than OP_CHECKSIG.
B.ecrecoverrecovers the signer's public address directly from the signature hash and the message, whereas OP_CHECKSIG only verifies a signature against a known public key.
C.ecrecover is a precompiled contract, making its execution significantly faster and cheaper than the OP_CHECKSIG opcode.
D.OP_CHECKSIG can only verify one signature per script, while ecrecover can be called multiple times within a single transaction to verify many signatures.
Correct Answer: ecrecoverrecovers the signer's public address directly from the signature hash and the message, whereas OP_CHECKSIG only verifies a signature against a known public key.
Explanation:
The key is in the name: ecrecover performs elliptic curve signature recovery. This means a smart contract can be given a message and a signature, and the function will return the address of the account that produced that signature. This is the foundation of meta-transactions. A user can sign a message off-chain, and a third-party 'relayer' can submit it to a contract. The contract uses ecrecover to verify that the message was indeed signed by the user, and then executes the action on their behalf. OP_CHECKSIG cannot do this; it can only confirm true or false if a provided signature matches a provided public key, it cannot determine the signer's identity from the signature alone.
Incorrect! Try again.
50A Solidity contract uses inline assembly (Yul) to directly manipulate memory. The code is as follows: function assemble() public pure returns (bytes memory) { bytes memory b = new bytes(64); assembly { mstore(add(b, 0x20), 0xFF) mstore(add(b, 0x40), 0xEE) } return b; }. What will be the hex value of the returned byte array?
Writing smart contracts using Solidity & JavaScript
Hard
A.The function will revert because memory outside the allocated length is accessed.
B.0x0000...00FF followed by 31 zero bytes, then 0x0000...00EE followed by 31 zero bytes.
In Solidity, a dynamic bytes array in memory has a specific layout. The first 32-byte word (at the pointer b) stores the length of the array (in this case, 64). The actual data starts at the memory location add(b, 0x20). The mstore opcode writes a 32-byte (256-bit) word. The first mstore writes 0xFF (as a 32-byte word) to the start of the data section. The second mstore writes 0xEE to the memory location 32 bytes after the start of the data section (add(b, 0x40)). Therefore, the returned 64-byte array will consist of the 32-byte representation of 0xFF followed by the 32-byte representation of 0xEE.
Incorrect! Try again.
51What is the defining characteristic of a Ricardian Contract that distinguishes it from a standard Ethereum smart contract coupled with an off-chain legal agreement?
Using smart contracts to enforce legal contracts
Hard
A.A Ricardian Contract is a single, integrated object that is both a human-readable legal document and machine-readable code, cryptographically binding the two together, often by hashing the legal text and including it in the code.
B.Ricardian Contracts are mutable and can be amended by a court order, whereas smart contracts are immutable.
C.Ricardian Contracts are written in a legally-enforceable programming language like DAML.
D.Ricardian Contracts can only be executed on permissioned blockchains that have a built-in legal framework and identity layer.
Correct Answer: A Ricardian Contract is a single, integrated object that is both a human-readable legal document and machine-readable code, cryptographically binding the two together, often by hashing the legal text and including it in the code.
Explanation:
The core concept of a Ricardian Contract is the tight, verifiable binding of legal prose and executable code. It aims to prevent ambiguity by ensuring that the contract executed by the machine is irrefutably linked to the text agreed upon by the humans. A typical Ethereum smart contract setup has the code on-chain and a PDF agreement stored elsewhere. There is no cryptographic guarantee that the PDF and the code represent the same agreement. A Ricardian contract model would, for example, embed the hash of the legal PDF within the smart contract's state, creating an unbreakable link and ensuring that what you read is what you execute.
Incorrect! Try again.
52A developer writes a function process(uint256[] calldata items) that iterates through the items array to perform a calculation. While this loop is not infinite, it introduces a significant Denial of Service (DoS) vulnerability. Why is this pattern, often called a 'gas griefing' or 'unbounded loop' vulnerability, so dangerous?
The Turing completeness of smart contract languages and verification challenges
Hard
A.The calldata keyword makes the array elements immutable, preventing the function from correctly processing them.
B.If the array is too large, it can cause a stack overflow error in the EVM, which is unrecoverable.
C.An attacker can call the function with an extremely large array, causing the transaction to consume the entire block gas limit and fail. If this function is required for other critical contract operations, the attacker can effectively halt the contract.
D.The EVM charges extra gas for processing arrays larger than 1024 elements, making the transaction uneconomical for legitimate users.
Correct Answer: An attacker can call the function with an extremely large array, causing the transaction to consume the entire block gas limit and fail. If this function is required for other critical contract operations, the attacker can effectively halt the contract.
Explanation:
This vulnerability arises because the computational cost (and thus gas cost) of the function is determined by an external input (items.length). An attacker can craft a transaction that calls process with an array so large that its execution would require more gas than the block gas limit allows. The transaction will always revert. If other functions in the contract depend on process being successfully run (e.g., a function to pay out dividends that first processes all contributions), the attacker can render that functionality unusable for everyone, effectively bricking that part of the contract at a very low cost to themselves.
Incorrect! Try again.
53An EOA submits two transactions. The first has nonce: 42, gasPrice: 20 Gwei. The second, submitted moments later, has nonce: 42, gasPrice: 30 Gwei. Both transactions enter the mempool. Assuming both are valid, what will be the outcome?
Ethereum and smart contracts
Hard
A.Both transactions will be mined, leading to a double execution of the intended action.
B.The transaction with the 20 Gwei gas price will be mined because it was submitted first, and the second transaction will be rejected as a duplicate.
C.Miners will prioritize the transaction with the 30 Gwei gas price. Once it is included in a block, the 20 Gwei transaction becomes invalid and is dropped from the mempool by all nodes.
D.Which transaction gets mined is random and depends on which one a miner's node sees first.
Correct Answer: Miners will prioritize the transaction with the 30 Gwei gas price. Once it is included in a block, the 20 Gwei transaction becomes invalid and is dropped from the mempool by all nodes.
Explanation:
This describes how to replace a pending transaction on Ethereum. A transaction is uniquely identified by the sender's address and its nonce. Only one transaction per nonce can be confirmed for any given account. When multiple transactions with the same address and nonce are in the mempool, they are in competition. Since miners are economically rational, they will almost always pick the transaction that offers a higher fee (in this case, the one with 30 Gwei gasPrice). Once this higher-fee transaction is mined, the other transaction with the same nonce is rendered invalid and is purged from the network.
Incorrect! Try again.
54What is the primary purpose of the EIP-712 standard for typed structured data hashing and signing, and what specific class of vulnerability does it mitigate compared to the older eth_sign method?
Writing smart contracts using Solidity & JavaScript
Hard
A.It standardizes a more gas-efficient signature verification algorithm, reducing the on-chain cost of ecrecover.
B.It enables signing transactions with hardware wallets, a feature that was not supported by eth_sign.
C.It prevents signature replay attacks across different blockchains (e.g., Ethereum and Polygon) by mandating the inclusion of the chainId in the signed data.
D.It mitigates phishing and replay attacks across different DApps by creating a domain-separated, human-readable context for the data being signed, ensuring a signature for one application cannot be used in another.
Correct Answer: It mitigates phishing and replay attacks across different DApps by creating a domain-separated, human-readable context for the data being signed, ensuring a signature for one application cannot be used in another.
Explanation:
The older eth_sign method required users to sign an opaque 32-byte hash, e.g., 0x1c8aff95.... It was impossible for the user to know what they were actually signing. Furthermore, a malicious DApp could craft a message that produced the same hash as a legitimate action on a different, vulnerable DApp, and trick the user into signing it. EIP-712 solves this by defining a standard for hashing structured data. The data is presented to the user in a readable format, and the final hash includes a domainSeparator (containing the DApp's name, version, contract address, etc.). This makes the signature unique to that specific DApp and intended action, preventing cross-application replay attacks.
Incorrect! Try again.
55Bitcoin Script is a stack-based, non-Turing-complete language. Which of the following features, fundamental to general-purpose programming and present in Solidity, is explicitly forbidden in Bitcoin Script to prevent infinite loops and ensure termination?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Hard
A.Access to transaction-specific data like output values or lock times.
B.Conditional flow control using opcodes like OP_IF and OP_ELSE.
C.Arithmetic operations such as OP_ADD and OP_SUB.
D.Backward jumps or loops (e.g., GOTO or for/while constructs).
Correct Answer: Backward jumps or loops (e.g., GOTO or for/while constructs).
Explanation:
The primary reason Bitcoin Script is not Turing-complete is the intentional omission of backward jumps or looping instructions. The script is executed sequentially from top to bottom. While it has conditional statements (OP_IF/OP_ENDIF) that allow it to skip sections of code (forward jumps), there is no opcode that allows the instruction pointer to move to a previous point in the script. This structural limitation guarantees that every script will terminate after executing a finite number of opcodes, thus completely avoiding the Halting Problem and the need for a gas-like metering system.
Incorrect! Try again.
56The EVM storage model works with 32-byte slots. Solidity packs multiple variables into a single storage slot if they fit. Consider the contract: contract C { uint128 a; uint128 b; }. A user calls a function that executes a = type(uint128).max; b = 1;. What will be the raw hex value stored in storage slot 0?
Ethereum and smart contracts
Hard
A.The operation will fail because two variables cannot be written to the same slot in one transaction.
Solidity packs state variables from right to left (less significant bytes to more significant bytes) within a storage slot. The first variable declared, a, will occupy the lower-order 16 bytes (128 bits) of slot 0. The second variable, b, will occupy the higher-order 16 bytes. type(uint128).max is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF. 1 is 0x01. So, a's value is placed in the right half of the 32-byte word, and b's value is placed in the left half. The resulting 32-byte value in slot 0 is the concatenation of b's 16-byte representation and a's 16-byte representation.
Incorrect! Try again.
57A smart contract for a decentralized autonomous organization (DAO) is designed to be governed by its token holders. A legal challenge arises from a real-world event not anticipated in the code. The principle of "code is law" is invoked by one party, while another seeks external legal recourse. What architectural pattern could have been implemented in the DAO to bridge this gap between rigid code and the need for external, human-centric dispute resolution?
Using smart contracts to enforce legal contracts
Hard
A.Integrating with a decentralized court system (e.g., Kleros, Aragon Court) and including a function that allows an EOA controlled by that system's resolution protocol to trigger a specific, pre-defined action (like an emergency pause or the reversal of a specific transaction).
B.Making the entire contract mutable so that a judge can order direct changes to the code.
C.Writing the smart contract in a natural language processing language so it can interpret legal documents directly.
D.A centralized 'admin key' held by a law firm that can override any DAO decision.
Correct Answer: Integrating with a decentralized court system (e.g., Kleros, Aragon Court) and including a function that allows an EOA controlled by that system's resolution protocol to trigger a specific, pre-defined action (like an emergency pause or the reversal of a specific transaction).
Explanation:
The 'code is law' absolutism is often impractical. A sophisticated solution is to build an 'appeal' mechanism directly into the system's logic. By designating a decentralized arbitration service as the arbiter for certain disputes, the DAO can remain trust-minimized while still having an outlet for complex, unforeseen situations. The smart contract would have a function that can only be called by the arbitration contract. If the decentralized court rules in a particular way, it can call this function to enforce its ruling on-chain. This creates a 'decentralized rule of law' that respects both the automated nature of the code and the need for human judgment in exceptional cases.
Incorrect! Try again.
58When interacting with a smart contract from a JavaScript application using a library like ethers.js, a function returns a uint256 value representing an ERC20 token balance with 18 decimals. The value is 100000000000000000000. If a developer attempts to process this value directly as a standard JavaScript Number (e.g., let balance = await contract.balanceOf(address); let newBalance = balance / 2;), what will happen?
Writing smart contracts using Solidity & JavaScript
Hard
A.The code will throw a TypeError because the returned value is not a primitive number.
B.The developer will experience a loss of precision. The returned BigNumber object will be coerced into a JavaScript Number, exceeding Number.MAX_SAFE_INTEGER and resulting in an incorrect value for newBalance.
C.ethers.js automatically converts all uint256 values into strings to prevent precision loss, so the division operation will fail.
D.The calculation will work correctly, and newBalance will be 50000000000000000000.
Correct Answer: The developer will experience a loss of precision. The returned BigNumber object will be coerced into a JavaScript Number, exceeding Number.MAX_SAFE_INTEGER and resulting in an incorrect value for newBalance.
Explanation:
This is a very common and critical error for new Web3 developers. JavaScript's native Number type is a 64-bit floating-point number and cannot safely represent integers larger than Number.MAX_SAFE_INTEGER (which is ). The value 100 * 10^{18} is far larger than this. Libraries like ethers.js and web3.js return large integer values as BigNumber objects to preserve their precision. Any attempt to use standard arithmetic operators (+, -, *, /) on these objects directly with JavaScript Numbers will lead to incorrect results. The correct way is to use the methods provided by the BigNumber library itself, such as balance.div(2).
Incorrect! Try again.
59An often-cited difference is that Bitcoin is 'stateless' while Ethereum is 'stateful'. What does this mean in the context of how their respective virtual machines operate on data?
Comparing Bitcoin scripting vs. Ethereum smart contracts
Hard
A.Ethereum transactions can fail and revert, effectively being stateless, while all valid Bitcoin transactions are final and change the state of the UTXO set.
B.Bitcoin scripts are purely functional: they execute with data from the spending transaction and cannot access or modify any state outside of that transaction. Ethereum contracts can read and write to persistent storage associated with their address.
C.Bitcoin's state is reset after every block, whereas Ethereum's state persists indefinitely.
D.Bitcoin nodes do not store the entire blockchain history, whereas Ethereum nodes do.
Correct Answer: Bitcoin scripts are purely functional: they execute with data from the spending transaction and cannot access or modify any state outside of that transaction. Ethereum contracts can read and write to persistent storage associated with their address.
Explanation:
The 'state' of the Bitcoin ledger is the set of all UTXOs. A Bitcoin script's only job is to return true or false to validate the spending of specific UTXOs. The script itself cannot read the state of other UTXOs or write to a persistent database. Its execution context is ephemeral. In contrast, an Ethereum smart contract is like an object with its own internal, persistent storage. A function call can read data that was stored by a previous transaction and can write new data that will persist for future transactions to read. This ability to maintain and modify a persistent, address-specific state is what allows for complex applications like DAOs, ENS, and DeFi protocols.
Incorrect! Try again.
60What is the key difference in gas consumption and execution context between call, delegatecall, and staticcall in the EVM?
Ethereum and smart contracts
Hard
A.call preserves msg.sender and storage context, delegatecall changes them, and staticcall is for read-only calls.
B.All three execute in the same context, but staticcall prevents writes, and delegatecall allows for library-like code reuse.
C.delegatecall is the most gas-efficient, followed by staticcall, and then call.
D.call creates a new execution context (storage, msg.sender are new), delegatecall uses the storage and context of the calling contract, and staticcall is a variant of call that forbids any state-modifying operations.
Correct Answer: call creates a new execution context (storage, msg.sender are new), delegatecall uses the storage and context of the calling contract, and staticcall is a variant of call that forbids any state-modifying operations.
Explanation:
This is a crucial distinction. When Contract A calls Contract B, the execution inside B has msg.sender as A, and any storage writes affect B's storage. When A delegatecalls B, B's code is executed as if it were A's code. This means msg.sender and msg.value remain the same as in A's original call, and crucially, any storage writes modify A's storage. This is powerful for proxies and libraries but dangerous if not handled correctly. staticcall is like call, but it is guaranteed to be read-only; the EVM will revert the transaction if any opcode that modifies state (like SSTORE, LOG, etc.) is used during a staticcall.