How to send your first gasless transaction with Gelato Relay
Gelato Team
•
Jan 20, 2023

Creating a gasless user experience for your application allows you to offer users the ability to send transactions
without needing native tokens to pay for gas.
Gelato Relay provides out-of-the-box authentication with flexible payment support.
Just answer two easy questions first and in the time it takes to make a coffee, your first gasless tx will be ready to execute!
Questions to ask yourself before starting
1. Do you require user authentication?
If you need to authenticate a user, you need to know their original address. For gasless transactions,
Gelato Relay supports ERC2771 and EIP-712 signatures to verify and recover addresses on-chain.
The _msgSender()
function is available via inheritance to access the original sender. If you use msg.sender
directly, you’ll get the Gelato Relay contract address instead.
For example, our demo app authenticates proposal submissions to prevent double voting.
However, if anyone can create proposals, you may not need authentication at all.
2. What is the funding strategy?
Transactions can be funded in two ways:
Sponsor gas fees via 1Balance: A cross-chain pool where you deposit funds to use for any transaction on any chain. Methods: sponsoredCall or sponsoredCallERC2771.
Let users pay fees: Use callWithSyncFee.
Note: We recommend 1Balance for a streamlined experience.
For our first demo transaction, we’ll pay from the target contract balance. For the second, we’ll use 1Balance with our own SponsorKeys.
Two Steps to Best-in-Class UX
Once you’ve decided on authentication and payment strategy, just follow two steps:
Prepare the target contract by inheriting a Gelato helper contract.
Build & send the transaction in your frontend.
Reference table:
Gelato Auth | Payment | Inheriting Contract | SDK/API method |
---|---|---|---|
No | User | GelatoRelayContext | relayWithSyncFee |
Yes | User | GelatoRelayContextERC2771 | relayWithSyncFeeERC2771 |
No | 1Balance | n.a. | relayWithSponsoredCall |
Yes* | 1Balance | ERC2771Context | relayWithSponsoredCallERC2771 |
* A SponsorKey is required, available via Gelato 1Balance.
Step #1: Prepare the contract
Example (no authentication, fees paid by contract):
Example (1Balance, authenticated users):
Step #2: Build & Send the Transaction
Example (no authentication, fees paid by contract):
Example (1Balance, authenticated users):
Conclusion
By making your contracts gasless with Gelato Relay, you remove friction for users.
They no longer need to obtain native tokens to interact with your app—making onboarding seamless and UX smoother.
About Gelato
Gelato is a Web3 Cloud Platform empowering developers to create automated, gasless, and off-chain-aware Layer 2 chains and smart contracts.
Over 400 web3 projects rely on Gelato to facilitate millions of transactions across DeFi, NFTs, and gaming.
Gelato RaaS: Deploy ZK or OP L2s with account abstraction and middleware baked in.
Web3 Functions: Connect contracts to off-chain data via decentralized cloud functions.
Automate: Automate contract execution in a reliable, decentralized manner.
Relay: Provide robust, scalable gasless transactions via API.
Account Abstraction SDK: Built with Safe, combining gasless txs with secure wallets.
Subscribe to our newsletter and turn on Twitter notifications for the latest Gelato updates!
Interested in building the future of Web3? Explore open roles and apply here.