Skip to main content

Turbo Relayer

Send gasless transactions directly to any contract. The relayer handles gas payment and transaction submission on your behalf.
1

Install Dependencies

npm install @gelatocloud/gasless viem
2

Initialize Relayer Client

import { createGelatoEvmRelayerClient } from '@gelatocloud/gasless';

const relayer = createGelatoEvmRelayerClient({
  apiKey: process.env.GELATO_API_KEY,
  testnet: true
});
3

Send Transaction

const id = await relayer.sendTransaction({
  chainId: 84532, // Base Sepolia
  data: '0xd09de08a',
  to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
});

try {
  const receipt = await relayer.waitForReceipt({ id });
  console.log(`Transaction hash: ${receipt.transactionHash}`);
} catch (error) {
  console.log(`Transaction failed: ${error.message}`);
}

Turbo Relayer with Smart Account

Enable smart account features on any EOA using EIP-7702. Batch multiple calls, use session keys, and maintain the same wallet address.
1

Install Dependencies

npm install @gelatocloud/gasless viem
2

Create Gelato Smart Account

import {
  createGelatoSmartAccountClient,
  toGelatoSmartAccount,
} from "@gelatocloud/gasless";
import { createPublicClient, http, type Hex } from "viem";
import { baseSepolia } from "viem/chains";
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";

const owner = privateKeyToAccount(
  (process.env.PRIVATE_KEY ?? generatePrivateKey()) as Hex
);

const client = createPublicClient({
  chain: baseSepolia,
  transport: http(),
});

const account = toGelatoSmartAccount({
  client,
  owner,
});
3

Setup Relayer Client

const relayer = await createGelatoSmartAccountClient({
  account,
  apiKey: process.env.GELATO_API_KEY,
});
4

Send Transaction

const receipt = await relayer.sendTransactionSync({
  calls: [
    {
      to: "0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De",
      data: "0xd09de08a",
    },
  ],
});

console.log(`Transaction hash: ${receipt.transactionHash}`);

Examples Repository

Explore complete working examples in our GitHub repository:

Gasless Examples

Full examples for Turbo Relayer, Smart Accounts, and more.