SHA256
Hashing
SHA2-256 hash of the input.
| Address | 0x0000000000000000000000000000000000000002 |
|---|---|
| Name | SHA256 |
| Minimum gas | 60 |
| Input | variable |
| Output | 32 bytes |
| Available since | Frontier |
Input
| Offset | Length | Field | Description |
|---|---|---|---|
| 0 | variable | data | Arbitrary 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");