Gas Saving By Biconomy

Divya
Biconomy
Published in
6 min readSep 23, 2020

Ethereum gas fees are once again the talk of the town! With average transaction fees accumulating to millions of dollars worth of income for miners on a daily basis, developers have started questioning the scalability and economic viability of the Ethereum network.

Gas is a pseudo currency reflecting the number of computational steps performed by a miner (and other network nodes) while executing a transaction. Since Ethereum contracts may contain a variety of complex logic, the exact consumption of gas can be determined once you’re executing a transaction. Currently, Ethereum’s existing gas prices respond to the relatively limited number of transactions that can be filled in a single block. Miners, in such a scenario, choose the highest-priced transactions as their priority, which means the more the demand for block space, the higher the increase in effective gas prices.

In the previous article, we looked at how Biconomy is saving up to 30% of transaction fees by modelling “ Just the right price” needed for the transaction. Transactions relayed by Biconomy save on an average of 109 gwei per transaction.

Moving forward, we are super excited to announce our relayers at Biconomy will come with gas token support that can further optimize transaction fees! This uses a mechanism that refunds gas when storage space is freed on the Ethereum Virtual Machine.

How does a Gas Token save gas?

The basic concept of Gas tokens is that it takes advantage of the Ethereum storage refund where Ethereum provides a refund for each zeroed element, to encourage smart contract developers to erase unnecessary storage.

This means that when you mint (deploy) a gas token Contract at low prices (or stable periods of congestion) and burn (destroy) them in a transaction at a higher price (or high periods of congestion), gas gets refunded and is then included in the current transaction and ultimately reduces the overall gas used and the transaction cost.

Biconomy is using the Chi Gas token by 1inchExchange in its infrastructure because of its efficiency.

How does it work?

The working is quite simple as explained above, you mint at a lower price and burn them at a higher price. The only thing to keep in mind is at what price the Chi token should be burned to make it efficient and to take the maximum benefit from it.

Calculate Efficiency

The efficiency can be calculated as below

y = (24000 * x / (35678 + 6053 * x) ) * 100

where y is the efficiency & x is the ratio of current gas price/token mint price.

Let’s take an example.

Suppose the current gas price is 100Gwei and you have minted the Chi tokens at 60 Gwei.

y = (24000 * (100/60)/ (35678 + 6053 * (100/60))) * 100

y = 87.4 (approx)

If the efficiency is >100 then only the maximum benefit of the gas refund can be redeemed. Hence, in the above example, it will be inefficient for the user to burn the token as minting cost will be higher than the burning benefit.

Calculate the number of tokens to be burn

Similar to efficiency, it is important to find how much Chi gas tokens should be burned to get the maximum refund as we can only get up to 50% of the gas refund in a transaction.

GasSpent = 21000 + gasStart — gasleft() + 16 * msg.data.length;

Total no. of tokens to be burned = (gasSpent + 14154) / 41947);

The above calculation is already being done in Chi’s “discountCHI” modifier which users only need to include in their smart contracts.

We made a cool Chi gas token calculator which you can access here: Gas Saving Model. Just add your transaction-related data and you can check how much gas can be saved by using Chi gas Token in that transaction.

Why are we using a Gas Token at Biconomy?

Since we are optimising transactions, the gas token has growing demand in helping to reduce gas fees. Developers across a number of projects are attempting to implement gas tokens internally. The biggest issue and question they face is When to mint Gas tokens because, for that, one needs to constantly monitor the market and actually spend time to come up with a solution to automate the token minting/burning process in a timely and efficient manner. All this overhead a developer would have to undertake is being handled by Biconomy, including:

1. Deciding when to Mint the token

2. Deciding when to Burn the Token

3. Monitoring the market price continuously

4. Coming up with more efficient and better solutions to decide the Average Mint Price

We believe while building a DApp and your job should be to grow your user base and your platform, not worry about gas tokens and other infra bottlenecks.

Approach 1 (Current System):

As per the current approach, we “set” the mint gas price as per our understanding of the market and what we think is the low gas price. The cron job keeps tracking the current price and if the price goes below or becomes equal to the “set” price then it automatically starts minting the gas token. It will also manage and stop the minting automatically when the current price goes above the “set” price.

Approach 2

Moving forward the plan is to keep track of current gas price (spot gas price), last 30 days average gas price and last 90 days average gas price and if the spot gas price falls between the 30 days and 90 days average or goes further down the 90 days average, we consider it a good time to buy the gas tokens.

We are planning to mint 100000 gas tokens over a 2 month period to support transactions going via Biconomy on Ethereum Network.

Minting will also be dependent on when we think it’s affordable to mint gas tokens and when the number of transactions increases.

What’s Next?

Biconomy is laser-focused on building the first chain agnostic optimized transaction highway.

Our support of the gas token marks the second out of three approaches we have to help reduce gas prices on Ethereum.

Additional explorations in our roadmap include the research we have made showing how high gas fees paid for some priority transactions can possess potential security risks on Ethereum for front running, also known as miner extractable value (MEV).

We are very excited and head down to release our next module called “Bunch” that can further optimise the transactions via transaction batching.

We are big fans of some of the layer 2 solutions such as Matic, optimism, xDai but moving assets on layer 2 give birth to a plethora of other problems. While we are huge fans of Layer 2 and as a result have already ensured Biconomy is compatible with xDai and Matic Network, we believe it is important to solve the gas problem on layer 1 and our results clearly demonstrate that up to 30–40% of gas fees can be saved via transaction batching. Thus with all the measures and approaches, we are taking, Biconomy can save up to 50% of gas fees going forward.

About Biconomy:

At Biconomy, our mission is to make next-generation technologies simple to use. We are building a smart relayer infrastructure network for blockchain transactions that reduces the friction between applications built on the blockchain and the end-users. Biconomy’s relayer network comprises a suite of SDKs and APIs that simplify the DApp development process for developers as well as abstracting many of the blockchain complexities, vastly enhancing the end-user experience for DApps and wallets.

Website: https://biconomy.io

Twitter: https://twitter.com/biconomy

Telegram: https://t.me/biconomy

Discord: https://discord.gg/X2EGFB

--

--