CBSA Smart Contracts & Decentralized Applications 4 — Questions and Answers
Question 1: What is the role of an oracle in a decentralized application ecosystem?
- To validate block headers on behalf of light clients
- To provide external real-world data to smart contracts that cannot access off-chain information natively (Correct answer)
- To aggregate user transactions into rollup batches
- To store encrypted smart contract source code
Correct answer: To provide external real-world data to smart contracts that cannot access off-chain information natively
Oracles bridge the gap between blockchains and the external world, feeding data like prices or weather into smart contracts.
Question 2: Which ERC standard extends ERC-20 to allow token approvals and transfers to be performed in a single transaction via off-chain signatures?
- ERC-777
- ERC-2612 (Correct answer)
- ERC-4626
- ERC-1155
Correct answer: ERC-2612
ERC-2612 adds a `permit` function that uses EIP-712 typed signatures to set allowances without a separate on-chain approval transaction.
Question 3: In the context of Ethereum smart contracts, what does 'immutability' imply about deployed bytecode?
- The contract's storage variables cannot be changed after deployment
- The contract's code cannot be modified after deployment, only its state can change (Correct answer)
- Both the code and state are frozen at the block of deployment
- The contract can be paused but not deleted
Correct answer: The contract's code cannot be modified after deployment, only its state can change
Once deployed, a contract's bytecode is permanently stored on-chain and cannot be altered; only its state variables can change through function execution.
Question 4: What is a 'flash loan' in DeFi and what unique property enables it?
- A loan collateralized by NFTs that must be repaid in 30 days
- An uncollateralized loan that must be borrowed and repaid within the same transaction, enforced by smart contract atomicity (Correct answer)
- A micro-loan issued automatically by a DAO governance vote
- A cross-chain loan bridged between Ethereum and a sidechain
Correct answer: An uncollateralized loan that must be borrowed and repaid within the same transaction, enforced by smart contract atomicity
Flash loans exploit atomic transaction execution — if the loan is not repaid by the end of the same transaction, the entire transaction reverts.
Question 5: Which Solidity keyword marks a function as not modifying contract state, allowing it to be called without a transaction?
- immutable
- view (Correct answer)
- payable
- virtual
Correct answer: view
Functions marked `view` promise not to modify state and can be called off-chain for free using `eth_call`.
Question 6: What is the primary risk of storing sensitive data directly in a smart contract's storage on a public blockchain?
- It significantly increases gas costs beyond practical limits
- All data stored on-chain is publicly visible, so no truly sensitive data should be stored in plain text (Correct answer)
- The Ethereum VM does not support storing string data types
- On-chain storage is deleted after 256 blocks
Correct answer: All data stored on-chain is publicly visible, so no truly sensitive data should be stored in plain text
Blockchain storage is public and permanent, so storing sensitive plaintext data (e.g., private keys, PII) on-chain exposes it to anyone.
Question 7: In Ethereum's EVM, what is the maximum size of a smart contract's bytecode?
- 128 KB
- 24.576 KB (Correct answer)
- 64 KB
- 8 KB
Correct answer: 24.576 KB
EIP-170 enforces a maximum contract code size of 24,576 bytes (approximately 24 KB) to prevent DoS attacks via large contracts.
What is the role of an oracle in a decentralized application ecosystem?