Integrating with EIP-7702
EIP-7702 is an upgrade to EVM blockchains that enables externally owned accounts (EOAs) to set their code to that of a smart contract. In practical terms, this means that EOA wallets will gain AA (account abstraction) capabilities such as transaction bundling, gas sponsorship, and custom permissions.
Privy supports all low level interfaces required by 7702 - signing authorizations and sending type 4 transactions, allowing you to use any implementation of EIP-7702. Use the following guides to get started with EIP-7702 in your application:
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!
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.
0. Install dependencies
In your app’s repository, install the required dependencies from Privy, Alchemy, and viem
:
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.
Now that you have your API key and Policy ID, you can set up your smart wallets.
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 your PrivyProvider
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 wallet
2. Create a SmartAccountSigner
instance
4. Upgrade to smart accounts and send sponsored transactions
Now that you have a SmartAccountSigner
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
Once you define the client, you can send sponsored transactions with your embedded EOA and access other advanced smart account features! This client will handle all of the logic of delegating to a new smart account, if not already, and signing transactions. If you don’t yet have a signer, follow this guide to get set up.
Next steps
You just upgraded your EOA and sent your first sponsored transaction using EIP-7702!
If you want to leverage other smart account capabilities such as batching and permissions, check out the Alchemy docs.
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.
0. Install dependencies
In your app’s repository, install the required dependencies from Privy, Alchemy, and viem
:
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.
Now that you have your API key and Policy ID, you can set up your smart wallets.
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 your PrivyProvider
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 wallet
2. Create a SmartAccountSigner
instance
4. Upgrade to smart accounts and send sponsored transactions
Now that you have a SmartAccountSigner
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
Once you define the client, you can send sponsored transactions with your embedded EOA and access other advanced smart account features! This client will handle all of the logic of delegating to a new smart account, if not already, and signing transactions. If you don’t yet have a signer, follow this guide to get set up.
Next steps
You just upgraded your EOA and sent your first sponsored transaction using EIP-7702!
If you want to leverage other smart account capabilities such as batching and permissions, check out the Alchemy docs.
In this guide we’ll see a quick example of using the Biconomy’s Modular Execution Environment (MEE) stack with Privy!
To keep things short, this guide will show you a simple example of single-chain orchestration with cross-chain gas. However, the Biconomy MEE stack supports multi-chain orchestration cases. If you’re looking to build a multi-chain DeFi strategy - read the Biconomy Docs
Project Setup
Create your project using Vite:
Add the following to your package.json
:
Install dependencies:
Set up your main.tsx
:
In wagmi.ts
:
⬇Get the Embedded Wallet Instance
After logging in the user with Privy, you can find the embedded wallet as follows:
Authorizing with EIP-7702
To install the Biconomy Nexus 1.2.0 smart account on the address of your Privy embedded
wallet EOA, you need to sign the following authorization. Note: This is using the
signAuthorization
method exposed by the useSignAuthorization
Privy hook.
Execute a Cross-Chain Gas Abstracted Transaction
After signing, you can submit a transaction through Biconomy MEE Relayers. Notice few things for this transaction:
- Gas is paid with USDC
- Gas is paid on a different chain than the instruction being executed
- The
amount
arg in the ERC-20transfer
call is not fixed to a value, but usesruntimeERC20BalanceOf
which will inject the full amount of USDC available.
This demonstrates few key points of MEE:
- Gas abstraction / gas sponsorship
- Multi-chain execution/orchestration
- Runtime parameter injection enabling multi-transaction composability
You can then link the user to MEE Scan to track:
Storing the Authorization
If you’ve used the chainId === 0
for your authorization you can store it (e.g. in localStorage or DB) and
replay it for other chains in the future. This gives your users an even more seamless UX.
In this guide, we’ll demonstrate how to use Pimlico, a bundler and paymaster service for ERC-4337 accounts, to enable your users to send gasless transactions using EIP-7702 authorization.
Want to see a full end to end example? Check out our starter repo here
0. Install dependencies
In your app’s repository, install the required dependencies from Permissionless and Viem:
1. Sign up for a Pimlico account and get your API key
Head to the Pimlico dashboard here and create an account. Generate an API key and create a sponsorship policy for the network you plan to use (optional). Make note of your API key and sponsorship policy ID.
2. Configure Privy settings
Configure your app to create embedded wallets for all users.
3. Create a simple smart account with Permissionless SDK
Permissionless provides a simple way to create a smart account client that can send user operations with EIP-7702 authorization. All you need is the user’s embedded wallet and the Pimlico API key.
4. Sign the EIP-7702 authorization
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.
5. Send a gas-sponsored transaction
With the smart account client configured and the authorization signed, you can now send gasless UserOperations. Below we send an empty call to the zero address:
Conclusion
That’s it! You’ve just executed a gasless transaction from a normal EOA upgraded with EIP-7702 using Pimlico as the bundler and paymaster service.
Explore the rest of the Pimlico docs to learn about advanced features like batching transactions, gas estimation, and more.
Want to see a full end to end example? Check out our starter repo here!
In this guide, we demonstrate using ZeroDev, a toolkit for creating smart accounts, together with Privy to enable your users to send gasless (sponsored) transactions.
Want to see a full end to end example? Check out our starter repo here!
0. Install dependencies
In your app’s repository, install the required dependencies from Privy, ZeroDev and viem
:
1. Sign up for a ZeroDev account and create a project
Head to the ZeroDev dashboard and create a project on a chain that supports EIP-7702.
Set up a gas sponsorship policy to enable sending sponsored transactions. Copy the Bundler RPC and Paymaster RPC for the network you plan to use.
2. Configure Privy settings
Configure your app to create embedded wallets for all users. Also configure Privy to not show its default wallet UIs. Instead, we recommend you use your own custom UIs for showing users the user operations they sign.
Update your PrivyProvider
configuration to include the following properties:
3. Create a 7702 Kernel account with the ZeroDev SDK
ZeroDev exposes helper functions that take care of generating the 7702 authorization for you. All you need to provide is the signer for the user’s embedded wallet and the Kernel version you want to use.
Behind the scenes ZeroDev generates the EIP-7702 authorization and binds the Kernel implementation code to the EOA, giving it smart-account super-powers while keeping the same address.
4. Configure the ZeroDev client for sponsored transactions
5. Send a gas-sponsored transaction
With the client configured, you can now send gasless UserOperations. Below we send an empty call then wait for it to be mined:
Conclusion
That’s it! You’ve just executed a gasless transaction from a normal EOA upgraded with EIP-7702.
Explore the rest of the ZeroDev docs to learn about batching, session keys, cross-chain actions and more.