Skip to main content

Gas Fees on ZIGChain

TL;DR: Every transaction on ZIGChain pays a small ZIGChain gas fee in ZIG. ZIGChain gas fees depend on gas units, your gas limit, and the gas price. Set gas price or total gas fees with a gas limit, not all three at once. Paying more does not change execution order in the mempool.

Overview

ZIGChain gas fees are the small upfront charge for each transaction. The fee limits resource use, reduces spam, and pays validators for their work.

The sender pays in $ZIG. The amount depends on gas units for the work and the gas price you attach. Fees are usually shown in uZIG, the smallest unit on ZIGChain. One uZIG equals 0.000001 ZIG. One million uZIG equals one ZIG.

ZIGChain gas fees follow the Cosmos SDK gas model. Wallets and CLIs let you set a gas limit and either a gas price or a total fee string.

The sections below use a fuel analogy for units, limits, and prices. They also explain when you still pay a fee if a transaction fails.

For chain context see ZIGChain - What and Why?. For accounts and signing sends see ZIGChain Accounts. For the native asset see The ZIG Token. For shared terms see ZIGChain Glossary.

Key Concepts

  • Gas units: Work the chain measures to run your messages. The node estimates units from the transaction content.
  • Gas limit: The maximum gas you allow for one run. Wallets often use auto so the limit tracks estimated units.
  • Gas price: The ZIG cost per gas unit. It moves with demand. Validators set min-gas-prices they accept.
  • Gas fee: What you pay in ZIG, often uZIG. It is typically round_up(gas limit times gas price) before signing.
  • Gas adjustment: A wallet factor that multiplies the estimated limit so execution does not run out of gas.
  • uZIG: The smallest ZIG unit on chain. One ZIG equals one million uZIG.

Core Components of Gas Fees

  • Gas Units are based on the computational effort or how much work will be required to execute the transaction's code. This is calculated on the server. A metaphor can be the fuel amount that your car uses to take you from one city to another.

  • Gas Limit is the maximum amount of gas a user is willing to spend on a transaction, set when creating the transaction in their wallet. It is normally set to auto, adjusting to match the required Gas Units. Think of it as setting a maximum fuel budget that you are willing to spend to go from one city to another.

  • Gas Price is the cost per unit of gas, determined by the network traffic and demand in each block. Similar to the price of fuel per litre.

  • Gas Fee is what the user pays, which is:

Formula:

Gas Fee = round_up(Gas Limit * Gas Price)

Following the metaphor, the Gas Fee is the Total Cost of fuel you will pay to go from one city to another.

Payment Options

When you set ZIGChain gas fees on a transaction, you choose how much gas the run may use and what you pay per unit.

Users must set a combination of two parameters:

  1. Gas Price or Gas Fees (one of them).
  2. Gas Limit as the maximum execution gas.

You can set either Gas Price and Gas Limit or Gas Fees and Gas Limit, but not all three simultaneously.

Note: It is common to set a Gas Adjustment Rate to ensure that the Gas Limit is sufficient to execute the transaction. The Gas Adjustment Rate is a factor that multiplies the Gas Limit to ensure successful execution.

It is important to set the fee correctly. The entire Gas Fee provided will be consumed before executing the transaction.

ZIGChain gas fees are not refunded when a run uses compute. The validator must execute the transaction regardless of the result. The Gas Fee will be consumed in all the following scenarios:

  1. If the transaction is successful, the Gas Fee will be consumed.
  2. If the transaction fails, the Gas Fee will be consumed.
  3. If the transaction fails because the Gas Fee is insufficient, the Gas Fee will be consumed.
  4. If the fee provided is more than required, the remaining Gas Fee will still be consumed.

Common Reasons for Failed Transactions

There are two cases in which the transaction will fail:

  1. If the Gas Price provided was less than min-gas-prices established by the validators, the transaction could be delayed or failed.
  2. If the Gas Limit is insufficient, the transaction will fail, and any changes will be rolled back without refunding the Gas Fees.

Paying More Fees to Go Faster

In ZIGChain, paying a higher Gas Price will not make the transaction faster. The transaction will be executed in the order that it was received.

Higher ZIGChain gas fees do not buy a priority slot in the block. They can still help inclusion when your gas price clears validator minimums.

If your gas is above the minimum-gas-prices of all validators, more validators may include your transaction. That can feel faster than waiting with a price below some validators' floors.

Common Questions

How Do I Estimate Gas Fees Before Signing?

Simulate the transaction against current state to read gas units, then set your gas limit at or above that estimate. Pick gas price or total fees using the rules in Payment Options. Wallets often expose simulate in the send flow; CLI users can use the Cosmos SDK simulation APIs linked under References.

References