# `EEVM.Delegation`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/delegation.ex#L1)

EIP-7702 delegation designators.

A set-code transaction writes `0xef0100 || address` as an authority's code.
From then on, calls to the authority (top-level and CALL, CALLCODE,
DELEGATECALL, STATICCALL) execute the code stored at `address`, while
EXTCODESIZE, EXTCODECOPY, and EXTCODEHASH still see the 23-byte designator.
Only one hop is followed: a designator that points at another designator
runs that designator as code.

# `delegated_address`

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

Return the delegate address if `code` is exactly a delegation designator.

## Examples

    iex> EEVM.Delegation.delegated_address(EEVM.Delegation.designator(0xBEEF))
    {:ok, 0xBEEF}

    iex> EEVM.Delegation.delegated_address(<<0x60, 0x00>>)
    :error

# `designator`

```elixir
@spec designator(non_neg_integer()) :: binary()
```

Build the designator code for `address`.

## Example

    iex> EEVM.Delegation.designator(0x1234)
    <<0xEF, 0x01, 0x00, 0::144, 0x12, 0x34>>

# `designator?`

```elixir
@spec designator?(binary()) :: boolean()
```

Return whether `code` is exactly a delegation designator.

---

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