Skip to main content

Overview

EIP-7702 is available as of [email protected] (web) and @magic-sdk/[email protected] / @magic-sdk/[email protected] (React Native).
EIP-7702 introduces a new transaction type (Type-4) that allows Externally Owned Accounts (EOAs) to temporarily delegate to smart contract code. This enables account abstraction features like batched transactions, gas sponsorship, and session keys for regular wallets. Magic supports EIP-7702 through two SDK methods:
  • wallet.sign7702Authorization() — Signs an authorization that delegates your EOA to a smart contract implementation
  • wallet.send7702Transaction() — Sends a Type-4 transaction that includes signed authorizations

Compatibility

  • EIP-7702 operates headlessly with no UI confirmation prompt
  • Requires a network that supports EIP-7702 (e.g., Ethereum Mainnet, Sepolia, Arbitrum, Base, Optimism)
  • The wallet must have ETH (or the network’s native token) to pay for gas

Use Cases

  • Temporarily delegate an EOA to a smart contract implementation for advanced features
  • Enable batched transactions through a delegated smart account
  • Integrate with account abstraction infrastructure that leverages EIP-7702

Usage

Step 1: Sign an EIP-7702 Authorization

The sign7702Authorization method signs an authorization that delegates your EOA to a specified smart contract. This authorization is then included in a Type-4 transaction.
JavaScript
import { Magic } from 'magic-sdk';

const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', {
  network: {
    rpcUrl: 'https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY',
    chainId: 11155111,
  },
});

// Sign an EIP-7702 authorization
const authorization = await magic.wallet.sign7702Authorization({
  contractAddress: '0x000000004F43C49e93C970E84001853a70923B03',
  chainId: 11155111,
});

console.log('Authorization:', authorization);
// {
//   contractAddress: '0x000000004F43C49e93C970E84001853a70923B03',
//   chainId: 11155111,
//   nonce: 0,
//   v: 27,
//   r: '0x...',
//   s: '0x...'
// }

Parameters

ParameterTypeRequiredDescription
contractAddressstringYesThe smart contract implementation address to delegate to
chainIdnumberYesThe chain ID for the authorization
noncenumberNoThe account nonce. If omitted, fetched from the network automatically

Response

FieldTypeDescription
contractAddressstringThe contract address that was authorized
chainIdnumberThe chain ID for the authorization
noncenumberThe nonce used in the authorization
vnumberThe v component of the signature (27 or 28)
rstringThe r component of the signature
sstringThe s component of the signature

Step 2: Send a Type-4 Transaction

The send7702Transaction method sends a Type-4 transaction that includes the signed authorization list. This is what actually executes the delegation on-chain.
JavaScript
// Send a Type-4 transaction with the authorization from Step 1
const { transactionHash } = await magic.wallet.send7702Transaction({
  to: '0x1234567890123456789012345678901234567890',
  value: '0x0',
  data: '0x',
  authorizationList: [authorization],
});

console.log('Transaction hash:', transactionHash);

Parameters

ParameterTypeRequiredDescription
tostringYesThe recipient address
authorizationListarrayYesArray of signed authorizations returned by sign7702Authorization
valuestringNoValue to send in wei (hex string). Defaults to '0x0'
datastringNoTransaction calldata. Defaults to '0x'
gasstringNoGas limit (hex string). If omitted, estimated automatically
gasLimitstringNoAlias for gas
maxFeePerGasstringNoMax fee per gas (hex string). If omitted, fetched from the network
maxPriorityFeePerGasstringNoMax priority fee per gas (hex string). If omitted, fetched from the network
noncenumberNoTransaction nonce. If omitted, fetched from the network

Response

FieldTypeDescription
transactionHashstringThe hash of the submitted transaction

Complete Example

JavaScript
import { Magic } from 'magic-sdk';

const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', {
  network: {
    rpcUrl: 'https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY',
    chainId: 11155111,
  },
});

async function sendEip7702Transaction() {
  try {
    // Step 1: Sign the authorization
    const authorization = await magic.wallet.sign7702Authorization({
      contractAddress: '0x000000004F43C49e93C970E84001853a70923B03',
      chainId: 11155111,
    });
    console.log('Authorization signed:', authorization);

    // Step 2: Send the Type-4 transaction with the authorization
    const { transactionHash } = await magic.wallet.send7702Transaction({
      to: '0x1234567890123456789012345678901234567890',
      data: '0x',
      authorizationList: [authorization],
    });
    console.log('Transaction hash:', transactionHash);
  } catch (error) {
    console.error('EIP-7702 transaction failed:', error);
  }
}

Resources