CBSA Smart Contracts & Decentralized Applications 3 — Questions and Answers
Question 1: Which Ethereum Improvement Proposal introduced the concept of a standardized event interface for token transfers, forming the basis of ERC-20?
- EIP-55
- EIP-20 (Correct answer)
- EIP-712
- EIP-1559
Correct answer: EIP-20
EIP-20 formally defined the ERC-20 fungible token standard, including the `Transfer` and `Approval` events.
Question 2: What is the key difference between `call`, `delegatecall`, and `staticcall` in Solidity?
- `delegatecall` runs code in the callee's context; `call` runs in the caller's context; `staticcall` allows state changes
- `call` runs code in the callee's context; `delegatecall` uses the caller's storage/context; `staticcall` disallows state changes (Correct answer)
- All three are identical but differ only in gas forwarding
- `staticcall` is used only for constructor calls
Correct answer: `call` runs code in the callee's context; `delegatecall` uses the caller's storage/context; `staticcall` disallows state changes
`delegatecall` executes the callee's logic in the caller's storage context, making it fundamental to proxy upgradeability patterns.
Question 3: In Hyperledger Fabric, what is chaincode equivalent to in Ethereum's smart contract ecosystem?
- Validators
- Smart contracts (Correct answer)
- Oracles
- Gas meters
Correct answer: Smart contracts
Chaincode in Hyperledger Fabric is the equivalent of smart contracts, defining business logic that runs on the permissioned ledger.
Question 4: What problem does the 'checks-effects-interactions' pattern solve in smart contract development?
- Integer overflow and underflow vulnerabilities
- Reentrancy vulnerabilities by updating state before making external calls (Correct answer)
- Front-running attacks by randomizing transaction ordering
- Gas limit exhaustion by batching multiple operations
Correct answer: Reentrancy vulnerabilities by updating state before making external calls
By performing all checks, then updating state, then making external calls, this pattern prevents reentrancy attacks from exploiting stale state.
Question 5: Which Layer 2 scaling solution uses fraud proofs and requires a challenge period before withdrawals are finalized?
- ZK-Rollup
- Optimistic Rollup (Correct answer)
- State channel
- Plasma
Correct answer: Optimistic Rollup
Optimistic Rollups assume transactions are valid by default and rely on a challenge period during which fraud proofs can be submitted to dispute invalid state.
Question 6: What is the primary purpose of an ABI (Application Binary Interface) in Ethereum smart contract development?
- To encrypt transaction data before broadcasting to the network
- To define the interface for interacting with a smart contract, encoding function calls and event data (Correct answer)
- To store the bytecode of a deployed contract on-chain
- To generate deterministic wallet addresses from private keys
Correct answer: To define the interface for interacting with a smart contract, encoding function calls and event data
The ABI describes a contract's functions and events, enabling external applications and other contracts to correctly encode and decode interactions.
Question 7: In smart contract security, what is a 'front-running' attack?
- Deploying a malicious contract before the legitimate one to claim the same address
- A miner or bot observing a pending transaction and submitting a competing transaction with higher gas to execute first (Correct answer)
- Exploiting integer overflow to wrap token balances to the maximum value
- Draining a contract by calling its fallback function repeatedly
Correct answer: A miner or bot observing a pending transaction and submitting a competing transaction with higher gas to execute first
Front-running exploits the public mempool by placing a higher-gas transaction ahead of a known pending one to profit from the anticipated outcome.
Which Ethereum Improvement Proposal introduced the concept of a standardized event interface for token transfers, forming the basis of ERC-20?