EIP-7702 enables externally owned accounts (EOAs) to delegate their execution to smart contract code. This allows EOA wallets to gain account abstraction capabilities such as transaction bundling, gas sponsorship, and custom permissions.

Privy provides methods to sign EIP-7702 authorizations, which allows your embedded wallets to be upgraded into any smart contract. Learn more about EIP-7702 and how to use it with various account abstraction providers.

EIP-7702 authorization signing is currently only supported in the React SDK and REST API.

Use the useSign7702Authorization hook to sign an EIP-7702 authorization with your user’s wallet.

import {useSign7702Authorization} from '@privy-io/react-auth';

const {signAuthorization} = useSign7702Authorization();

Usage

import {useSign7702Authorization} from '@privy-io/react-auth';

function Sign7702Button() {
    const {signAuthorization} = useSign7702Authorization();

    const handleSign = async () => {
        try {
            const authorization = await signAuthorization({
                contractAddress: '0x1234567890abcdef1234567890abcdef12345678',
                chainId: 1, // Ethereum mainnet
                nonce: 0 // Optional, defaults to current nonce
            });

            console.log('Signed authorization:', authorization);
            // Use the authorization with your AA provider
        } catch (error) {
            console.error('Failed to sign authorization:', error);
        }
    };

    return (
        <button onClick={handleSign}>
            Sign EIP-7702 Authorization
        </button>
    );
}

Parameters

contractAddress
string
required

The address of the smart contract whose code the EOA will delegate to. This is typically an account implementation contract from your AA provider.

chainId
number
required

The chain ID where the authorization will be used.

nonce
number

The nonce for the authorization. If not provided, the current transaction count for the wallet will be used.

Returns

authorization
Authorization

The signed EIP-7702 authorization object containing: