Blockchain Quiz

quiz

Blockchain Quiz channel for Web3 learners and professionals: practice blockchain, DeFi, NFT, smart contract, and blockchain security quiz questions with answers

  • Difficulty - Medium
    Total Plays - 17
    Allowed Time - 10 sec
    Best time - 4.491

    What happens if a public variable name conflicts with a function name?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Public variables automatically generate getter functions. If a function shares the same name, the compiler prioritizes the variable-generated getter, shadowing the function definition.
  • Difficulty - Medium
    Total Plays - 18
    Allowed Time - 10 sec
    Best time - 3.013 sec

    Which keyword prevents further inheritance of a contract?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Solidity does not support a final or sealed keyword for contracts. Any contract can be inherited unless architectural constraints are enforced manually.
  • Difficulty - Medium
    Total Plays - 15
    Allowed Time - 10 sec
    Best time - 3.845

    Which function type cannot access msg.sender?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    pure functions cannot read blockchain context such as msg.sender or block.timestamp. They are restricted to computation based solely on input parameters and local variables
  • Difficulty - Medium
    Total Plays - 10
    Allowed Time - 10 sec
    Best time - 1.012 sec

    What breaks if virtual is omitted in multiple inheritance?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Without the virtual keyword, a function cannot be overridden in derived contracts. This breaks the override chain and prevents proper polymorphic behavior in multiple inheritance scenarios.
  • Difficulty - Medium
    Total Plays - 6
    Allowed Time - 10 sec
    Best time - 10

    Which Solidity construct enforces compile-time immutability?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    constant variables are evaluated at compile time and embedded directly into contract bytecode. This guarantees immutability and avoids any runtime storage access or gas cost.
  • Difficulty - Medium
    Total Plays - 5
    Allowed Time - 10 sec
    Best time - 10

    What default value does an uninitialized storage pointer hold?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    An uninitialized storage pointer defaults to storage slot zero. This can overwrite critical state variables such as ownership or balances, making it a high-severity audit issue.
  • Difficulty - Medium
    Total Plays - 5
    Allowed Time - 10 sec
    Best time - 10

    Which visibility allows internal calls but blocks inheritance override?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    private functions and variables are accessible only within the defining contract. They cannot be called or overridden by child contracts, which blocks inheritance-based modification entirely.
  • Difficulty - Medium
    Total Plays - 3
    Allowed Time - 10 sec
    Best time - 10

    What happens if a modifier reverts after _ execution?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    If a modifier reverts after the _ placeholder executes, the entire transaction is reverted. All state changes made inside the function and modifier are rolled back due to Ethereum’s atomic execution model.
  • Difficulty - Medium
    Total Plays - 5
    Allowed Time - 10 sec
    Best time - 3.892

    Which Solidity keyword prevents state variable shadowing?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    The override keyword forces explicit acknowledgment when a derived contract replaces a parent variable or function. This prevents accidental state variable shadowing in inheritance hierarchies, which can otherwise lead to subtle storage corruption bugs.
  • Difficulty - Medium
    Total Plays - 11
    Allowed Time - 10 sec
    Best time - 3.307

    Why should developers avoid using tx.origin for authentication?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Attackers can trick users into calling a malicious contract. That contract then makes a call where tx.origin equals the victim’s address. This bypasses access control and leads to unauthorized actions.
  • Difficulty - Medium
    Total Plays - 12
    Allowed Time - 10 sec
    Best time - 1.493

    Why are fallback functions dangerous?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Fallback functions run automatically when unknown calls or plain ETH are sent. If they contain external calls or heavy logic, attackers can trigger recursion or re-entrancy. They must be kept minimal and safe.
  • Difficulty - Medium
    Total Plays - 11
    Allowed Time - 10 sec
    Best time - 1.974

    Why can abi.encodePacked cause issues?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    encodePacked removes padding, which can produce identical byte sequences for different inputs. When combined with hashing, this may cause collisions. Using abi.encode is safer for multi-field data.
  • Difficulty - Medium
    Total Plays - 13
    Allowed Time - 10 sec
    Best time - 4.554

    What makes nested delegatecalls dangerous?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Each delegatecall runs in the caller’s storage space, so nesting them multiplies the chances of overwriting incorrect slots. This breaks upgradeability guarantees and corrupts state. Auditors treat deep delegatecall chains as red flags.
  • Difficulty - Medium
    Total Plays - 16
    Allowed Time - 10 sec
    Best time - 2.746

    Why do upgradeable contracts avoid constructors?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Constructors run only during deployment and do not execute through proxies. Using an initializer ensures state is properly set through proxy calls. The entire proxy pattern relies on replacing constructors with explicit initialization.
  • Difficulty - Medium
    Total Plays - 20
    Allowed Time - 10 sec
    Best time - 1.062

    Why avoid multiple SSTOREs in a function?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    SSTORE is one of the most expensive operations and repeating it unnecessarily multiplies costs. Caching values into memory and writing once dramatically optimizes gas. This is foundational in gas-sensitive protocols.
  • Difficulty - Medium
    Total Plays - 17
    Allowed Time - 10 sec
    Best time - 1.746

    Why is assert() dangerous in production?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    assert() triggers a Panic error and is intended only for internal guarantees. If it fires in production, it indicates a compiler or logic bug. Developers should use require() for user-facing validation.
  • Difficulty - Medium
    Total Plays - 12
    Allowed Time - 10 sec
    Best time - 6.381

    What does a selector collision indicate?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Selector collisions occur when different function signatures hash to the same first 4 bytes. This leads to unintended dispatching and silent bugs. It’s especially dangerous in diamond proxies and minimal routers.
  • Difficulty - Medium
    Total Plays - 16
    Allowed Time - 10 sec
    Best time - 1.487

    Why is msg.value validation kept at the top of functions?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Validating msg.value early ensures no state mutation occurs before detecting invalid ether transfers. This prevents partially updated storage on failure, preserving atomicity. It aligns with checks-effects-interactions
  • Difficulty - Medium
    Total Plays - 8
    Allowed Time - 10 sec
    Best time - 1.153

    What makes fallback functions error-prone?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Fallbacks receive raw calldata without predefined structure, forcing developers to manually decode and validate inputs. Any mistake leads to reentrancy or mis-routing. They must be extremely minimal.
  • Difficulty - Medium
    Total Plays - 13
    Allowed Time - 10 sec
    Best time - 4.927

    Why do storage reads cost more than memory reads?

    Tip: Click "Play" to reveal options and start playing.

    #A
    #B
    #C
    #D
    Explanation:
    Storage accesses require Merkle-Patricia proof validation at the state level. This makes SLOAD one of the most expensive operations in Solidity. Caching values into memory significantly reduces repeated cost.