This site requires Javascript to be enabled.

Gas and fees

The fee system in Archway plays a pivotal role not only in resource management and the incentivization of validators, developers, and delegators, but also in assuring security, protecting against spam, and preserving the healthy operations of the network. A crucial element in fee computation is gas, which is a unit that measures the amount of computational effort required to perform specific operations. Each transaction in Archway requires a certain amount of gas for execution, the cost of which is usually covered by the account initiating the transaction.

Gas limit

Think of the gas limit as the amount of fuel needed to reach your destination, which in this case is the successful completion of a transaction. If the user sets the gas limit too low, the transaction might fail due to insufficient gas for completion. Conversely, setting the gas limit excessively high could lead to resource wastage, as any unused gas is not refunded.

Instead of manually setting the gas limit, a simulation of the transaction is usually executed to get an estimate of the gas limit required to execute a transaction. The gas estimation process may not always be perfect due to the complexity and variability of transactions, especially in smart contract operations. Therefore, a gas adjustment multiplier is applied as a buffer to increase the likelihood of successful transaction execution. For example, a gas adjustment value of 1.5 would increase the initially estimated gas by 50%.

Gas price

The gas price in Archway determines the cost of each unit of computational resource consumed by a transaction. It represents the amount of the network's native token that is required to execute one unit of gas. Gas prices can vary based on network conditions, such as congestion or market demand.

To prevent validators from accepting transactions with low fees that might lead to spamming the network and additional security issues, a Minimum Price of Gas system was put in place. Consequently, transactions will fail if the set gas price falls beneath this threshold. Therefore, it's not ideal to set the gas price manually but instead utilize the endpoint or CLI command that returns the minimum price of gas and then use this value as the gas price. This falls under the estimate fees feature of the rewards module.

You can pull in the minimum price of gas via the following API endpoint You can find the details of this endpoint here.

Commands executed via the archwayd CLI can pull in the minimum price of gas by accessing the estimate-fees command:



$(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)')

Try it:

archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)'
Try It

For example, to send tokens from one wallet to another, the following could be done:



archwayd tx bank send archway1e2ntjy39x4gqn3tqu09ztjpjp4hf9q6u47w30u archway19vprdtfha0xsls0qlwqj2sas32nqqtf4ee9z58 1000000000000000000000aarch --chain-id archway-1  --from my-wallet --node --gas auto --gas-adjustment 1.4 --gas-prices $(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)')

Merely configuring the --gas-prices isn't always the optimal choice, given that the default --gas value of 200000 and default --gas-adjustment value of 1 may not suffice for every transaction, such as when storing a contract. Therefore, it's suggested to set --gas to auto and employ a --gas-adjustment of 1.3 or higher, as demonstrated in the preceding example.

Fee calculation

The total fee paid is determined by the equation fee = gas limit * gas price. The Gas limit is the total amount of computational work needed to execute the transaction, and gas price is the amount of tokens a user is willing to pay per unit of gas.

For example, if a transaction has a gas limit of 1,000 units and a gas price of 0.0001 ARCH per unit, the total fee would be 0.1 ARCH (1,000 units * 0.0001 ARCH/unit). Users need to ensure they have sufficient funds in their account to cover the transaction fee. If the account balance is insufficient, the transaction will be rejected.

Our Minimum Consensus Fee implementation prevents fees from being below a certain value. This protects the economic model of Archway by preventing the incentive to send low or no fee transactions in order to gain higher dapp rewards.

For transactions executed from a frontend dapp using Javascript, the arch3.js package is ideal for automatically calculating the right fee for executing a transaction. You can find more information here.