Gas Fees in gno.land
This document explains how gas works in the gno.land ecosystem, including gas pricing, estimation, and optimization.
What is Gas?
Gas is a measure of computational and storage resources required to execute operations on the blockchain. Every transaction on gno.land consumes gas based on:
- The complexity of the operation being performed
- The amount of data being stored
- The current network conditions
Gas serves several important purposes:
- Prevents spam and denial-of-service attacks
- Allocates network resources fairly among users
- Compensates validators for the computational resources they provide
Gas Parameters
When submitting transactions to gno.land, you need to specify two gas-related parameters:
Gas Wanted
--gas-wanted specifies the maximum amount of gas your transaction is allowed
to consume. If your transaction requires more gas than this limit, it will fail
with an "out of gas" error, but will still consume the gas up to that point.
Gas Fee
--gas-fee specifies how much you're willing to pay per unit of gas. This is
typically expressed in ugnot (micro-GNOT). For example, 1000000ugnot means
you're willing to pay 1 GNOT per unit of gas.
The total maximum fee you might pay is calculated as:
Maximum Fee = Gas Wanted × Gas Fee
You will be charged the gas fee you specified.
Calculating Your Gas Fee
Your --gas-fee must meet or exceed the network gas price for your transaction
to be accepted.
The easiest way is to use -simulate only, which automatically queries the
current gas price and calculates the recommended fee (with a 5% buffer).
Gas Price
The network dynamically adjusts the minimum required gas price after each block based on demand. This ensures the network responds to congestion by increasing prices when usage is high and decreasing them when usage is low.
How Gas Price Works
The gas price is returned as a GasPrice object with two fields:
gas- the gas units (e.g., 1000)price- the price for those gas units (e.g., "100ugnot")
Together, these represent a rate. For example, {gas: 1000, price: "100ugnot"}
means the minimum rate is 100 ugnot per 1000 gas units, which simplifies to
0.1 ugnot per gas unit.
To calculate the minimum fee manually:
- Query the current gas price
- Calculate the rate:
price / gas - Multiply by your
--gas-wanted
Example:
# Query returns: {gas: 1000, price: "100ugnot"}
# Rate = 100 ÷ 1000 = 0.1 ugnot/gas
# If you want --gas-wanted 2000000:
# Minimum fee = 2,000,000 × 0.1 = 200,000 ugnot
# So set: --gas-fee 200000ugnot (or higher)
Querying Gas Price
You can query the current network gas price using:
gnokey query auth/gasprice -remote https://rpc.gno.land:443
This returns the gas price calculated from the most recently completed block, which is the minimum rate currently required for new transactions.
For more details, see auth/gasprice.
How the Network Adjusts Gas Price
The network automatically adjusts the gas price after each block based on demand:
- Low demand: Price decreases (but never below 1 ugnot/1000 gas)
- High demand: Price increases
The network targets 70% utilization of the maximum block gas limit (3B gas) by default. When blocks exceed this target, prices rise. When blocks fall below it, prices drop. Changes are gradual to avoid sudden price spikes.
Note: Individual validators can also set their own minimum gas price through the
min_gas_prices configuration parameter in their config.toml file. Different validators may have different minimums.
Typical Gas Values
Here are some recommended gas values for common operations:
| Operation | Recommended Gas Wanted | Typical Gas Fee |
|---|---|---|
| Simple transfer | 100,000 | 1000000ugnot |
| Calling a realm function | 2,000,000 | 1000000ugnot |
| Deploying a small package | 5,000,000 | 1000000ugnot |
| Deploying a complex realm | 10,000,000+ | 1000000ugnot |
These values may vary based on network conditions and the specific implementation of your code.
Gas Estimation
Use the -simulate only flag to estimate gas usage and the recommended fee
without executing on-chain or incrementing the account sequence number:
gnokey maketx addpkg \
-pkgdir "./hello" \
-pkgpath gno.land/r/hello \
-gas-wanted 2000000 \
-gas-fee 1000000ugnot \
-remote https://rpc.gno.land:443 \
-broadcast \
-chainid staging \
-simulate only \
YOUR_KEY_NAME
Output:
GAS WANTED: 2000000
GAS USED: 268994
INFO: estimated gas usage: 268994, gas fee: 282ugnot, current gas price: 1ugnot/1000gas
Use the estimated gas usage and gas fee values as your -gas-wanted and -gas-fee
for the actual transaction.
Gas Optimization Tips
To minimize gas costs, consider these optimization strategies:
- Minimize on-chain storage: Storage writes are the most expensive operations (2,000 gas flat + 30 gas/byte for writes vs. 1,000 gas flat + 3 gas/byte for reads). Only store essential data on-chain.
- Batch operations: Combine multiple operations into a single transaction when possible, reducing the overhead of per-transaction costs (signature verification, etc.).
- Use efficient data structures: Well-optimized code consumes less gas. Avoid unnecessary iterations — each iterator step costs gas.
- Precompute values off-chain: Do as much computation as possible before submitting to the blockchain.
- Test locally first: Use
gnodevto test and optimize your code before deploying to a network.
Common Errors
Insufficient fees: insufficient fees; got: 50000ugnot required: 200000ugnot
- Your
--gas-feeis too low. Increase it to meet the minimum required.
Out of gas: out of gas in location: ... wanted: 100000, used: 150000
- Your
--gas-wantedis too low. Use-simulate onlyto estimate needed gas, then increase. - ⚠️ You're still charged for failed transactions! Fees are deducted before execution, so even if your transaction runs out of gas, you pay for the gas consumed up to the limit.
Note: By default,
gnokey maketx -broadcastuses-simulate test, which simulates the transaction before submitting it. If the simulation fails (e.g., out of gas), the transaction won't be submitted and you won't be charged. However, a transaction that passes simulation can still fail on-chain, in which case you will be charged.