Authorization
An EIP-7702 authorization: an account’s signed permission to run the code of a contract as its
own. A transaction of type "eip7702" carries a list of them.
import { Effect } from "effect";import { type Hash } from "@ethect/core";import { Eth } from "@ethect/core/rpc";
const delegations = (hash: Hash.Hash) => Effect.gen(function* () { const transaction = yield* Eth.getTransactionByHash(hash); if (transaction?.type !== "eip7702") return []; // transaction.authorizationList: ReadonlyArray<Authorization.Authorization> return transaction.authorizationList.map((authorization) => authorization.address); });// ["0x5fbdb2315678afecb367f032d93f642f64180aa3"]The result is the contracts the accounts of that transaction delegate to.
Schemas
Section titled “Schemas”| Schema | Type | Describes | Used by |
|---|---|---|---|
Authorization.schema |
Authorization.Authorization |
one signed authorization | the entries of a list |
Authorization.listSchema |
Authorization.List |
the authorizations of a transaction: a ReadonlyArray<Authorization.Authorization> |
the authorizationList of a TransactionRequest and of an EIP-7702 Transaction |
Import a type to name it in your own signatures.
import type { Authorization } from "@ethect/core/rpc";
/** The contracts a list of authorizations delegates to. */const targets = (list: Authorization.List) => list.map((authorization) => authorization.address);Fields
Section titled “Fields”| Field | Type | Notes |
|---|---|---|
chainId |
number |
the chain the authorization is for, or 0 for every chain |
nonce |
number |
the nonce of the account that signed |
address |
Address |
the contract whose code the account runs |
yParity |
number |
the parity bit of the signature, 0 or 1 |
r |
Hex |
the first half of the signature |
s |
Hex |
the second half of the signature |
Behavior
Section titled “Behavior”- Already signed. An authorization holds a signature, and nothing in ethect signs one:
the
r,sandyParityof a request come from a wallet or from a signer of your own. addressis the contract, not the signer. The account that signed is not a field. It is recovered from the signature.- A
chainIdof0is valid on every chain. randsare hex, not numbers. A node sends them as quantities, so they can be shorter than 32 bytes. They are kept as the node sent them.- On the account. Once the transaction is mined, the code of the account is
0xef0100followed byaddress. Read it withEth.getCode.