How to create your first gasless app
Gelato Team
•
Mar 7, 2023

Introduction

Summary:
Gasless transactions abstract gas payment away from wallets (e.g. MetaMask), enabling users to send signed transactions without holding the native token.
Gelato Relay enables meta transactions so users can interact with smart contracts without paying gas.
This guide explains how to enable gasless transactions for your contracts and build dApps that offer a gasless user experience.
Showcase App: Gasless Proposal Voting for DAOs
Example app: DAO members create proposals, then have 30 minutes to vote. Afterward, an automated Gelato task closes the voting period.
Not Gasless at first
Initially, proposals and votes are signed transactions. Repo:
github.com/donoso-eth/gasless-voting.
Run a local Hardhat node:
Launch the Angular frontend:
App runs at http://localhost:4200/
. Test proposals locally before deploying to testnet for relayed transactions.
Why Gasless?
DAO participation is often hindered by gas costs. To remove friction, we convert our contract to be relay-aware.
Here’s how a relayer works:
The app sends an HTTP POST request to Gelato via the Relay SDK.
Gelato forwards the request to the Relay contract.
The target contract executes the transaction.
How to Gasless Step by Step
We’ll convert createProposal()
and vote()
into gasless transactions, following the 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 |
*Requires SponsorKey from Gelato 1Balance.
Transaction without authentication and 1Balance (relayWithSyncFee)
We allow all users to create proposals, no authentication needed. We use Gelato’s SyncFee
payment method.
Inherit contract: GelatoRelayContext
SDK method: relayWithSyncFee
Smart Contract Update
Ensures only the Gelato Relay contract can call
createProposal()
.Transfers fees to Gelato Relay’s feeCollector.
Frontend Update (SDK)
✅ Gasless transaction complete! Demo:
gelato-gasless-dao.web.app/landing
Transaction with authentication + 1Balance (relayWithSponsoredCallERC2771)
Inherit contract: ERC2771Context
SDK method: relayWithSponsoredCallERC2771
Configure 1Balance in the dashboard, deposit GETH, create app, and copy your sponsor API key.
Smart Contract Update
Frontend Update (SDK)
Bonus: Implementing Gelato Automate
In the demo app, Gelato Automate is used to close proposals after ~30 minutes. See Automate contract addresses and the repo.
About Gelato
Gelato is a Web3 Cloud Platform enabling developers to build automated, gasless, and off-chain-aware Layer 2 chains and smart contracts.
400+ web3 projects use Gelato to power millions of DeFi, NFT, and gaming transactions.
Gelato RaaS: Deploy ZK or OP L2 chains with account abstraction and middleware baked in.
Web3 Functions: Connect contracts to off-chain data via decentralized cloud functions.
Automate: Automate smart contracts with decentralized execution.
Relay: Enable robust, gasless transactions with a simple API.
Account Abstraction SDK: Built with Safe, combining gasless transactions with the security of Safe 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.