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, StatusCode, sponsored } 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',
  payment: sponsored(),
  to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
});

const status = await relayer.waitForStatus({ id });

if (status.status === StatusCode.Included) {
  console.log(`Transaction hash: ${status.receipt.transactionHash}`);
}

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,
  sponsored,
  StatusCode,
} 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 result = await relayer.sendTransactionSync({
  payment: sponsored(),
  calls: [
    {
      to: "0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De",
      data: "0xd09de08a",
    },
  ],
});

if (result.status === StatusCode.Included) {
  console.log(`Transaction hash: ${result.receipt.transactionHash}`);
}

Examples Repository

Explore complete working examples in our GitHub repository:

Gasless Examples

Full examples for Turbo Relayer, Smart Accounts, ERC-20 payments, multichain transactions, and more.