Best Practices/Recommendations:
When sending multiple UserOps back-to-back, querying the nonce from different providers may cause inconsistencies and stale nonces. For high-throughput use cases, we recommend:
- Using parallel nonces so ordering doesn’t matter.
- Managing nonces internally (query once, then increment locally for subsequent UserOps).
Important: When using Gelato Bundler for
Sponsoring
Transactions with Gas Tank
, both maxFeePerGas
and maxPriorityFeePerGas
are set to 0
.
This allows transaction fees to be accurately settled post-execution, rather than upfront via the EntryPoint.Using Viem
To start sponsoring transactions with Gas Tank using Viem, follow these steps:1
Create a API Key
Check out our How-To Guide for detailed instructions on generating a API key.
2
Import Dependencies
3
Setup Smart Account
Any smart account that implements viem’s
Account
type can be used here.
Check out other available smart accounts here.4
Create a Bundler Client
Create a
BundlerClient
with the account and publicClient and pass the apiKey
and sponsored
set to true
as query parameter to the transport option. Learn more about Bundler Client here.5
Send a UserOperation
Send a
UserOperation
with the bundlerClient
and the account
and set maxFeePerGas
and maxPriorityFeePerGas
to 0
(0x0). This allows transaction fees to be settled after execution, rather than through the EntryPoint.Using Bundler API Endpoints
To start sponsoring transactions with Gas Tank directly with Bundler API Endpoints, follow these steps:1
Create a API Key
Check out our How-To Guide for detailed instructions on generating a API key.
2
Set `sponsored` query parameter to `true`
When calling Gelato API endpoints, make sure to include the
apiKey
and sponsored
set to true
as a query parameter.Your Bundler URL will look like this:3
Configure the UserOperation Parameters
- Set
maxFeePerGas
,maxPriorityFeePerGas
, andpreVerificationGas
to0
(0x0). This allows transaction fees to be settled after execution, rather than through the EntryPoint. - Leave all paymaster-related fields empty (i.e
paymaster
,paymasterData
,paymasterPostOpGasLimit
,paymasterVerificationGasLimit
).
When you set
sponsored
to true
in the query params:- The
eth_estimateUserOperationGas
endpoint will returnpreVerificationGas
as0
. - The
eth_getUserOperationGasPrice
endpoint will returnmaxFeePerGas
andmaxPriorityFeePerGas
as0
.
Check out the required parameters for sponsoring gas with Gas Tank in the following scenarios: