Gelato’s Gas Tank is a powerful alternative to traditional onchain paymasters. It acts as a cross-chain gas tank, allowing you to sponsor gas fees across any supported EVM-compatible chain — using just a single balance. Instead of maintaining balances on multiple chains, you only need to deposit funds in one place, and you’re ready to sponsor gas anywhere.
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

import { createPublicClient, http } from 'viem'
import { createBundlerClient, toSoladySmartAccount } from "viem/account-abstraction";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
3

Setup Smart Account

Any smart account that implements viem’s Account type can be used here. Check out other available smart accounts here.
const publicClient = createPublicClient({ chain: mainnet, transport: http() });
const signer = privateKeyToAccount(PRIVATE_KEY as any);

const account = await toSoladySmartAccount({ 
    client: publicClient, 
    owner: signer, 
}) 
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.
const bundlerClient = createBundlerClient({
    account,
    client: publicClient,
    transport: http(`https://api.gelato.digital/bundlers/${chainID}/rpc?apiKey=${apiKey}&sponsored=true`)
})
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.
const userOperationHash = await bundlerClient.sendUserOperation({
    account,
    calls: [{ to: account.address, value: 0n, data: "0x" }],
    maxFeePerGas: 0n,
    maxPriorityFeePerGas: 0n,
})

console.log("UserOperation Hash: ", userOperationHash);

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:
https://api.gelato.digital/bundlers/${chainID}/rpc?apiKey=${apiKey}&sponsored=true
3

Configure the UserOperation Parameters

  • Set maxFeePerGas, maxPriorityFeePerGas, and preVerificationGas to 0 (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 return preVerificationGas as 0.
  • The eth_getUserOperationGasPrice endpoint will return maxFeePerGas and maxPriorityFeePerGas as 0.
Check out the required parameters for sponsoring gas with Gas Tank in the following scenarios: