Skip to content
reverts

Reverts & Errors

Handling failure gracefully.

When an error occurs or a requirement isn't met, the REVERT opcode stops execution and undoes all state changes made during the transaction. However, it allows returning a reason (error message) to the caller. Other error types like INVALID or Out-of-Gas also revert state but might consume all remaining gas.

Execution Simulation

Assistant Note

"Currently at PUSH instruction. It's going to place a value on top of the stack."

Program

14 bytes
0000
PUSH10x01
Place 1-byte item on stack
0002
PUSH10x00
0004
EQ
0005
PUSH10x0a
0007
JUMPI
0008
PUSH10x00
000a
PUSH10x00
000c
REVERT
000d
JUMPDEST

Stack

LIFO
0 / 1024
Stack is empty

Most opcodes pop their arguments from here.

Memory

0 bytes
00-0708-1516-2324-31
Memory is uninitialized
Memory is byte-addressable and volatile. It expands as you write to new offsets.

Gas Meter

Consumed0 / 1,000,000
Last Op Cost
-0
Refund
0
* Gas prevents infinite loops and DDoS. SSTORE is the most expensive opcode (20,000 gas for new slots).