Key Terms and Concepts
Gas
A unit of measurement representing the work done to execute a transaction, “gas” varies based on the complexity of the transaction being executed.Gas Price
The amount of Sei paid per unit of gas used when executing a transaction. The gas price is set by the user and is used to calculate the fee for the transaction.Gas Limit
The maximum amount of gas the user wants the transaction to use. If the gas limit is set too low, the node attempting to run the transaction will run out of gas and fail to complete the transaction, using up the entire max gas without completing the transaction.Fee
Fee = Gas Price * Gas Used.
The gas limit caps the maximum possible charge at Gas Price * Gas Limit. Note
that on Sei, excess gas (the gas limit beyond the actual gas used) may not be
refunded in full or in part, so avoid setting gas limits far above what a
transaction actually needs. See
Sei EVM vs Ethereum for details.
To help developers and users estimate fees on Sei, please reference
Sei Gas and the associated
APIs provided by
Blocknative. Their estimates are based on real-time SEI data and advanced ML
modeling to accurately and consistently estimate SEI transaction fees.
Maximum Gas
The maximum gas limit for a transaction ensures that complex transactions do not consume excessive resources. You can find the maximum gas limits for each chain in the Sei chain registry or by querying the/consensus_params of the RPC node itself (ex.
https://rpc.sei-apis.com/consensus_params).
Minimum Gas Price
Sei enforces minimum gas prices to prevent spam transactions. These prices are set per chain and are detailed in the chain registry.Max Bytes
Each transaction has a maximum size in bytes, which is set per chain. This limit can be queried on the RPC node directly using the/consensus_params endpoint.
Max Gas for Queries
Since queries also use gas, there is a maximum gas limit for queries. This limit is RPC specific, so check with your RPC provider to determine the maximum gas limit for queries.Sending Gas in Transactions
When submitting a TX to be broadcast, users specify the gas price and the gas limit to create the fee.Using seid
When using seid, the fee is set using the --fees flag, gas limit and gas
price can be set with --gas and --gas-prices flags respectively.
Using EVM (wagmi)
Optimizing Gas Prices for Smart Contracts
Optimizing gas prices involves efficient smart contract coding practices:- Minimize storage operations.
- Use fixed-size data structures where possible.
- Avoid unnecessary computations.