Skip to main content
Send transactions and wait for the final result in a single call. Sync methods are ideal for fast chains where you want immediate confirmation feedback.

Getting Started

1

Import Dependencies

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

Create Relayer Client

To create an API Key, visit the Gelato App and navigate to Relayer > API Keys.
const relayer = createGelatoEvmRelayerClient({
  apiKey: process.env.GELATO_API_KEY,
  testnet: true // Use false for mainnet
});
3

Send Sync Transaction

Submit a transaction and wait for the final result:
const receipt = await relayer.sendTransactionSync({
  chainId: 84532,
  to: '0xContractAddress',
  data: '0xCalldata',

  timeout: 30000  // Required: max wait time in ms
});

console.log('TX hash:', receipt.transactionHash);

Parameters

ParameterTypeRequiredDescription
chainIdnumberYesTarget chain ID
toAddressYesTarget contract address
dataHexYesTransaction calldata
authorizationListAuthorization[]NoEIP-7702 authorizations
contextunknownNoOptional context (e.g., from fee quote)
timeoutnumberYesMax wait time in milliseconds

Return Type

The sync method returns a TransactionReceipt directly on success, or throws an error on failure:
const receipt = await relayer.sendTransactionSync({
  chainId: 84532,
  to: '0xContractAddress',
  data: '0xCalldata',
  timeout: 30000
});

// receipt contains:
// - transactionHash: Hex
// - blockNumber: bigint
// - gasUsed: bigint
// - ... other receipt fields

Async vs Sync Comparison

// Returns immediately with task ID
const taskId = await relayer.sendTransaction({
  chainId: 84532,
  to: '0xContract',
  data: '0xCalldata',
});

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

Additional Resources