Sponsoring transactions on Ethereum
Privy makes it easy to create smart wallets for your users to sponsor gas fees for transactions on Ethereum. This is done by using a paymaster to pay for users’ gas fees.
This guide explains how to use smart wallets from your server to sponsor gas fees for transactions on Ethereum. Using server wallets as smart wallets gives your application all the benefits of account abstraction, including gas sponsorship, with the flexibility of server wallets.
In this setup, an embedded wallet created on your server wallet is the signer for the smart wallet. Note that the server wallet’s address is not the smart wallet address in this case - it simply authorizes actions taken by the smart wallet. All transactions and assets are tied to the smart wallet.
This guide uses Kernel as the smart wallet contract provider, but your implementation can use any smart wallet provider.
0: Install necessary dependencies
This guide uses Privy’s server SDK to create the server wallet, Pimlico’s permissionless
package, and viem
. Install these packages with the following command:
1: Create a server wallet
Create a privy
client and use the create
method from Privy’s SDK to create a server wallet. If you already have a server wallet you wish to use, you can skip this step.
2: Get a viem
LocalAccount
for the server wallet
Create a viem LocalAccount
object representing the server wallet. Use the createViemAccount
method from Privy’s SDK.
3: Create a smart wallet
Use permissionless
to create a smart wallet with the server wallet as the signer. Learn more about creating smart wallet accounts in the permissionless
docs.
4: Create a client for the smart wallet
You can use this smart wallet client to request signatures and transactions from the smart wallet. Learn more about making transactions on the client in the permissonless
docs.
Was this page helpful?