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.
Sponsor gas fees for your users using Gelato’s cross-chain Gas Tank. Deposit funds once and sponsor transactions across all supported networks.
Implementations
Gelato Gasless SDK
With 7702 Smart Account
Relay 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. Initialize Relayer Client
import { createGelatoEvmRelayerClient } from '@gelatocloud/gasless';
import { baseSepolia } from 'viem/chains';
const relayer = createGelatoEvmRelayerClient({
apiKey: process.env.GELATO_API_KEY,
testnet: baseSepolia.testnet
});
Generate Payload
Generate the payload for your target contract function:import { encodeFunctionData } from 'viem';
const data = encodeFunctionData({
abi: [{ name: 'increment', type: 'function', inputs: [], outputs: [] }],
functionName: 'increment'
});
Send Transaction
const id = await relayer.sendTransaction({
chainId: baseSepolia.id,
data: data,
to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
});
console.log(`Gelato transaction id: ${id}`);
try {
const receipt = await relayer.waitForReceipt({ id });
console.log(`Transaction hash: ${receipt.transactionHash}`);
} catch (error) {
console.log(`Transaction failed: ${error.message}`);
}
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 {
createGelatoSmartAccountClient,
toGelatoSmartAccount,
} from "@gelatocloud/gasless";
import { createPublicClient, http, type Hex } from "viem";
import { baseSepolia } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const owner = privateKeyToAccount(process.env.PRIVATE_KEY as Hex);
const client = createPublicClient({
chain: baseSepolia,
transport: http(),
});
const account = toGelatoSmartAccount({
client,
owner,
});
Create Relayer Client
const relayer = await createGelatoSmartAccountClient({
account,
apiKey: process.env.GELATO_API_KEY,
});
Send Transaction
const receipt = await relayer.sendTransactionSync({
calls: [
{
to: "0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De",
data: "0xd09de08a",
},
],
});
console.log(`Transaction hash: ${receipt.transactionHash}`);
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 Relay Request
const response = await fetch('https://api.gelato.cloud/rpc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'relayer_sendTransaction',
params: {
chainId: '84532',
to: '0x...',
data: '0x...',
payment: { type: 'sponsored' }
}
})
});
const data = await response.json();
const taskId = data.result;
console.log(`Task ID: ${taskId}`);
Check Task Status
Poll for the transaction status using relayer_getStatus:const statusResponse = await fetch('https://api.gelato.cloud/rpc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'relayer_getStatus',
params: { id: taskId }
})
});
const statusData = await statusResponse.json();
const status = statusData.result.status;
// 200 = Included, 400 = Rejected, 500 = Reverted
if (status === 200) {
console.log(`Transaction hash: ${statusData.result.receipt.transactionHash}`);
} else if (status >= 400) {
console.log(`Failed: ${statusData.result.message}`);
}
Additional Resources