Tips and Tricks for implementing a relayer into your web3 app

March 10 2023

One of the biggest challenges that faces any application developer is user experience. This has been the case throughout web2, and is now often considered the top priority in web3. Web2 applications typically rely on a lot of abstraction so that users are not aware of what is happening on the backend; however, this is something that we are yet to see reach its full potential in web3. There is still a complicated flow of signing transactions, paying gas fees, and waiting for transactions to finalize.

Fortunately, relayers are here to simplify the process. A relayer sends transactions to the blockchain on behalf of the user, enabling a layer of abstraction that comes with an improved gas experience, batched transactions, faster transactions, and more. You can learn more about the features of a relayer by reading this article on meta transactions. Today’s article will discuss some things developers should consider when implementing a relayer into their web3 app.

Deciding when to use a relayer

Many user-facing apps will benefit from using a relayer, as they drastically improve user experience. Relayers also help with gas efficiency, which can be especially beneficial if your dapp requires a lot of writing to the blockchain. It is recommended to use a relayer if any of the following are true for your app:

  • Looking to onboard more web2 users

  • Does not require deep crypto knowledge

  • Has a fast-paced user experience, such as a game, and would benefit from faster transaction finality

  • Requires many small transactions throughout the experience, such as small in-game battles or reactions and interactions on a social media application

However, it’s important to understand that although relayers improve user and gas experience, they do act as an intermediary between the user and the blockchain. This is not necessary or recommended for all web3 applications, and abstracting transactions can sometimes take away from the user experience. Some examples of use cases that may not benefit from a relayer are:

  • Processing a small number of large transactions, such as yield farming

  • Apps that do not require fast transaction processing, such as token trading

  • Apps that require the user to understand crypto and the blockchain, such as web3 developer-focused tooling or various types of DeFi

All that to say, if you want to target web2 users and provide a seamless experience, which includes most use cases outside of finance, implementing a relayer can help significantly.

Optimizing for gas efficiency

Relayers have multiple features, and the ability to deliver gasless transactions is one of the most sought-after. Gasless transactions allow the developer to cover the transaction cost for the user, making transacting and onboarding seamless. In this case, optimizing transaction costs is in your best interest! But, even if you don’t want to implement gasless transactions, relayers can help lower gas for your users.

There are multiple ways you can optimize gas, and the Sequence Relayer has built-in features to accomplish exactly that:

  • Batched transactions.

     

    This means multiple transactions can be pulled together and written to the blockchain in one transaction. As only one transaction is sent to the chain, gas cost is lower than if you were to send them all individually. Remember that not all transactions can be batched though — only independent transactions that do not rely on another to be finalized before it can go through.

  • Optimal gas pricing

    . Gas price is dependent on the network — the more congested it is, the higher price a user will have to pay for their transaction to be mined. If the user pays more for the transaction, it will be processed faster. The Sequence Relayer automatically monitors the network and sets the gas price at an optimal level to decrease gas cost while increasing transaction finality.

  • Optimized timing of transactions

    . A relayer can be used to find a better time in which to process transactions, and allow users to continue playing or interacting with your application while their transaction is waiting for lower gas.

To further optimize gas, you can consider deploying your application on a sidechain or L2 that has cheaper costs, since the Sequence Relayer is compatible with all smart contracts on all EVM-compatible chains.

Building a better user experience

To make the most out of implementing a relayer, you will want to use the built-in UX features. The Sequence Relayer enables all of the following:

  • Batched transactions. We talked about how these can optimize gas, but they also allow a user to only sign one transaction instead of multiple, improving UX.

  • Fire + forget model. With fast transaction finality, developers can send a transaction to the relayer and trust that it will be committed to the network efficiently. There’s no need to wait for it to finalize before continuing with the user experience.

  • Parallel transactions. Allowing transactions to be dispatched in parallel with one another can massively increase the speed of transaction finality. Keep in mind that, as with batching, this only works with independent transactions.

  • Gas abstraction. If you do not want to sponsor the gas for your users, gas abstraction can allow users to pay gas fees in any token they want, which means they do not have to hold the chain’s native token in their wallet.

  • Automatically integrate with the Sequence Wallet, a user-friendly smart contract wallet.

You can also completely abstract anything related to the blockchain. By utilizing the Sequence Wallet, which allows a user to create a web3 wallet in the same familiar way they would sign up for a web2 application, in conjunction with a Sequence Relayer server, you can sign transactions for your users without them even being aware that it is a transaction. You could, for example, programmatically mint an NFT using your own Sequence Wallet on the backend and send this NFT to the user’s Wallet. The user can use this NFT in the dapp or game without ever knowing where it came from or even that it is a token on the blockchain.

Reporting

An underrated feature of a relayer is the ability to easily see everything your users are doing on your application without having to check Etherscan or build your own indexer. You can use this data to build reporting to better predict the costs you or your users will incur. Sequence Pro provides top-notch reporting when you implement the Relayer into your dapp, allowing you to easily see the challenges your users are facing and how you can fix them.

To implement the Sequence Relayer in your app for free, check out the docs, which gives you a ready-to-run template for building a relayer server in Node.js. You can also join our Discord to learn and share more UX and gas efficiency tricks.


Sequence is the leading all-in-one development platform for integrating web3 into games. Onboard, monetize, grow, and retain players with Sequence’s award-winning technology. From collectibles and ownable rewards to fully on-chain experiences, Sequence’s easy-to-integrate platform solves blockchain complexities, so developers can focus on creative execution and delivering amazing player experiences. Trusted by hundreds of games, thousands of developers, and powering millions of users, Sequence is backed by Take-Two Interactive, Ubisoft, Xsolla, Bitkraft, Brevan Howard, Coinbase, Polygon, and more. To learn more, please visit: https://sequence.xyz/

---

Have any suggestions on how to improve Sequence development platform? Request a new feature here!


Written by

Robert Guenette

Product Marketing Director

Share this article

Stay up to date with Sequence

We'll keep you informed about the latest and best in web3 game development.

Stop fretting web3. Just build.

Create now with the Sequence Builder or chat with a product expert to learn more.