This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
Overview
Address:0x0000000000000000000000000000000000000002Introduced: FrontierThe SHA256 precompile implements the SHA-256 cryptographic hash function, producing a 32-byte hash of arbitrary input data. SHA-256 is part of the SHA-2 family standardized by NIST and is widely used in Bitcoin and other systems.This precompile enables Ethereum contracts to verify Bitcoin SPV proofs, validate SHA-256 based signatures, and interact with systems that use SHA-256 hashing.
Gas Cost
Formula:60 + 12 * ceil(input_length / 32)
Base cost: 60 gas
Per-word cost: 12 gas per 32-byte word
Partial words round up
Examples:
0 bytes: 60 gas
32 bytes: 72 gas (60 + 12*1)
33 bytes: 84 gas (60 + 12*2)
64 bytes: 84 gas (60 + 12*2)
Input Format
Accepts arbitrary-length byte array. No restrictions on input size.
SHA-256 is more expensive than Keccak256 on Ethereum (60 vs 30 base gas). Use Keccak256 for Ethereum-native hashing when possible.Gas costs favor larger batches:
Per-byte cost: ~0.375 gas/byte
Prefer hashing larger inputs over multiple small ones