Skip to content

SHA256

Hashing

SHA2-256 hash of the input.

Address0x0000000000000000000000000000000000000002
NameSHA256
Minimum gas60
Inputvariable
Output32 bytes
Available sinceFrontier

Input

OffsetLengthFieldDescription
0variabledataArbitrary bytes to hash.

Output

The 32-byte SHA2-256 digest.

Gas

60 + 12 × ceil(len(input) / 32)

Failure behaviour

  • Cannot fail. Any input, including empty input, produces a digest.

Calling it

Precompiles have no ABI and no function selector: the input is raw bytes at the exact offsets above. Call with staticcall.

// SHA256 at 0x02
(bool ok, bytes memory out) = address(0x02).staticcall(input);
require(ok, "SHA256 reverted");