Gas on Sei
Gas refers to the unit of measurement representing the work done to execute a transaction on the blockchain. The amount of gas used varies based on the complexity of the transaction.
When submitting a TX to be broadcast, users specify the gas price and the gas limit (sometimes shortened to ‘gas’).
The gas price refers to the amount of sei the user pays per gas used. In a proof-of-stake chain like Sei, increasing the gas price provides a greater incentive for validators to execute your transaction, ensuring shorter time to finality when the chain is congested.
The gas limit is 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.
The gas limit is multiplied by the gas price to create the ‘fee’. In the event that the validator successfully executes your transaction, the fee is paid in full to the validator (regardless of how much gas was actually used).
Sei has minimum gas prices per chain, which can be found in the official chain registry (opens in a new tab).
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 (opens in a new tab).
Minimum Gas Prices
Sei enforces minimum gas prices to prevent spam transactions. These prices are set per chain and are detailed in the chain registry (opens in a new tab).
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.
Sending Gas in Transactions
Using seid
seid tx bank send <from_address> <to_address> <amount> --gas <gas_limit> --gas-prices <gas_price> --fees <fee>
Using CosmJS
const fee = {
amount: [{ denom: "usei", amount: "5000" }],
gas: "200000",
};
const result = await client.signAndBroadcast(address, [msg], fee, memo);
Using EVM (wagmi)
import { sendTransaction } from 'wagmi/actions'
sendTransaction({
request: {
to: '0xRecipientAddress',
value: '1000000000000000000', // 1 ETH
gasPrice: '20000000000', // 20 Gwei
gasLimit: '21000',
},
})
Minimum Gas Price Per Chain
• Pacific-1 (Mainnet): 0.025usei • Atlantic-2 (Testnet): 0.01usei • Arctic-1 (Devnet): 0.005usei
For more details, refer to the chain registry.