Pay with ERC20
This page details the process of paying the gas of user operations (UserOps) using ERC20 tokens.
Last updated
This page details the process of paying the gas of user operations (UserOps) using ERC20 tokens.
Last updated
ERC20 token payments are currently restricted to testnets as part of our staging environment. For this functionality, please use staging Gelato Bundler RPC as bundler transport.
Zerodev ERC20 Paymaster currently supports USDC on Ethereum Mainnet, Polygon, Base, Optimism, and Arbitrum networks, including both their mainnet and testnet environments. Learn more.
After reading this page:
You'll know how to pay gas for UserOps using ERC20 tokens.
You'll learn about how to use Zerodev Kernel and Safe as an smart account to pay gas.
You'll see some code which will help you send a Non-Sponsored UserOp within minutes.
Register on the ZeroDev dashboard to access the tools necessary for managing and sponsoring gas fees in your projects.
After signing in, create a new project and choose the network you plan to operate on (e.g., Ethereum, Polygon). This ensures that all settings and configurations match your target chain.
Within your project’s dashboard, locate and copy the Paymaster URL. This endpoint is essential for integrating the sponsorship service into your application. If you want custom ERC20 tokens for gas fees checkout here.
createKernelAccount
from @zerodev/sdk
createZeroDevPaymasterClient
createKernelAccountClient
adding Gelato Bundler RPC with Zerodev paymasterWhen using the Gelato Bundler with a ZeroDev Paymaster, you need to specify a specialized gas estimation method when creating the kernelClient
. The Paymaster, along with its paymasterContext
, is required for paying gas in ERC20 tokens—be sure to include the specific token address in the paymasterContext.
You should encode your initial transaction to include an approval of the required amount of ERC20 tokens for the paymaster client.
The userOpHash, when using the Gelato Bundler, is equivalent to the Task ID. This Task ID can be easily debugged through the Relay API, providing a streamlined method for troubleshooting and monitoring the status of transactions. Checkout here.
Explore the complete example code that demonstrates how to sponsor UserOps using Zerodev Paymaster with the ZeroDev Kernel here, as well as how to integrate with a Safe account here.