Skip to main content

Example program

This page helps illustrate the program schema's key concepts by offering a fictional pseudo-code example and its hypothetical compiled program.

Assume this fictional [somewhat] high-level language expects one contract per source file, where each contract defines its storage layout, high-level logic, and other metadata as top-level statements or blocks.

The following source code might be used to define a contract that increments a state variable if the caller pays at least 1 finney (0.001 ETH).

Interactive example

Source contents

Loading...

Compiled opcodes

0x00
PUSH6 0x02ba7def3000 (hexadecimal for 3 finney)
0x07
CALLVALUE
0x08
LT
0x09
PUSH1 0x13
0x0b
JUMPI (jump to end unless sufficient fee)
0x0c
PUSH0 (push stack slot of state variable)
0x0d
SLOAD
0x0e
PUSH1 0x01
0x10
ADD
0x11
PUSH0
0x12
SSTORE
0x13
JUMPDEST (skip to here if not enough paid)

Details

tip
Select an instruction offset to see associated ethdebug/format debugging information.