Test Flashcards
11 cards from real Ethereum Developer practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 11 Test flashcards as text
If you engage with a smart contract and observe a 50,000 gas usage at a 15 Gwei gas cost, how much Ether would you be required to pay the miner?
Answer: 750,000,000,000,000 Wei
To calculate the total Ether paid, multiply the gas usage by the gas cost: 50,000 gas * 15 Gwei/gas = 750,000 Gwei. Since 1 Gwei is 1,000,000,000 Wei (10^9 Wei), convert Gwei to Wei: 750,000 Gwei * 1,000,000,000 Wei/Gwei = 750,000,000,000,000 Wei. This conversion is crucial for understanding the actual cost in the smallest denomination of Ether.
Which is TRUE about the Fallback function?
Answer: Can be as logical as you like, but it's best to keep it brief and not go over the 2300 gas allotment.
The fallback function in Solidity is executed when a contract receives Ether without any data, or when a function is called that doesn't exist. It has a strict gas limit of 2300 gas when called by a plain Ether transfer, making it crucial to keep its logic minimal. While it can contain logic, exceeding this gas limit will cause the transaction to fail, so brevity is key for successful Ether transfers.
Which is TRUE about Storing almost all data in the Ethereum Blockchain?
Answer: Using a Merkle Patricia Trie
Ethereum uses a Merkle Patricia Trie (MPT) to store all state data, including accounts, balances, contract storage, and transaction receipts. This data structure is highly efficient for verifying data integrity and allows for quick retrieval and updates of information. The MPT is fundamental to Ethereum's ability to maintain a consistent and verifiable global state across all nodes.
Solidity is assembled into
Answer: Bytecodes, which function similarly to opcodes but are executed instruction by instruction.
Solidity code is compiled into Ethereum Virtual Machine (EVM) bytecode. This bytecode consists of a series of low-level instructions, known as opcodes, which the EVM executes sequentially. Each opcode performs a specific operation, making the bytecode the executable form of the smart contract on the Ethereum blockchain.
How much ETH was generated from 1 BTC at the start of the Ethereum token sale?
Answer: 2000 ETH
During the initial two weeks of the Ethereum token sale, which began in July 2014, the exchange rate was set at 2000 ETH for every 1 BTC. This early bird rate was part of the presale structure to incentivize early participation in the network's funding. The rate subsequently decreased over the duration of the sale.
Which statement is TRUE regarding view and Pure Functions:
Answer: State variables can only be accessed from by view functions. A pure function is unable to change or access state.
View functions in Solidity are restricted to reading state variables and cannot modify the blockchain state. Pure functions are even more restrictive; they cannot read or modify any state variables, operating solely on their input parameters and local variables. Neither type of function can alter the contract's state on the blockchain.
Checking an address's balance repeatedly inside a smart contract's loop
Answer: Doesn't require any gas
Accessing an address's balance within a smart contract loop, such as using `address.balance`, is a read-only operation that queries existing state information. Reading from the blockchain state does not incur additional gas costs for each read operation beyond the initial transaction execution cost. Gas is primarily consumed for state modifications or complex computations.
What address will be in msg.sender in Contract B if a User calls Contract A and that calls Contract B?
Answer: Contract A
In Solidity, `msg.sender` always refers to the immediate external account or contract that initiated the current function call. If a user calls Contract A, and Contract A then calls Contract B, the `msg.sender` within Contract B's execution context will be the address of Contract A. The original user's address would be available via `tx.origin`.
How much Ether would you have to pay the miner if you interacted with a smart contract and saw a gas usage of 50,000 gas at a cost of 15 Gwei?
Answer: 750,000,000,000,000 Wei
To calculate the total Ether paid, multiply the gas usage by the gas price. Given 50,000 gas and 15 Gwei (15 * 10^9 Wei), the total cost is 50,000 * 15 * 10^9 Wei. This calculation results in 750,000,000,000,000 Wei, which is the amount paid to the miner for executing the transaction.
Smart Contracts are programmable in
Answer: Solidity, Viper, LLL, and Serpent since they are bytecode-compiled high-level languages.
Ethereum smart contracts are primarily written in high-level languages that compile into EVM bytecode. Solidity is the most widely used, but other languages like Vyper (formerly Viper), LLL (Low-Level Lisp), and Serpent (now deprecated) were also designed for this purpose. These languages provide abstractions over the raw EVM opcodes.
Complete the statement : "Gas costs accrue on..."
Answer: Sending a transaction regardless of its content.
Gas costs are fundamental to the Ethereum network and are incurred for every transaction, regardless of its specific content. Whether you're sending Ether, deploying a new contract, or calling a function on an existing contract, gas is required to compensate miners for the computational resources used to process and validate the transaction on the blockchain.