Enable Gasless Transactions For Your dApp With Gelato Relay!
Gelato Team
•
Aug 18, 2023

This is an updated version of a developer tutorial originally posted on Thirdweb.
TL;DR
This guide shows you how to build a gasless app using Gelato Relay SDK and Thirdweb's React SDK. We'll build two React components, CounterApp
and GaslessNFTApp
, that let users increment a counter or mint an NFT without paying gas fees.
Web3 onboarding is complex due to gas fees. Gelato Relay removes this friction by sponsoring transactions. Combined with 1Balance, developers can cover fees for users across all supported networks. We'll also use Thirdweb’s React SDK for wallet connections and contract interactions.
Initialization & Dependency Installation
Step 1: Clone the repo & install dependencies
Step 2: Run the project
Visit http://localhost:3000/ to see the app.
Step 3: Connect your wallet and switch to Polygon mainnet. Use Thirdweb's "Connect Wallet" button in the UI.
When you click increment, Gelato Relay’s Status API shows your task ID and progress. You didn’t pay gas or sign an onchain tx — that’s a gasless transaction.
Behind the Scenes
The sendRelayRequest
function in CounterApp.tsx
instantiates the Gelato Relay SDK, builds a relay request, and submits it:
The ABI builds the payload, which tells Relay what contract function to call. Thirdweb’s useChainId()
hook fetches the chain ID.
Sponsor Transactions using 1Balance
To sponsor fees for users across all networks:
Log in to relay.gelato.cloud and connect your wallet.
Deposit USDC into 1Balance (Polygon) to cover gas for all transactions across networks.
Optionally use testnets (Goerli, Optimism Goerli, etc.) for trial runs.
Register your contract (or toggle “Any Contract”). Create your app to get an API key. Use it in your code:
Security note: Don’t expose your API key in frontend code. Use a backend proxy to keep it secret.
How to Build Your dApp
The repo includes GaslessNFTApp.tsx
. Enable it in AppContainer.tsx
:
Uncomment the import and component, then restart your dev server. The new app will appear at localhost:3000.
Deploy your contract with Thirdweb
Use Thirdweb’s dashboard to deploy the NFTDrop contract. Set free/unlimited claim conditions for demo purposes. Paste your contract address into GaslessNFTApp.tsx
:
Thirdweb’s hooks like useContract()
and useNFTs()
simplify ABI management and queries:
Paste your 1Balance sponsor API key:
Now, when you click “Claim NFT”, Gelato Relay handles the transaction gaslessly.
Conclusion
With Gelato Relay + 1Balance, you can build dApps that sponsor gas for users, creating smooth onboarding. CounterApp shows gasless state updates, while GaslessNFTApp demonstrates gasless NFT minting. Thirdweb’s React SDK simplifies wallet integration and contract queries.
About Gelato
Gelato is Web3’s decentralized backend, empowering builders to create augmented smart contracts that are automated, gasless, and off-chain aware across Ethereum, Arbitrum, Polygon, Optimism, zkSync, and more. 400+ Web3 projects rely on Gelato to power millions of DeFi, NFT, and gaming transactions.
Core Services:
Web3 Functions: Connect contracts to off-chain data & computation via decentralized cloud functions.
Automate: Execute smart contracts automatically in a reliable, decentralized way.
Relay: Provide users with reliable, scalable gasless transactions via API.
Account Abstraction SDK: Built with Safe, combining Gelato’s gasless infra with secure smart contract wallets.
Subscribe to our newsletter and follow Gelato on Twitter for updates.
Want to join the Gelato team? Explore open positions and apply here.