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.Documentation Index
Fetch the complete documentation index at: https://docs.gelato.cloud/llms.txt
Use this file to discover all available pages before exploring further.
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.Implementations
- Gelato Gasless SDK
- Viem
- Permissionless
- API Endpoints
npm install @gelatocloud/gasless viem
Create an API Key
Check out our How-To Guide for detailed instructions on generating an API key.
Create Smart Account
import { createGelatoBundlerClient, toGelatoSmartAccount } from '@gelatocloud/gasless';
import { createPublicClient, http } from 'viem';
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
const owner = privateKeyToAccount(process.env.PRIVATE_KEY);
const client = createPublicClient({
chain: baseSepolia,
transport: http(),
});
const account = await toGelatoSmartAccount({
client,
owner,
});
Create Bundler Client
const bundler = await createGelatoBundlerClient({
account,
apiKey: process.env.GELATO_API_KEY,
client,
pollingInterval: 100
});
Send UserOperation
const hash = await bundler.sendUserOperation({
calls: [
{
data: '0xd09de08a',
to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
}
]
});
console.log(`User operation hash: ${hash}`);
const { receipt } = await bundler.waitForUserOperationReceipt({ hash });
console.log(`Transaction hash: ${receipt.transactionHash}`);
npm install viem
Create an API Key
Check out our How-To Guide for detailed instructions on generating an API key.
Create Bundler Client
Use
https://api.gelato.cloud for both mainnets and testnets. Pass the API key in the X-API-Key header via fetchOptions.import { createPublicClient, http } from "viem";
import { createBundlerClient } from "viem/account-abstraction";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
const owner = privateKeyToAccount(process.env.PRIVATE_KEY);
const publicClient = createPublicClient({
chain: baseSepolia,
transport: http(),
});
const bundlerClient = createBundlerClient({
client: publicClient,
transport: http(`https://api.gelato.cloud/rpc/84532?payment=sponsored`, {
fetchOptions: {
headers: {
'X-API-Key': process.env.GELATO_API_KEY
}
}
}),
});
Send UserOperation
To use Gas Tank sponsorship efficiently, set
maxFeePerGas and maxPriorityFeePerGas to 0n. This allows transaction fees to be settled after execution via Gelato Gas Tank.const hash = await bundlerClient.sendUserOperation({
account,
calls: [
{
data: '0xd09de08a',
to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De',
value: 0n,
}
],
maxFeePerGas: 0n,
maxPriorityFeePerGas: 0n,
});
console.log(`User operation hash: ${hash}`);
const receipt = await bundlerClient.waitForUserOperationReceipt({ hash });
console.log(`Transaction hash: ${receipt.receipt.transactionHash}`);
npm install permissionless viem
Create an API Key
Check out our How-To Guide for detailed instructions on generating an API key.
Create Smart Account
import { createSmartAccountClient } from "permissionless";
import { createPublicClient, http } from "viem";
import { createBundlerClient, toSoladySmartAccount } from "viem/account-abstraction";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
const owner = privateKeyToAccount(process.env.PRIVATE_KEY);
const client = createPublicClient({
chain: baseSepolia,
transport: http(),
});
const account = await toSoladySmartAccount({
client,
owner,
});
Create Smart Account Client
Use
https://api.gelato.cloud for both mainnets and testnets. Pass the API key in the X-API-Key header via fetchOptions.const smartClient = createSmartAccountClient({
account,
chain: baseSepolia,
bundlerTransport: http(`https://api.gelato.cloud/rpc/84532?payment=sponsored`, {
fetchOptions: {
headers: {
'X-API-Key': process.env.GELATO_API_KEY
}
}
}),
});
Send UserOperation
To use Gas Tank sponsorship efficiently, set
maxFeePerGas and maxPriorityFeePerGas to 0n. This allows transaction fees to be settled after execution via Gelato Gas Tank.const hash = await smartClient.sendUserOperation({
account,
calls: [
{
data: '0xd09de08a',
to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De',
value: 0n,
}
],
maxFeePerGas: 0n,
maxPriorityFeePerGas: 0n,
});
console.log(`User operation hash: ${hash}`);
const receipt = await smartClient.waitForUserOperationReceipt({ hash });
console.log(`Transaction hash: ${receipt.receipt.transactionHash}`);
Use
https://api.gelato.cloud for both mainnets and testnets. Pass the API key in the X-API-Key header.Create an API Key
Check out our How-To Guide for detailed instructions on generating an API key.
Send UserOperation
To use Gas Tank sponsorship, ensure your UserOperation includes
maxFeePerGas and maxPriorityFeePerGas set to "0x0":{
"sender": "0x...",
"nonce": "0x...",
"callData": "0x...",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
...
}
const response = await fetch(
`https://api.gelato.cloud/rpc/${chainId}?payment=sponsored`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.GELATO_API_KEY
},
body: JSON.stringify({
jsonrpc: "2.0",
method: "eth_sendUserOperation",
params: [userOperation, entryPoint],
id: 1,
}),
}
);
const data = await response.json();
const userOpHash = data.result;
Estimate Gas (Optional)
const response = await fetch(
`https://api.gelato.cloud/rpc/${chainId}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.GELATO_API_KEY
},
body: JSON.stringify({
jsonrpc: "2.0",
method: "eth_estimateUserOperationGas",
params: [userOperation, entryPoint],
id: 1,
}),
}
);
const data = await response.json();
const gasEstimate = data.result;
Get UserOperation Receipt
const response = await fetch(
`https://api.gelato.cloud/rpc/${chainId}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.GELATO_API_KEY
},
body: JSON.stringify({
jsonrpc: "2.0",
method: "eth_getUserOperationReceipt",
params: [userOpHash],
id: 1,
}),
}
);
const data = await response.json();
const receipt = data.result;
Available Endpoints
eth_sendUserOperation
Send a user operation to the bundler
eth_estimateUserOperationGas
Estimate gas for a user operation
eth_getUserOperationReceipt
Get receipt for a user operation
eth_getUserOperationByHash
Get user operation by hash