EIPs
EIP-7702 — Set EOA account code
A transaction type that lets an EOA temporarily delegate to contract code. The EOA signs an Authorization saying “for this transaction, execute as if I had this contract’s bytecode.” That gives EOAs smart-account features (batching, sponsored gas, custom validation) without becoming smart accounts and without bundler infrastructure.
import {
build_authorization_message,
sign_authorization,
wallet_sign_authorization,
wallet_send_set_code_transaction,
} from "@ethernauta/eip/7702";
// 1. dapp builds the authorization payload
const auth = {
chain_id: 1n,
address: delegate_contract,
nonce: 0n,
};
// 2. wallet signs (path 1)
const signed_auth = await wallet_sign_authorization(auth)(
signer({ chain_id: eip155_1.chain_id }),
);
// 3. wallet bundles into a type-4 tx and broadcasts
const hash = await wallet_send_set_code_transaction({
authorization_list: [signed_auth],
to: target,
data: calldata,
})(signer({ chain_id: eip155_1.chain_id })); Surface
Authorization (the inner signature)
| Export | Type | Purpose |
|---|---|---|
build_authorization_message | (auth) => Bytes | Compose the message hash input. |
hash_authorization | (auth) => Hash32 | Final digest. |
sign_authorization | (args) => AuthorizationSigned | Sign with a raw private key. |
AuthorizationParameter, AuthorizationParameters, AuthorizationSigned, AuthorizationList | types | Wire shapes. |
is_delegation_designator | (bytecode) => boolean | Check whether code is a 7702 designator. |
Set-code transaction (the outer envelope)
| Export | Type | Purpose |
|---|---|---|
encode_set_code_signed | (tx) => Bytes | RLP encode a signed type-4 tx. |
encode_set_code_unsigned | (tx) => Bytes | RLP encode the pre-signing payload. |
sign_set_code_transaction | (args) => Bytes | Sign + encode. |
SetCodeTransactionSigned, SetCodeTransactionUnsigned | types | |
AccessListItem, DelegationIntent | types | |
SendSetCodeTransactionParameters | type | The wallet RPC param shape. |
hexDataSchema | Valibot schema |
RPC methods
| Method | Shape | Purpose |
|---|---|---|
wallet_sign_authorization | Signable<AuthorizationSigned> | Path 2: get back a signed authorization. |
wallet_send_set_code_transaction | Signable<Hash32> | Path 1: wallet bundles + broadcasts. |
Constants
| Export | Value |
|---|---|
SET_CODE_MAGIC | 0x05 — the authorization tuple prefix. |
SET_CODE_TX_TYPE | 0x04 — the transaction type byte. |
What a delegation looks like on-chain
After a successful 7702 tx, the EOA’s code field becomes 0xef0100 || <delegate_address>. That’s the delegation designator:
import { is_delegation_designator } from "@ethernauta/eip/7702";
const code = await eth_get_code({ address: eoa, block: "latest" })(reader);
const delegated = is_delegation_designator(code); When delegated, transactions to the EOA execute the delegate’s bytecode. The EOA can clear the delegation by signing another authorization pointing to 0x0...0.
Path 1 vs path 2
| Path 1 (wallet-bundled) | Path 2 (primitive composition) | |
|---|---|---|
| Method | wallet_sendSetCodeTransaction | wallet_signAuthorization + eth_sendRawTransaction |
| Dapp owns | nothing | the broadcast |
| Round trips | 1 | 2 |
| Use case | typical | bridges, MEV-sensitive flows, audit-heavy systems |
See Concepts → two paths for the general principle.
See also
- EIP-5792 — wallet may pick a 7702 strategy under the hood.
- Wallet → authorize-delegation view.