Smart Contract Fundamentals Flashcards
6 cards from real Blockchain Technology practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Smart Contract Fundamentals flashcards as text
A developer deploys a smart contract to the Ethereum mainnet. After deployment, they discover a logical bug in one of the functions. What is the primary consequence of blockchain's immutability in this scenario?
Answer: The contract's code is permanently unchangeable, and the bug cannot be directly fixed in the deployed version.
Immutability is a core feature of blockchains, meaning that once data (like a smart contract) is written, it cannot be altered or deleted. This ensures security and trust but also means that any bugs in a deployed contract are permanent in that specific instance. Mitigation requires deploying a new, corrected contract and migrating state, or having implemented an upgradeability pattern (like a proxy) beforehand.
What is the primary function of the Ethereum Virtual Machine (EVM)?
Answer: To provide a sandboxed, deterministic execution environment for smart contracts.
The EVM is the computation engine of the Ethereum network. It acts as a decentralized, sandboxed virtual machine that executes smart contract bytecode. This isolated environment ensures that smart contracts run exactly as written on all nodes in the network without interfering with the host system, which is essential for maintaining consensus.
A smart contract is designed to trigger an insurance payout for a flight delay. To function correctly, it needs to know the official landing time of a specific flight. How does a smart contract on a deterministic blockchain typically obtain this type of real-world information?
Answer: Through a trusted external data feed service known as a blockchain oracle.
Blockchains and smart contracts cannot directly access off-chain data because it would break the deterministic nature required for consensus. A blockchain oracle is a necessary third-party service that acts as a bridge, fetching and verifying real-world data (like flight times or asset prices) and relaying it to the smart contract in a secure and reliable way.
A smart contract has a `withdraw` function where the code first sends Ether to the user's address and then updates the user's balance in the contract's storage. Which classic smart contract vulnerability does this specific order of operations create?
Answer: Reentrancy Attack
This sequence creates a reentrancy vulnerability. A malicious contract can exploit this by implementing a fallback function that recursively calls the `withdraw` function *after* receiving the Ether but *before* the original call updates the balance. This allows the attacker to drain the contract's funds. The secure pattern is Checks-Effects-Interactions: update the balance first, then send the Ether.
Which of the following best describes the role of "gas" in the context of the Ethereum blockchain?
Answer: A unit of measurement for the computational effort required to execute operations.
Gas is the unit that measures the amount of computational work required to perform operations, such as transactions or smart contract executions, on the Ethereum network. Each operation has a fixed gas cost. The total transaction fee (paid in ETH) is the amount of gas used multiplied by the gas price (in Gwei), which prevents network spam and compensates validators for their computational resources.
A developer is creating a decentralized autonomous organization (DAO) where token holders can vote on proposals. The smart contract automatically tallies votes and executes the winning proposal if a quorum is met. What fundamental property of smart contracts ensures this process will execute exactly as programmed without manual intervention?
Answer: Self-Execution
Self-execution is the core principle that smart contracts are programs that automatically run when predetermined conditions are met. The terms of the agreement (the DAO's voting rules) are written directly into code, and the contract will enforce those rules (tallying votes, executing proposals) without the need for a traditional intermediary.