Abstract Away Gas Tokens and Fees with Circle’s Gas Station

Web3 Services Programmable Wallets API Gas Station Developer

 

blog-gas-stations

Gas Station abstracts gas fees from the end-user during a blockchain transaction using Programmable Wallets, vastly improving the user’s experience.

Introduction

Despite its promises to democratize finance and revolutionize industries such as art, video games, and music, Web3 is still often difficult to navigate, especially for people used to the seamless UX offered by iOS and Android apps. One of the biggest culprits of Web3 UX problems is the concept of gas.

Gas has no real equivalent in Web2.0; equating it to a transaction fee is close, but doesn’t really encapsulate all the UX issues it presents. Why? Two reasons: gas costs are highly volatile, and gas must be paid in different currencies on different blockchains.

In this article, we’ll walk through Circle Gas Station: a service that allows developers to build experiences that completely abstract gas fees and gas tokens—both for their end users and themselves. It makes Web3 payments as seamless and easy as credit cards. We’ll look at the details of Circle Gas Station, how it works, and then point you to a tutorial of how to conduct a gasless transaction.

Defining gas and gas price

On virtually every blockchain that supports smart contracts, transactions involve running a piece of code and storing/modifying data. Even the simplest transaction of sending tokens from one wallet to another entails updating a ledger which tracks token balances.

Since anyone can create code and store data on a public blockchain such as Ethereum, it’s important to charge for this service. Doing so prevents the system from being spammed and choking from a large number of requests.

This is where gas comes in; gas is simply a unit that represents the amount of computation a particular transaction request requires. The more complex the computation, the higher the amount of gas needed.

For every deterministic transaction, the amount of gas required remains the same. However, the price of each unit of gas does not; it is dependent on how much traffic is currently being experienced by the system. The price of one unit of gas at a particular block is known as the gas price.

The gas fee is simply the product of the amount of gas required by your transaction and the current price of one unit of gas.

Gas fee = gas needed x gas price

This fee typically has to be paid in the native token of the blockchain. On Ethereum, this is ETH. On Polygon, this is Matic. On Solana, this is SOL, and so on.

Therefore, gas fees typically present two major problems that deter users:

  1. Gas is often expensive
    On popular blockchains such as Ethereum, gas can be expensive. In fact, when Ethereum experiences a spike in traffic, there have been instances of wallets paying upwards of $10,000 in gas fees.

    Gas prices are also notoriously hard to predict. Prices can fall by as much as 90% in less than an hour. Users who sent what was an appropriate gas fee can find themselves waiting for hours for their transaction to be included in a block because of a sudden spike in costs.
  2. Gas must be paid in a specific currency
    As mentioned above, every blockchain has a very specific currency for its gas fees. Even if you’re transacting purely in USDC on a dApp, you’ll still typically be required to have ETH to pay the gas for your transaction on Ethereum (or MATIC on Polygon).

    The concept of having two different currencies to conduct transactions is confusing and cumbersome, and it’s a stopping point for many potential Web3 users.

Overview of Circle’s Gas Station

Circle’s Gas Station solves this problem by abstracting away gas and gas fees from the end user. It does so by enabling developers to sponsor all or part of the fee on behalf of its users, not only on Ethereum, but also on side chains or L2s such as Polygon, where the gas fees are greatly reduced. This creates a gas-reduced or gas-free user experience and removes a huge amount of the friction in using web3 dApps.

What is ERC-4337?

To accomplish this, Circle utilizes the ERC-4337 account abstraction protocol which has been touted as the greatest change to Ethereum since the Merge.

ERC-4337 aims to increase security and usability in Ethereum by changing the way user accounts and transactions work. It has the following features:

  1. Smart contract wallets
    The protocol moves Ethereum away from externally owned wallets to smart-contract-based accounts. Since these smart-contract-based accounts are controlled by code, they offer dApps more flexibility when it comes to security and control. For instance, using these wallets can remove the risk of user’s losing assets because of their mistakes.
  2. Decoupling transactions and gas fees
    The protocol calls for the decoupling of initiating transactions and paying for the transactions in ETH, thus enabling users to conduct transactions without actually having any ETH in their wallet.
  3. Gas payment in ERC20 tokens
    The proposal allows for gas fees to be paid in any ERC20 token and not just ETH. This is a huge boost to dApps powered by stablecoins such as USDC, as they will no longer require their users to have ETH at all times.
  4. Sponsored transactions
    It is now natively possible for a third party to sponsor transactions on someone else’s behalf. This eliminates a major obstacle users face of having to pay for transactions before doing anything remotely useful in Web3.

The protocol also introduces other innovations such as multi-signatures, recovery options, and spending limits.

Circle Gas Station

Circle Gas Station builds on top of this protocol, allowing developers to seamlessly create gasless experiences. It does so by leveraging the following components in the Web3 Services Console:

  • Paymaster - an ERC-4337 contract that pays on-chain gas on behalf of a user according to certain sponsorship conditions. On the Web3 Services Console, go to your Paymaster setup to create and configure policies.
  • Policy - a set of rules about which transactions, wallets, and contracts are allowed to be sponsored by the developer account. Developers can also configure values such as max value of transactions, daily limits on gas expenses, and more.
  • Billing - creates a reserve for the dApp to pay gas fees (using traditional methods of payment such as credit cards).

    image1-1

The Gas Station is plug-and-play ready with all smart contract (SCA) wallets. As of now, it accommodates both custody types of Programmable Wallets on the Ethereum and Polygon.

Sending a gasless transaction

You can create your first gasless transaction by following along with this thorough interactive tutorial on user-controlled wallets. It will not only walk you through creating your first gasless transaction, but also all the steps needed to create a Web3 Services Console account, create a user, set up a user wallet, deposit funds into the wallet, and create user transactions.

Conclusion

Enabling gasless transactions for end users is the future of dApps and something that may soon be a part of any serious developer’s toolbox. You can get a head start now with the Web3 Services Platform—where you can unlock innovative Web3 functionality, empower your users, and create delightful Web3 user interfaces.

To get started with Programmable Wallets, check out the documentation available here.

Sign up for an account to get started.

New call-to-action

*Programmable Wallets application programming interface (“API”) is offered by Circle Technology Services, LLC (“CTS”). CTS is not a regulated financial services company and the API does not include financial, investment, tax, legal, regulatory, accounting, business, or other advice. For additional details, please click here to see the Circle Developer terms of service.

Back to top