LOGBOOK

HELP

Quiz Entry - updated: 2026.07.30

What does require do, and how does a revert behave?

require(condition, "message") checks a condition and, if it is false, reverts the whole transaction with an error message — undoing every change made so far and refunding the remaining gas.

function fund() public payable {
    require(msg.value >= 1e18, "didn't send enough");
    // ... only runs if the require passed
}

require is an input/validity guard placed at the top of a function. If the condition holds, execution continues; if not, the transaction reverts: any state changes it had already made are rolled back as if nothing happened, and unused gas is returned to the caller. Note that gas already spent on work before the failing require is not refunded — only the leftover. A revert can also be triggered directly with the revert keyword (no condition), and newer Solidity supports gas-cheaper custom errors (error NotOwner(); ... if (msg.sender != owner) revert NotOwner();) instead of a stored string.

Go deeper:

From Quiz: IOTHACK / Smart Contracts & the Remix IDE | Updated: Jul 30, 2026