Ramine Darabiha · Product and R&D Leader

How to Pay Gas Fees for Users of Your dApp: Meta Transactions on Tezos

Cached copy of an article from Tezos Spotlight, 2023-12-19, served from ramine.net so it stays readable if the original goes offline.

View the original

This tutorial introduces meta transactions on Tezos and covers how to use the Gas Station API to cover gas fees for dApp users.

To onboard the next billion users on Web3, simplifying user onboarding and improving the user experience of dApps is extremely important. For many users, the mindset shift from using Web2 applications to using Web3 dApps can be a steep slope. One example of a major barrier to onboarding users to a dApp is the need to pay gas fees in order to interact with the dApp.

Users of dApps built on Tezos need to open a wallet and acquire XTZ (tez) in order to start using a dApp, which can be a barrier to user onboarding. To get over this barrier, the idea of meta transactions was developed.

What are Meta Transactions?

Meta transactions allow dApp developers to improve the user experience of their applications by removing the need for users to hold tokens for paying gas fees. This is done by separating the transaction's sender (user) from the gas payer. The gas payer (usually another smart contract wallet) acts as the relayer for the transaction.

In Web2, an app like Instagram allows users to post pictures to their feed without the need to pay a fee each time they post. Users can also like posts, leave comments, and send DMs without paying fees for each operation. Meta transactions allow Web3 dApps to provide a similar experience, making dApps more user-friendly.

There are two types of meta transactions. Gasless transactions allow users to interact with a dApp without paying gas fees at all. Gas abstraction allows users to pay gas fees using a token other than the native token of the application.

TZIP-17 and Meta Transactions

TZIP-17 (the permit proposal) introduced the standard for account abstraction. This standard allows pre-signing: a way to have transactions signed and submitted separately. TZIP-17 is the standard that allows meta transactions to work on Tezos. With this standard, a relayer can submit a user's pre-signed (meta) transaction and pay the tez fees on their behalf.

Gas stations are a good example of systems that can act as a relayer for transactions on a dApp. A gas station, as the name implies, is a system that allows you to store tez (or any supported token) to be used in paying for gas on behalf of your dApp users.

The rest of the tutorial walks through building a voting dApp on the Marigold Gas Station API: adding credits, adapting the smart contract so the sender comes from transaction parameters rather than sp.sender, registering the contract's entrypoints with the gas station, and routing front-end transactions through the gas station's /operation endpoint so users never see a fee prompt.

By Adebola Adeniran (Trilitech).