0%
Overview page background
HomeOverviewsInfra
What are Gas Optimized Transactions?

What are Gas Optimized Transactions?

Alchemy headshot

Written by Alchemy

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on 2023-03-073 min read

Gas Optimized Transactions are a powerful solution for users sending blockchain transactions, particularly those with a high volume of transactions going through a single address. 

A common and painful workflow for these users is running into a large backup of unmined transactions, invariably caused by a single transaction with a gas value that is set too low. A backlog of unmined transactions are more likely to happen when there is gas price volatility, caused by network congestion. 

In this article, we’ll cover: 

  • The transaction lifecycle 

  • The problem of gas price volatility

  • Gas Optimized Transactions

  • How Gas Optimized Transactions solve gas volatility problems 

  • How Gas Optimized and Reinforced Transactions work together 

  • How to start using Gas Optimized Transactions  

  • Blockchains that support Gas Optimized Transactions 

What is the transaction lifecycle? 

The transaction lifecycle happens in four sequential stages:

  1. Create - you decide to send a transaction at a specific gas price

  2. Simulate - you preview how your transaction will behave once it is sent

  3. Send - you send your transaction to get executed on chain

  4. Monitor - you track notifications to ensure your transaction is successful

Alchemy Transact is a series of products for faster, cheaper, and safer transactions, offering improvements throughout the entire web3 transaction lifecycle.  

Alchemy’s Gas Optimized Transactions is a tool to improve the “Create” phase of the web3 transaction lifecycle, giving users access to a smart gas optimization system that effectively minimizes gas spend while reducing risk of failed transactions that create a negative cascade effect.

Why is gas price volatility a problem when sending blockchain transactions? 

Developers and users spend more than necessary on blockchain transaction requests. Reasons for this include incorrect gas price estimation and network congestion.

1. Incorrect or inaccurate gas price estimation

EIP-1559 caps the amount the base fee can move, block to block, at 12.5%. It optionally gives users the ability to define a “max fee” field, denoting the maximum price (base fee + priority fee) they’re willing to pay to get a transaction mined.  

While the base fee’s movement is capped, the priority fee is arbitrary. This means a user could send what should have been a reasonably priced transaction, but the required block fees balloon, and their transaction gets stuck in mempool purgatory. This user would have to either resubmit their transaction or wait until the fees drop (but by then, their transaction could have been purged from the mempool). 

This stuck transaction then causes a cascade effect, creating a back up of unmined transactions and long delays in transaction processing times. This is particularly problematic for teams sending a large volume of transactions. 

2. Network congestion

The cost of executing a transaction is determined by the current gas price on the network. During periods of high network congestion, the gas price can rise dramatically and cause transactions to get stuck.

What are Gas Optimized Transactions? 

Gas Optimized Transactions is a collection of API endpoints that provide a mechanism to optimize gas values, while ensuring that web3 transactions are successfully mined on chain. 

When submitting a transaction to be mined on chain, the typical workflow is to send a single transaction, with a single gas value, representing the amount of gas you’re willing to pay for that transaction to be mined. 

Gas Optimized Transactions allow developers to set a wide range of gas values for a single transaction, removing the need to accurately estimate a single gas value. 

With Gas Optimized Transactions, instead of sending a single gas value, users send multiple versions of the same transaction with different gas values, all on the same nonce. 

The system will then select the appropriate transaction for the current network conditions, increasing to higher gas levels as needed to get a transaction mined. 

Gas Optimized Transactions help to ensure:

  • Transactions are successfully mined, while guaranteeing the cheapest gas price

  • Long backups of transactions are avoided

*Backups are invariably caused by one transaction with too low of a gas price getting stuck in the mempool.

How do Gas Optimized Transactions solve gas price volatility? 

Instead of sending a single transaction directly to a node, developers will be able to send Alchemy a list of signed transactions via the alchemy_sendGasOptimizedTransaction endpoint. 

In the background, Alchemy will submit the transaction with multiple gas levels, defaulting to ensure that the transaction with the lowest possible gas value will be successfully mined. Ultimately, Gas Optimized Transactions mean that developers can try a wide range of gas values for a single transaction.

Developers concerned about reliable transaction throughput speed, like the developers of The Smurfs' Game, can improve mined transaction guarantees by using Gas Optimized Transactions, even during periods of high network congestion. 

How do Gas Optimized and Reinforced Transactions work together?

To access Gas Optimized Transactions, you will have to enable Reinforced Transactions on your app. Reinforced Transactions require zero code changes and ensure your transactions get on-chain 7.9x faster, with 100% reliability. 

This requirement is the mechanism to ensure that Gas Optimized Transactions are implicitly Reinforced, thereby with higher reliability. 

How to start using Gas Optimized Transactions

Gas Optimized Transactions are still in beta. If you’d like early access to this product, please fill out this form. Solve the headache of optimal gas values when creating transactions and leave the hard work to Alchemy.

What blockchains support Gas Optimized Transactions?

Gas Optimized Transactions are currently supported on the following blockchain networks:

  • Ethereum

  • Polygon

  • Optimism

  • Arbitrum

Overview cards background graphic
Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key