Key terms and concepts
Gas
Gas is a unit of measurement for the work done to execute a transaction. The amount of gas depends on the complexity of the transaction.Gas price
The gas price is the amount of SEI paid per unit of gas that a transaction uses. You set the gas price, and it is used to calculate the transaction fee.Gas limit
The gas limit is the maximum amount of gas that you want the transaction to use. If the gas limit is too low, the node that executes the transaction runs out of gas. The transaction then fails, and it uses up the entire gas limit.Fee
Fee = Gas Price * Gas Used.
The gas limit caps the maximum possible charge at Gas Price * Gas Limit. On
Sei, excess gas (the gas limit beyond the actual gas used) may not be refunded
in full or in part. Because of this, avoid gas limits far above what a
transaction needs. For details, see
Sei EVM vs Ethereum.
To estimate fees on Sei, query the network directly with the standard EVM
JSON-RPC methods eth_gasPrice, eth_maxPriorityFeePerGas, and
eth_feeHistory. These methods return real-time gas pricing from the chain, so
you do not need a third-party service. For examples, see
Estimating gas prices below.
Maximum gas
The maximum gas limit for a transaction prevents complex transactions from using excessive resources. You can find the maximum gas limits for each chain in the Sei chain registry. You can also query the/consensus_params endpoint of the RPC node (for example,
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 the chain registry lists them.Max bytes
Each transaction has a maximum size in bytes, which is set per chain. You can query this limit directly on the RPC node with the/consensus_params endpoint.
Max gas for queries
Because queries also use gas, there is a maximum gas limit for queries. This limit is specific to each RPC. To find it, check with your RPC provider.Sending gas in transactions
When you submit a transaction for broadcast, you specify the gas price and the gas limit to create the fee.Using seid
With seid, the --fees flag sets the fee. You can set the gas limit with the
--gas flag and the gas price with the --gas-prices flag.
Using EVM (wagmi)
Optimizing gas prices for smart contracts
To optimize gas prices, follow efficient coding practices for smart contracts:- Minimize storage operations.
- Use fixed-size data structures where possible.
- Avoid unnecessary computations.
Estimating gas prices
You can read real-time gas pricing directly from the network, without a third-party service. Sei’s EVM RPC exposes the standard Ethereum JSON-RPC methods for gas estimation:eth_gasPrice: Returns the current recommended gas price for legacy transactions.eth_maxPriorityFeePerGas: Returns the suggested priority fee (tip) for EIP-1559 transactions.eth_feeHistory: Returns recent base fees and priority-fee percentiles. It helps you build custom fee strategies.