Gas fees are the costs associated with initiating a transaction on a given blockchain, allowing network validators to perform the requested function. 

Gas fees can fluctuate due to network congestion, the type of transaction you request, and the priority placed on your request. You can accelerate a transaction by paying additional gas fees.  

Each blockchain has its own native asset required to pay these fees. When interacting with the blockchain, you’ll need to account for the amount of this native asset required for the requested transaction.

You can estimate transaction fees and contract execution with Circle’s Programmable Wallets APIs. 

Video Tutorial: Estimating Gas Fees for Transactions

Watch this video to learn about gas fees, also known as transaction fees. In the video, you will learn the importance of gas fees, understand how to estimate fees for a transfer transaction using an API and send USDC to other wallets using the estimates.


Programmable Wallets gas fee configurations

When initiating a request via Circle’s Programmable Wallets APIs that require gas fees, you have two options for configuring your fee tolerance: fee levels and gas limits

Fee levels provide a simple way to configure your gas tolerance. Depending on your choice, the speed in which your transaction completes compared to the expected blockchain confirmation timing may vary. 

You can choose between three tolerance levels:

  1. low - a low-priority transaction, expected to take longer than the average amount of time to complete, with lower fees
  2. medium - a medium-priority transaction, expected to take the average amount of time to complete, with average fees
  3. high - a high-priority transaction, expected to take less than the average amount of time to complete, with higher fees

Gas limits allow for a more advanced configuration of your gas tolerance. Setting gas limit requires the following parameters, which are all designated in wei: 

  1. gasLimit - the base amount of gas required to process the requested transaction
  2. priorityFee - an additional “tip” that can be added to the validator to accelerate the requested transaction
  3. maxFee - maximum fee that can be used for the requested transaction, if the fee is greater, the transaction will be failed. Note that Solana has no concept of a max fee.

Differences in gas fee specification

While EVM chains and Solana support fee levels, you can also assign your own gas fee. The process differs based on the blockchain and protocols supported.

EVM Chains without EIP-1559 Support

When creating a transfer transaction, you must specify gasPrice, which affects how quickly miners may process your transaction, and gasLimit, which protects you from consuming more resources than desired. The total fee you agree to pay is gas price * gas limit, but you only pay for the actual gas used.

  • Gas limit: Maximum computational work you agree to consume for executing a transaction or contract function.
  • Gas price: Amount of native token you're willing to pay per unit of computational work. This encourages miners to include your transaction in a block.

EVM Chains With EIP-1559 Support

When creating a transfer transaction, you must specify gasLimit, maxFee, and priorityFee. Your actual fee will be (base fee + priority fee) * gas used . Note that you do not need to specify the base fee in your transaction because it is automatically determined and adjusted by the network based on its current congestion level.

  • Base fee: Fee set by the network based on congestion levels. It is burned with a transaction, which means it is removed from circulation.
  • Priority fee: Additional fee paid to miners that expedites your transaction.
  • Max fee: Maximum price you're willing to pay per unit of gas for the transaction. This protects against paying excessive prices when the base fee rises unexpectedly.

Solana

The gas fee mechanism is similar to EIP-1559, where you can specify the priority fee to incentivize miners to include your transaction in a block. However, there's no max fee concept in Solana, and the gasLimit is optional as Solana defaults to a gas limit of 200,000 micro-lamport (10^-15 SOL).