Skip to main content
Gelato is deprecating the SyncFee payment pattern (callWithSyncFee and GelatoRelayContext). The old pattern will no longer be available. To continue accepting ERC-20 token payments for relayed transactions, you must update your contracts and frontend to use direct token transfers.

What’s Changing?

The old approach required:
  • Contract inheritance from GelatoRelayContext
  • Fee data encoded in calldata - Gelato appended fee, feeToken, and feeCollector to the calldata
  • On-chain fee extraction - Contract called _transferRelayFee() to decode and transfer fees
  • onlyGelatoRelay modifier - To restrict who can call the function
// OLD WAY - Being deprecated
import {GelatoRelayContext} from "@gelatonetwork/relay-context/contracts/GelatoRelayContext.sol";

contract MyContract is GelatoRelayContext {
    function myFunction() external onlyGelatoRelay {
        // Your logic here

        // Extract fee from calldata and transfer to Gelato
        _transferRelayFee();
    }
}

Migration Steps

1

Update Your Smart Contract

Remove the old Gelato inheritance and add direct token transfer.
import {GelatoRelayContext} from "@gelatonetwork/relay-context/contracts/GelatoRelayContext.sol";

contract MyContract is GelatoRelayContext {
    uint256 public counter;

    function increment() external onlyGelatoRelay {
        counter++;

        // Fee extracted from calldata
        _transferRelayFee();
    }
}
Changes Required:
  1. Remove GelatoRelayContext inheritance
  2. Remove _transferRelayFee() calls
  3. Remove onlyGelatoRelay modifier
  4. Add feeToken, feeCollector, and fee parameters to your function
  5. Add direct IERC20.transfer() call from the contract (or transferFrom with permit)
2

Deploy Your Updated Contract

Deploy your updated contract to the network.
If your contract is not upgradeable and contains important state data, a migration strategy will be required to transfer the state to the new contract.
3

Update Frontend to Get Fee Data

Your frontend now needs to fetch the fee collector and fee quote.
import { createGelatoEvmRelayerClient } from '@gelatocloud/gasless';
import { createPublicClient, http, formatUnits } from 'viem';
import { baseSepolia } from 'viem/chains';

const USDC_ADDRESS = '0x036CbD53842c5426634e7929541eC2318f3dCF7e';

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

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

// Get fee collector address
const capabilities = await relayer.getCapabilities();
const feeCollector = capabilities[baseSepolia.id].feeCollector;

// Estimate gas for your transaction
const gasEstimate = await publicClient.estimateGas({
  to: contractAddress,
  data: functionData
});

// Get fee quote in token
const quote = await relayer.getFeeQuote({
  chainId: baseSepolia.id,
  gas: gasEstimate,
  token: USDC_ADDRESS
});

console.log('Fee:', formatUnits(quote.fee, 6), 'USDC');
console.log('Fee Collector:', feeCollector);
4

Update Frontend Transaction Encoding

// OLD WAY - Gelato appended fee data to calldata
const functionData = contract.interface.encodeFunctionData("increment", []);

await gelatoRelay.callWithSyncFee({
  chainId: chainId,
  target: contractAddress,
  data: functionData,
  feeToken: FEE_TOKEN_ADDRESS,
});

Key Changes Summary

WhatBefore (SyncFee)After (Direct Transfer)
Contract inheritanceGelatoRelayContextNone required
Fee extraction_transferRelayFee()Direct IERC20.transfer()
ModifieronlyGelatoRelayNot required
Fee data sourceEncoded in calldata by GelatoFrom Gelato API
Fee collectorExtracted from calldataFrom relayer_getCapabilities
Fee amountExtracted from calldataCalculated from relayer_getFeeData

Migration Checklist

  • Update contract to remove GelatoRelayContext and add direct transfer
  • Redeploy your updated contract
  • Update frontend to call Gelato API for fee data
  • Update frontend transaction encoding
  • Test on testnet
  • Deploy to production

API Reference

EnvironmentURL
Mainnethttps://api.gelato.cloud/rpc
Testnethttps://api.t.gelato.cloud/rpc
MethodDescription
relayer_getCapabilitiesGet supported tokens and fee collector per chain
relayer_getFeeDataGet fee quote with exchange rate and gas price
relayer_sendTransactionSubmit transaction for relay
relayer_getStatusCheck transaction status

Example Implementations