> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magic.link/llms.txt
> Use this file to discover all available pages before exploring further.

# EIP-7702

> Sign EIP-7702 authorizations and send Type-4 transactions to delegate EOA capabilities to smart contracts.

## Overview

<Note>EIP-7702 is available as of `magic-sdk@33.4.0` (web) and `@magic-sdk/react-native-expo@34.2.0` / `@magic-sdk/react-native-bare@34.2.0` (React Native).</Note>

[EIP-7702](https://eips.ethereum.org/EIPS/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 JavaScript icon="square-js" theme={null}
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

| Parameter         | Type     | Required | Description                                                           |
| ----------------- | -------- | -------- | --------------------------------------------------------------------- |
| `contractAddress` | `string` | Yes      | The smart contract implementation address to delegate to              |
| `chainId`         | `number` | Yes      | The chain ID for the authorization                                    |
| `nonce`           | `number` | No       | The account nonce. If omitted, fetched from the network automatically |

#### Response

| Field             | Type     | Description                                   |
| ----------------- | -------- | --------------------------------------------- |
| `contractAddress` | `string` | The contract address that was authorized      |
| `chainId`         | `number` | The chain ID for the authorization            |
| `nonce`           | `number` | The nonce used in the authorization           |
| `v`               | `number` | The `v` component of the signature (27 or 28) |
| `r`               | `string` | The `r` component of the signature            |
| `s`               | `string` | The `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 JavaScript icon="square-js" theme={null}
// 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

| Parameter              | Type     | Required | Description                                                                 |
| ---------------------- | -------- | -------- | --------------------------------------------------------------------------- |
| `to`                   | `string` | Yes      | The recipient address                                                       |
| `authorizationList`    | `array`  | Yes      | Array of signed authorizations returned by `sign7702Authorization`          |
| `value`                | `string` | No       | Value to send in wei (hex string). Defaults to `'0x0'`                      |
| `data`                 | `string` | No       | Transaction calldata. Defaults to `'0x'`                                    |
| `gas`                  | `string` | No       | Gas limit (hex string). If omitted, estimated automatically                 |
| `gasLimit`             | `string` | No       | Alias for `gas`                                                             |
| `maxFeePerGas`         | `string` | No       | Max fee per gas (hex string). If omitted, fetched from the network          |
| `maxPriorityFeePerGas` | `string` | No       | Max priority fee per gas (hex string). If omitted, fetched from the network |
| `nonce`                | `number` | No       | Transaction nonce. If omitted, fetched from the network                     |

#### Response

| Field             | Type     | Description                           |
| ----------------- | -------- | ------------------------------------- |
| `transactionHash` | `string` | The hash of the submitted transaction |

## Complete Example

```javascript JavaScript icon="square-js" theme={null}
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

* [EIP-7702 Specification](https://eips.ethereum.org/EIPS/eip-7702)
* [Quickstart](/embedded-wallets/quickstart/overview)
