Gas
Gas is the unit that measures the computational workload required to execute transactions or contracts on the ENI network.
Key Terms and Concepts
Gas
Gas is a measure of the amount of work required to execute a transaction, and its value varies according to the complexity of the transaction being executed.
Gas Price
Gas Price refers to the amount of $ENI a user is willing to pay per unit of gas.
Users can set the gas price to influence transaction fees.
Gas Limit
Gas limit is the maximum amount of gas a user wants to use for a transaction. If the gas limit is set too low, a node attempting to execute the transaction will run out of gas, fail to complete the transaction, and consume the entire specified gas limit.
Fees
Fees = Gas Price * Gas Limit.
Maximum Gas
The maximum gas limit for transactions ensures that complex transactions do not consume excessive resources. You can check the ENI registry or query an RPC node using /consensus_params
(i.e., https://rpc.eniac.network/consensus_params) to find the maximum gas limit for each chain.
Minimum Gas Price
ENI enforces a minimum gas price to prevent junk transactions. These prices are set by chain and detailed in the chain registry.
Maximum Byte Size
Each transaction has a maximum byte limit, defined by each chain. This limit can be retrieved by querying the /consensus_params
endpoint of an RPC node.
Maximum Gas Limit for Queries
Since queries also consume gas, they have a maximum gas limit. This limit is specific to each RPC provider, so check with your provider to determine the maximum gas limit for your query.
Sending Gas in Transactions
When submitting a transaction for broadcast, the user needs to specify the gas price and the gas limit to determine the fee.
Using enid
When using enid, fees are set via the --fees
flag, and gas limits and gas prices can be set via the --gas
and --gas-prices
flags, respectively.
Using CosmJS
In any CosmJS transaction, the gas fee must be specified using the StdFee
object.
Using EVM (wagmi)
Optimizing Gas Prices for Smart Contracts
Best Practices for Efficient Gas Usage:
Minimize storage operations: Storage is expensive in terms of gas.
Use fixed-size data structures: They are more gas-efficient.
Avoid unnecessary computations: Streamline your smart contract logic.
Optimizing gas usage ensures lower costs and faster execution for smart contracts on the ENI network.
Last updated