blockchain_web3 25 Q&As

Blockchain Web3 FAQ & Answers

25 expert Blockchain Web3 answers researched from official documentation. Every answer cites authoritative sources you can verify.

unknown

25 questions
A

Storage is most expensive: 20,000 gas for zero-to-non-zero writes (SSTORE), 5,000 gas for existing non-zero slots, 2,100 gas for reads (SLOAD). Memory costs 3 gas per 32-byte word beyond 724 bytes threshold. Calldata is cheapest: read-only, no copying overhead, 16 gas per non-zero byte (post-EIP-2028). For external function array parameters, calldata saves 35% gas vs memory. Use calldata for external inputs, memory for internal processing, storage only when persistence required. Example: function process(uint256[] calldata data) external outperforms uint256[] memory data significantly.

99% confidence
A

EIP-1559 (deployed August 5, 2021) splits transaction fees into base fee and priority fee. Base fee: algorithmically adjusted by protocol targeting 50% block fullness, increases up to 12.5% per block when demand exceeds target, decreases 12.5% when below target, burned (permanently destroyed). Priority fee (tip): optional user-set amount paid directly to validators, incentivizes faster inclusion. Total fee = (base fee + priority fee) × gas used. Example: 21,000 gas × (10 gwei base + 2 gwei tip) = 252,000 gwei total. Over 3.5 million ETH burned since launch, making ETH potentially deflationary. Recommended 2-3 gwei priority for timely inclusion.

99% confidence
A

Security pattern organizing function logic in three steps: 1) Checks - validate preconditions (require(balance[msg.sender] >= amount)), 2) Effects - update state BEFORE external calls (balance[msg.sender] -= amount), 3) Interactions - external calls last (payable(msg.sender).transfer(amount)). Critical: state changes must complete before external calls to prevent reentrancy. Prevented 2016 DAO hack ($60M). Still essential in 2025: combine with OpenZeppelin ReentrancyGuard for defense-in-depth. Solidity 0.8+ example: Always update balances/state before .call(), .transfer(), or external contract calls. Pattern remains cornerstone of smart contract security.

99% confidence
A

View functions read but don't modify state: can access storage variables, global variables (block.timestamp, msg.sender). Pure functions neither read nor modify state: only use parameters and local variables, no storage access. Both marked in function signature (function getName() public view returns (string) vs function add(uint a, uint b) public pure returns (uint)). Critical difference: view incurs gas when called on-chain, pure does not access any state. Neither consumes gas when called off-chain via JSON-RPC. Compiler enforces restrictions - warns/errors if violated. Use view for getters, pure for calculations. Solidity 0.8+ strictly enforces these modifiers.

99% confidence
A

ERC-20: Fungible tokens, each identical and divisible (USDC, DAI, governance tokens). 500,000+ deployed as of 2025. ERC-721: Non-fungible tokens (NFTs), each unique and indivisible (CryptoPunks, BAYC, digital art). 10 million+ minted. ERC-1155: Multi-token standard supporting both fungible and non-fungible in single contract, batch transfers reduce gas dramatically. Dominant in gaming (currencies + unique items). Key difference: ERC-1155 handles multiple token types in one contract with batch operations (up to 10x gas savings), ERC-20/721 require separate contracts. 2025 market: ERC-20 for DeFi, ERC-721 for collectibles, ERC-1155 for gaming/metaverse. Choose based on use case and gas efficiency needs.

99% confidence
A

require(): Input validation and preconditions, refunds unused gas on failure, syntax: require(condition, "Error message"). Use for user input validation, access control, external call validation. assert(): Internal invariants that should never fail, consumes ALL gas on failure (signals bug), no error message. Use only for checking impossible conditions post-state-changes. revert(): Explicit transaction reversal, more flexible than require, supports custom errors (Solidity 0.8.4+): revert CustomError(param). Best practice 2025: Use custom errors with revert for 99% less gas vs require strings. Example: if (amount == 0) revert ZeroAmount(); saves ~500 gas vs require(amount != 0, "Zero amount"). Custom errors recommended for production code.

99% confidence
A

September 15, 2022 at 06:42:42 UTC (block 15,537,393). Transitioned Ethereum from Proof of Work (miners) to Proof of Stake (validators). Major changes: 99.95% energy reduction, eliminated GPU mining, validators stake 32 ETH minimum, block creation via random validator selection proportional to stake. Running stably 2+ years. 2025 stats: 35.3 million ETH staked (29% of supply), 1.06 million active validators, 2.9-5% APY. Pectra upgrade (May 2025) via EIP-7251 raised validator cap from 32 ETH to 2,048 ETH allowing consolidation. Proof of Stake now production-proven at scale.

99% confidence
A

Gwei (gigawei) is denomination of ETH for gas pricing. 1 gwei = 0.000000001 ETH (10^-9 ETH, one-billionth). Full hierarchy: 1 ETH = 1,000,000,000 gwei = 1,000,000,000,000,000,000 wei. Gas prices quoted in gwei because transaction costs typically millions of wei, making gwei more readable. Example: 21,000 gas × 10 gwei = 210,000 gwei = 0.00021 ETH. Post-EIP-1559: base fee and priority fee both expressed in gwei. Typical 2025 base fees: 5-30 gwei (mainnet), 0.001-0.01 gwei (L2s). Use gwei for human-readable gas calculations, wei for smart contract math.

99% confidence
A

Calldata is read-only and doesn't copy data to memory, dramatically cheaper gas. Memory requires copying entire array from calldata to memory (expensive operation). Savings: 35% average gas reduction for array parameters (2024 L2 study). Example: function process(uint256[] calldata ids) vs uint256[] memory ids. Calldata costs 16 gas/byte (non-zero, post-EIP-2028), memory costs 3 gas per 32-byte word plus copy overhead. Use calldata for all external function parameters that won't be modified. Restriction: calldata is immutable. If modification needed, explicitly copy: uint256[] memory mutableIds = ids;. Best practice 2025: Default to calldata for external functions unless modification required.

99% confidence
A

OpenZeppelin ReentrancyGuard is a contract module preventing reentrancy attacks via nonReentrant modifier. Import with import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; (v4.x) or from utils/ (v5.x). Works via mutex: sets _status=ENTERED before function execution, reverts if already entered, resets after completion. Apply to functions with external calls/transfers. Gas optimized: uses constants NOT_ENTERED=1, ENTERED=2. Place nonReentrant before other modifiers. Protected functions can't call each other (workaround: make private with external nonReentrant entry points). V5.x adds ReentrancyGuardTransient for EIP-1153 transient storage. Use with Checks-Effects-Interactions pattern for defense-in-depth.

99% confidence
A

21,000 gas units for basic ETH transfer between externally owned accounts (EOAs). This is the minimum base gas for any Ethereum transaction (includes 21,000 intrinsic gas). Breakdown: 21,000 base transaction cost. Additional costs for: data (16 gas/non-zero byte calldata, 4 gas/zero byte), contract execution (varies), storage writes (20,000 gas zero-to-non-zero). Example: Simple payable(address).transfer(amount) = 21,000 gas. Contract interaction with fallback function may add 2,300 gas (transfer/send stipend). Post-EIP-1559: Total cost = 21,000 × (base fee + priority fee). At 10 gwei: 21,000 × 10 = 210,000 gwei = 0.00021 ETH.

99% confidence
A

Base fee is burned (permanently destroyed), sent to address(0), never paid to validators. Only priority fee (tip) rewards validators. Burning mechanism makes ETH potentially deflationary when base fee burn > staking issuance. Impact since August 2021 launch: 3.5+ million ETH burned (worth billions USD). Burn rate varies with network usage: high activity = high base fee = more burn. 2025 average: 2-5 ETH/minute burned during peak usage. Formula: burned_ETH = base_fee × gas_used. Deflationary periods: When daily burn exceeds ~1,700 ETH (current PoS issuance). View real-time burn: ultrasound.money. This is core economic change making ETH "ultrasound money".

99% confidence
A

Use assert() ONLY for internal invariants that should never be false - failing assert indicates a bug requiring contract fix. Examples: validating mathematical invariants (total supply equals sum of balances), checking impossible conditions after state changes, overflow protection (pre-0.8.0). Critical: assert() consumes ALL remaining gas on failure (unlike require), no error message, generates Panic error. Solidity 0.8+ built-in overflow checks make assert() less common. Modern usage: Post-state-change validation: balance1 + balance2 == totalSupply. DO NOT use for: user input validation (use require), business logic checks (use revert), gas-sensitive operations. Best practice 2025: Rare usage, prefer custom errors with revert for most validation.

99% confidence
A

32 ETH minimum stake to run full validator node in Proof of Stake. Validator responsibilities: propose/attest blocks, run node 24/7, maintain >99% uptime for optimal rewards. Rewards: 2.9-5% APY (varies with total staked, network activity). Penalties: Slashing for malicious behavior (double-signing, prolonged downtime). 2025 alternatives: Liquid staking (Lido, Rocket Pool) allows <32 ETH participation, pooled staking (join with others), staking-as-a-service (third-party runs node). Pectra upgrade (May 2025, EIP-7251): Validators can now stake up to 2,048 ETH (consolidation), but 32 ETH remains minimum entry. Hardware: 16GB RAM, 2TB SSD, reliable internet recommended.

99% confidence
A

Single contract supports both fungible and non-fungible tokens simultaneously. Main advantage: batch transfers send multiple token types in one transaction, reducing gas up to 90% vs individual ERC-721 transfers. Example: safeBatchTransferFrom() transfers 100 items in one transaction vs 100 separate ERC-721 transactions. Ideal for gaming: fungible currencies/resources + unique NFT items/weapons in same contract. Reduces: deployment costs (one contract vs multiple), management complexity (one address), approval overhead (one setApprovalForAll for all tokens). Semi-fungible support: tokens can transition from fungible to unique. 2025 usage: Dominant in Web3 gaming, metaverse platforms. Trade-off: Less marketplace support than ERC-721, but dramatically more efficient for volume operations.

99% confidence
A

Approximately 99.95% energy reduction (nearly 100%) according to Ethereum Foundation. Pre-Merge PoW: ~94 TWh/year (comparable to Netherlands). Post-Merge PoS: ~0.01 TWh/year. Mechanism: Eliminated energy-intensive mining (computational puzzle-solving requiring massive GPU farms). PoS validators use standard consumer hardware (16GB RAM, basic CPU). One of largest environmental improvements in blockchain history. Impact: Ethereum energy use now ~2,000x less than Bitcoin. Criticism silenced: "Ethereum is bad for environment" obsolete. 2025 status: PoS running efficiently 2+ years, 1.06 million validators on consumer hardware. Environmental footprint now comparable to traditional web services, not mining operations.

99% confidence
A

SSTORE opcode costs: 20,000 gas for zero-to-non-zero storage write (initializing empty slot), 5,000 gas for non-zero-to-non-zero write (updating existing value), 2,900 gas for non-zero-to-zero write (freeing slot, plus 15,000 gas refund). SLOAD (read): 2,100 gas for warm slot, 100 gas for hot slot (EIP-2929). Storage is most expensive operation - 20K gas = ~952 calldata bytes. Optimization strategies: Pack multiple values in single slot (uint128 + uint128 = one slot), use events for historical data (cheaper than storage), minimize zero-to-non-zero writes. Example: Initializing mapping[address] from 0 to 1 costs 20K gas first time, 5K gas subsequently. Critical for gas optimization in Solidity 0.8+.

99% confidence
A

Vulnerability where external contract/address recursively calls function before first execution completes, exploiting unsynchronized state updates. Mechanism: Attacker's contract receives ETH via .call() triggering fallback/receive function, which calls original function again before balance updated, draining funds. Famous example: 2016 DAO hack (3.6M ETH / $60M stolen). Still occurring in 2025: millions lost annually to reentrancy variants (cross-function, cross-contract). Prevention: 1) Checks-Effects-Interactions pattern (update state BEFORE external calls), 2) OpenZeppelin ReentrancyGuard modifier, 3) Use .transfer() / .send() (2300 gas limit, though not recommended post-Istanbul). Example vulnerable code: msg.sender.call{value: amount}("") before balance[msg.sender] -= amount. Critical: Always update state before external calls.

99% confidence
A

No, view and pure functions consume zero gas when called off-chain via JSON-RPC providers (web3.js, ethers.js, Alchemy, Infura). Off-chain calls use eth_call which simulates execution locally without creating transaction or state change. Gas only consumed when: 1) Called from another contract during on-chain transaction, 2) Called via transaction (not recommended - waste of gas). Example: Off-chain contract.balanceOf(address) (view) = 0 gas, 0 cost. On-chain function transfer() public { uint256 bal = balanceOf(msg.sender); } = balanceOf() consumes gas as part of transfer transaction. Best practice: Use off-chain calls for getters/queries, save transactions for state changes. Solidity 0.8+ strictly enforces view/pure restrictions.

99% confidence
A

50% full blocks (15 million gas per block target, 30 million max). Base fee adjusts algorithmically: increases up to 12.5% per block when blocks >50% full (high demand), decreases 12.5% when <50% full (low demand). Mechanism creates price elasticity and stabilizes fees vs previous first-price auction. Block gas limit elasticity: blocks can use up to 2x target (30M max) during demand spikes, protocol increases base fee to push back toward 50% equilibrium. Result: More predictable fees than pre-EIP-1559. 2025 reality: Blocks average 45-55% full during normal periods, spike to 95%+ during NFT mints/high activity. Monitor current: etherscan.io/chart/blocksize. Target ensures network capacity for demand spikes while maintaining fee stability.

99% confidence
A

Semi-fungible tokens (SFTs) blend fungible and non-fungible properties within ERC-1155. Initially identical and interchangeable (fungible), they become unique (non-fungible) when specific conditions trigger. Technically: supply-based distinction - high supply = fungible, supply of 1 = NFT. Developer controls transition logic (e.g., redeem ticket → assign seat). Common use cases: gaming items that degrade/evolve with use, event tickets (pre-event fungible → post-event unique proof), vouchers, memberships. OpenZeppelin implementation: single contract tracks balances per token ID per address. Batch operations enable efficient minting/transfers. Use when you need both token types in one system - reduces deployment costs and complexity versus separate ERC-20/ERC-721 contracts.

99% confidence
A

29% of total ETH supply staked as of mid-2025 (35.3 million ETH staked of ~122 million circulating). Growth trajectory: 23.8% January 2024 → 28.89% late 2024 → 29% June 2025 (+5.2% annual increase). Active validators: 1.06 million as of February 2025. Staking yields: 2.9-5% APY depending on network activity, validator uptime. Leading staking services: Lido (24.4% market share, down from 32%), Coinbase, Rocket Pool, individual stakers. Growth drivers: Attractive yields, Pectra upgrade (EIP-7251) enabling validator consolidation, increased confidence in PoS security after 2+ years stable operation. Trend indicates continued growth toward 35-40% staking ratio long-term.

99% confidence
A

Use ERC-721: <100 unique NFTs, single asset type (art/collectibles like CryptoPunks/BAYC), individual mints/transfers, established marketplace compatibility priority. Use ERC-1155: 100+ items, mixed asset types (fungible + non-fungible), batch operations needed (90% gas savings vs ERC-721), gaming economies. Decision thresholds: Collection size >100 → ERC-1155. Need batch minting (10+ items) → ERC-1155 (1 transaction vs 10). Mixed token types → ERC-1155. Optimized ERC1155D: <51K gas/mint (23-66% savings). Trade-off: ERC-721 has wider marketplace support, ERC-1155 dramatically more efficient for volume. 2025 trend: Gaming/metaverse prefer ERC-1155, traditional art/collectibles remain ERC-721.

99% confidence
A

Proof of Work (PoW): Miners compete solving cryptographic puzzles (hash computation), first solver creates block and receives reward, extremely energy-intensive (GPU/ASIC farms). Example: Bitcoin, Ethereum pre-Merge. Proof of Stake (PoS): Validators stake 32+ ETH as collateral, randomly selected proportional to stake to create blocks, 99.95% less energy than PoW. Ethereum transitioned Sept 15, 2022 (The Merge). Key differences: PoW = computational power, PoS = economic stake. PoW vulnerable to 51% hash attacks, PoS to 51% stake attacks (economically prohibitive). PoS enables: slashing (penalties for malicious validators), finality (transactions irreversible after 2 epochs), sustainable scaling. 2025 status: PoS production-proven, 29% ETH staked, 1M+ validators.

99% confidence
A

Yes, ALL storage variables are publicly readable on blockchain regardless of visibility modifier (public/private/internal). 'private' keyword only prevents other contracts from calling/modifying via function calls, NOT from reading raw storage slots. Anyone can read storage via eth_getStorageAt RPC call or blockchain explorers. Storage layout deterministic: slot 0, 1, 2... sequentially. Mappings/arrays use hash-based slots (keccak256). Critical: NEVER store sensitive data (passwords, private keys, secrets) in smart contract storage - always publicly transparent. Even 'private' variables are visible. Use encryption off-chain if data privacy required. Example: Private variable uint256 private secretNumber is readable via web3.eth.getStorageAt(contractAddress, 0). Best practice: Treat all storage as public.

99% confidence