# `EEVM.Precompiles.SHA256`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/precompiles/sha256.ex#L1)

SHA-256 precompile — address `0x02`.

### Gas schedule (Yellow Paper §E.2)

| Component | Cost |
|-----------|------|
| Base      | 60   |
| Per word  | 12 (one word = 32 bytes, rounded up) |

### Output format

Always 32 bytes — the raw SHA-256 digest.

# `execute`

```elixir
@spec execute(binary(), non_neg_integer()) ::
  {:ok, binary(), non_neg_integer()} | {:error, :out_of_gas}
```

Executes the SHA-256 precompile.

Hashes `input` with SHA-256 and returns the 32-byte digest, charging
`60 + 12 * ceil(byte_size(input) / 32)` gas.

## Examples

    iex> {:ok, digest, _gas} = EEVM.Precompiles.SHA256.execute(<<>>, 1_000)
    iex> byte_size(digest)
    32

    iex> EEVM.Precompiles.SHA256.execute(<<1::256>>, 5)
    {:error, :out_of_gas}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
