Gasless Transactions
The simplest way to cover users' gas
Gasless Transactions are transactions where you pay the gas fees on behalf of your users. 0xEssential provides SDKs for implementing Gasless Transactions in your frontend and smart contracts. Our Gasless Transactions tooling complements NFT Global Entry and Burner Wallets, but can also be used independently on any EVM chain.
0xEssential's approach to Gasless Transactions uses EIP-2771 meta-transactions. Your users sign an EIP-712 payload with their wallet or private keys. That signature is sent to a relaying service that submits a transaction for the message signer, paying the transaction fee.
Why Go Gasless
Going gasless removes friction for users. When a new user discovers your application, you want their time-to-fun to be as quick as possible. If they need to add a new chain to their wallet and bridge funds to get some esoteric gas token you delay or deny that fun.
0xEssential's tooling can help you solve this friction easier than any other meta-transaction tooling. Our React SDK is based on wagmi, so adding meta-transaction support to your frontend requires little more than changing an import. Easy to add, easy to drop. No super custom SDK that requires rewriting your frontend.
Our love for meta-transactions emanates from the related UX wins they enable. Many of the benefits ERC-4337 Account Abstraction is aiming for are achievable today with 0xEssential's tooling for Gasless Transactions, NFT Global Entry and Burner Wallets. This guide will help you set up Gasless Transactions - you can add Global Entry and Burner Wallet integrations later.
Architecture
To implement 0xEssential's Gasless Transactions, consider these 4 entities:
Implementation Contract
The implementation or target contract is your smart contract that contains your business logic. In most cases you will not be able to use Gasless Transactions with existing contracts. Your implementation contract must inherit EssentialContext
or a compatible contract and replace all msg.sender
calls with _msgSender()
. You can deploy this contract on any EVM chain we support.
Forwarder
A forwarding contract receives transactions, verifies signatures, and calls your implementation contract. 0xEssential provides canonical forwarder deployments on most EVM chains at 0x000000000066b3aED7Ae8263588dA67fF381FfCa
. You may also deploy your own EssentialForwarder
to customize the name.
Relayer
A relayer is an API service that receives meta-transaction signatures and is responsible for submitting and paying for transactions. 0xEssential does not provide relayer infrastructure. We do provide OSS for using Open Zeppelin Defender as your relayer service, and a NextJS API route example for building your own custom relayer. Relayer security and reliability is important - we recommend Open Zeppelin with a proxy to keep your API keys secret.
Signer
The user submitting a meta-transaction and their connected address is the Signer. 0xEssential's React SDK handles all of the signature building and requesting. The usePrepareContractWrite
hook mimics wagmi
and can conditionally execute meta-transactions or standard transactions based on gas price, user preference or dev defined requirements.
Getting Started
Before writing any code we suggest deciding on your relayer service. This service handles paying for transactions so you'll want to take security seriously. Many services offer transaction relaying and should be compatible with 0xEssential's Gasless Transactions. If you plan on using NFT Global Entry, custom code may be required. We recommend Open Zeppelin Defender and provide code you can deploy.
Once you have a relaying service that supports your chosen chain, we recommend starting with your smart contracts and working towards your frontend.
Last updated