Signing EIP-7702 authorizations
Privy provides methods to sign EIP-7702 authorizations using the user’s embedded wallet. This authorization is a cryptographic signature that allows an EOA to set its code to that of a smart contract, enabling the EOA to behave like a smart account. Learn more about signing EIP-7702 authorizations in our dedicated guide. Learn more about using the signed authorization in the integration guides below!Detect current 7702 authorization state and implementation address
You can determine whether an EOA is currently delegated via EIP-7702 and read the authorized implementation address with a singleeth_getCode
call on the EOA address.
Under EIP-7702, an authorized EOA temporarily exposes a small bytecode stub that begins with the magic prefix 0xef0100
, followed immediately by the 20-byte implementation address. If eth_getCode
returns empty code (0x
or 0x0
), the EOA is not currently delegated on that chain. The snippets below return the current implementation address or null
.
Authorization state is per-chain. Under 7702, an authorized EOA will return non-empty code with
the
0xef0100
prefix; other non-empty code indicates a deployed contract account.Using EIP-7702 capabilities
In this guide, we will transform your Privy embedded wallet into a smart wallet with features like gas sponsorship, batch transactions, granular permissions, and more using EIP-7702 support from Alchemy.2. Create a
0. Install dependencies
In your app’s repository, install the required dependencies from Privy, Alchemy, andviem
:The Alchemy SDK currently requires
viem
to be pinned to 2.22.61. Create an Alchemy account and get your API key
-
Create an app: visit the Alchemy dashboard to create a new app, if you don’t already have one.
- Make sure to enable networks that support EIP-7702 such as Ethereum Mainnet or Sepolia.
- Save the app’s API Key that will be used later.
-
Enable gas sponsorship: visit the Gas Manager dashboard and create a new sponsorship policy for the app you created in step 1. This policy will be used to set rules on how much of user’s gas you want to sponsor.
- Make sure to enable gas sponsorship on a chain that support EIP-7702 such as Ethereum Mainnet or Sepolia.
- Save the Policy ID that will be used later.
2. Configure Privy settings
If you’re already using a Privy embedded wallet, update your configuration to support EIP-7702 with embedded wallets. If you don’t yet have authentication configured, you can follow this guide to get set up.Make sure yourPrivyProvider
has the following embeddedWallets
settings and ensure you set the defaultChain
and supportedChains
to the 7702 supported chain you chose in step 1.3. Adapt Privy signer to a smart account signer
Now that you have authentication working, adapt the Privy signer to be able to sign 7702 authorizations to upgrade to smart accounts.1. Get the Privy embedded walletSmartAccountSigner
instance4. Upgrade to smart accounts and send sponsored transactions
Now that you have aSmartAccountSigner
instance, follow this guide to create a smart account client (createModularAccountV2Client
) and start sending sponsored transactions. You’ll need:- the
SmartAccountSigner
instance defined in step 3 - the API key and the policy ID from step 1