BTA CBDE flashcards
BTA CBDE · Build recall with a focused review session.
32 cards. Read the term and the definition here. The deck at the top of this page is optional.
- EOA vs contract account
- An EOA is controlled by a private key, has no code, and originates transactions. A contract account has code and storage, cannot initiate transactions, and acts only when called.
- Effective gas price
- After EIP-1559 the price paid per gas equals the block baseFee plus the priority fee the sender offers, and the total fee is gasUsed multiplied by that sum.
- Base fee mechanism
- Each block's baseFee is burned and adjusts up or down based on how full the previous block was relative to the 50 percent gas target, damping congestion spikes.
- Account nonce
- For an EOA, the nonce counts sent transactions and enforces ordering; for a contract, it counts contracts created and starts at one under EIP-161.
- Event topics and data
- Indexed event parameters become topics usable for log filtering, while non-indexed parameters are ABI-encoded into the log data field. Contracts cannot read logs.
- EVM gas and memory
- Every opcode charges gas, memory expansion costs grow quadratically with size, and a revert rolls back state while still consuming gas already spent.
- Storage vs memory vs calldata
- Storage persists between calls, memory is a temporary per-call copy, and calldata is read-only input data. External function reference parameters default to calldata.
- Function visibility keywords
- Public is callable internally and externally, external only externally, internal from this contract and derived ones, and private only from the declaring contract, though all code is on-chain.
- receive and fallback
- receive() handles calls with empty calldata, typically plain ETH transfers. fallback() handles unmatched calldata. Both must be payable to accept ETH.
- Modifier execution order
- Modifiers wrap the function body at the underscore placeholder. Multiple modifiers nest in declaration order, so the first listed runs its pre-body code first.
- Custom errors versus require
- Declaring error X and reverting with it encodes a four-byte selector plus arguments, cheaper than require strings, and is surfaced by tooling as a named revert.
- Storage slot packing
- Adjacent state variables smaller than 32 bytes can share one slot to save gas, but structs and arrays always begin a new slot and cannot pack across boundaries.
- ecrecover zero-address pitfall
- ecrecover returns address(0) when the signature is invalid rather than reverting, so callers must check the recovered address is nonzero and matches the expected signer.
- Checked arithmetic default
- Since Solidity 0.8.0, overflow and underflow revert automatically. An unchecked block disables these checks to save gas where overflow is provably impossible.
- Hardhat Network features
- Hardhat's in-process EVM provides Solidity console.log, readable stack traces, instant mining, and mainnet forking configured through forking.url in hardhat.config.
- Foundry toolchain
- forge builds and tests, cast queries and sends transactions, and anvil runs a local node. Tests are Solidity contracts using cheatcodes such as vm.prank and vm.deal.
- Optimizer runs setting
- The Solidity optimizer runs value trades deployment size against runtime cost: lower values favor smaller bytecode, higher values favor cheaper repeated execution.
- Ethers.js provider vs signer
- A provider performs read-only calls and queries chain state, while a signer holds an account and authorizes state-changing transactions. Contracts need a signer to write.
- OpenZeppelin Contracts
- An audited library of reusable Solidity primitives such as ERC20, ERC721, Ownable, AccessControl, and ReentrancyGuard, installed via npm and imported by path.
- Secret key management
- Private keys and RPC URLs are stored in a .env file excluded from version control, loaded via dotenv, and referenced in config as process.env values.
- eth_call versus eth_sendTransaction
- eth_call simulates execution against current state, costs no gas, and returns data immediately. eth_sendTransaction broadcasts a signed transaction and returns only a hash.
- Injected wallet provider
- Wallets inject window.ethereum, exposing eth_requestAccounts to connect, eth_chainId to identify the network, and accountsChanged and chainChanged events the UI must handle.
- Transaction receipt polling
- A sent transaction yields a hash before mining. Clients poll eth_getTransactionReceipt until status is 1 for success or 0 for revert, then decode emitted logs.
- Token decimals conversion
- ERC-20 balances are integers scaled by ten to the power of decimals. Use parseUnits before sending amounts and formatUnits when displaying them to users.
- EIP-712 typed signing
- Structured data signing presents named fields to users and hashes them with a domain separator, which the contract verifies via ecrecover to prevent cross-chain replay.
- Event backfill with queryFilter
- Live updates arrive through contract.on subscriptions, but history requires queryFilter over bounded block ranges because RPC providers cap the number of blocks scanned.
- Reentrancy defense
- Follow checks-effects-interactions by updating balances before external calls, and add a ReentrancyGuard mutex so a reentrant call reverts before reaching sensitive logic.
- CREATE2 address derivation
- The address is the last 20 bytes of keccak256 of 0xff, the deployer address, a chosen salt, and keccak256 of the init code, enabling deterministic deployment.
- Proxy storage collision risk
- Upgradeable proxies share storage with implementations, so layouts must be append-only and slot conflicts checked with tooling before any upgrade is deployed.
- Initializer protection
- Upgradeable contracts use initializers instead of constructors, so implementations must call _disableInitializers in the constructor to prevent anyone initializing the logic contract directly.
- Oracle manipulation risk
- Spot reserves from a single AMM can be moved within one transaction, so price feeds should use time-weighted averages or decentralized oracles with staleness checks.
- Contract test layers
- Unit tests isolate functions, fork tests replay real mainnet state, fuzz and invariant tests probe accounting edge cases, and gas snapshots catch regressions across changes.