This example demonstrates how to use Gelato's Turbo Relayer for gasless transactions with sponsored payments.
The Relayer is the simplest integration path - it relays transactions directly without requiring a smart account. Gelato pays the gas fees (sponsored mode).
- Node.js >= 23
- Gelato API Key from app.gelato.cloud
-
Install dependencies:
pnpm install
-
Configure environment variables (see Environment Variables section below)
This example loads environment variables from two sources:
- Root
.env(at project root) - Shared defaults for all examples - Local
.env(in this directory) - Optional overrides
Local values take precedence over root values. To set up:
-
Copy the root
.env.exampleto.envat the project root:cp ../../../.env.example ../../../.env
-
Add your API key to the root
.env:GELATO_API_KEY="your-api-key" -
(Optional) Create a local
.envin this directory to override specific values for this example
pnpm devconst relayer = createGelatoEvmRelayerClient({
apiKey: GELATO_API_KEY,
testnet: chain.testnet
});Creates a relayer client configured for Base Sepolia testnet.
const id = await relayer.sendTransaction({
chainId: chain.id,
data: '0xd09de08a',
to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
});Submits a transaction to Gelato. Your Gelato Gast Tank covers gas costs.
const status = await relayer.waitForStatus({ id });
if (status.status === StatusCode.Success) {
console.log(`Transaction hash: ${status.receipt.transactionHash}`);
}Polls until the transaction reaches a final state (Success, Rejected, or Reverted).
| Concept | Description |
|---|---|
sponsored() |
Gelato pays gas fees |
sendTransaction |
Async - returns immediately with ID |
waitForStatus |
Blocks until transaction is finalized |
StatusCode.Success |
Transaction successfully included on-chain |