Sponsor Gas With Any Erc20 Token
Gas fees paid in the native gas token can feel foreign to users that primarily hold stablecoins or your app’s own token. With our smart wallet, you can enable your users to pay gas with ERC-20 tokens beyond the native gas token, like USDC or your own custom tokens, streamlining the user experience.
How it works: We front the gas using the network’s native gas token and transfer the ERC-20 tokens from the user’s wallet to a wallet you control. The equivalent USD amount and the admin fee is then added to your monthly invoice.
1. Create a Gas Manager policy
To enable your users to pay gas using an ERC-20 token, you need to create a “Pay gas with any token” Policy via the Gas Manager dashboard. You can customize the policy with the following:
- Receiving address: you must specify an address you own where the users’ ERC20 tokens will be sent to as they pay for gas. The token transfer to this address is orchestrated by the paymaster contract and happens automatically at transaction time.
- Tokens: you must select which tokens users should be able to pay gas with. Learn more here.
- ERC-20 transfer mode: choose when the user’s token payment occurs.
- [Recommended] After: No upfront allowance is required. The user signs an approval inside the same user operation batch, and the paymaster pulls the token after the operation has executed. If that post-execution transfer fails, the entire user operation is reverted and you still pay the gas fee.
- Before: You (the developer) must ensure the paymaster already has sufficient allowance—either through a prior
approve()
transaction or a permit signature—before the UserOperation is submitted. If the required allowance isn’t in place when the user operation is submitted, it will be rejected upfront.
- Sponsorship expiry period: this is the period for which the Gas Manager signature and ERC-20 exchange rate will remain valid once generated.

Now you should have a Gas policy created with a policy id you can use to enable gas payments with ERC-20 tokens.

2. Create a smart Account Client
Now you can create a Smart Account Client which is configured to sponsor gas.
3. Send a sponsored UserOperation
4. Estaime ERC20 token amount of a UO
You can use the alchemy_requestPaymasterTokenQuote endpoint to do off-chain simulation to verify both the approval and the underlying userOp will succeed.
Note that changes in blockchain’s state could lead to different outcomes.
Example:
5. Simulate a ERC20 UO
You can use the alchemy_simulateUserOperationAssetChanges endpoint to do off-chain simulation to verify both the approval and the underlying userOp will succeed.
Note that changes in blockchain’s state could lead to different outcomes.
Example:
Sample response: