EIPs

EIP-7702 — Set EOA account code

eips.ethereum.org/EIPS/eip-7702

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)

ExportTypePurpose
build_authorization_message(auth) => BytesCompose the message hash input.
hash_authorization(auth) => Hash32Final digest.
sign_authorization(args) => AuthorizationSignedSign with a raw private key.
AuthorizationParameter, AuthorizationParameters, AuthorizationSigned, AuthorizationListtypesWire shapes.
is_delegation_designator(bytecode) => booleanCheck whether code is a 7702 designator.

Set-code transaction (the outer envelope)

ExportTypePurpose
encode_set_code_signed(tx) => BytesRLP encode a signed type-4 tx.
encode_set_code_unsigned(tx) => BytesRLP encode the pre-signing payload.
sign_set_code_transaction(args) => BytesSign + encode.
SetCodeTransactionSigned, SetCodeTransactionUnsignedtypes
AccessListItem, DelegationIntenttypes
SendSetCodeTransactionParameterstypeThe wallet RPC param shape.
hexDataSchemaValibot schema

RPC methods

MethodShapePurpose
wallet_sign_authorizationSignable<AuthorizationSigned>Path 2: get back a signed authorization.
wallet_send_set_code_transactionSignable<Hash32>Path 1: wallet bundles + broadcasts.

Constants

ExportValue
SET_CODE_MAGIC0x05 — the authorization tuple prefix.
SET_CODE_TX_TYPE0x04 — 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)
Methodwallet_sendSetCodeTransactionwallet_signAuthorization + eth_sendRawTransaction
Dapp ownsnothingthe broadcast
Round trips12
Use casetypicalbridges, MEV-sensitive flows, audit-heavy systems

See Concepts → two paths for the general principle.

See also