gas
How gas pricing works on Monad and how it differs from Ethereum. Monad charges gas based on gas_limit (not gas used), has a different base fee controller, and…
от therealharpaljadeja★ 15 звёзд на GitHub
Установить gas в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Monad's gas pricing is EIP-1559 compatible but differs from Ethereum in critical ways. If you're building apps that submit transactions, estimate gas, or display gas costs, you need to understand these differences.
Key Difference: Monad Charges on Gas Limit, Not Gas Used
On Ethereum, users pay for the gas actually consumed by their transaction. On Monad, users pay based on the gas limit they set:
gas_paid = gas_limit * price_per_gas
This exists because Monad uses asynchronous execution — block leaders build blocks before executing them, so actual gas consumption isn't known at inclusion time. This prevents DOS attacks where transactions claim cheap gas but consume expensive computation.
What this means for developers:
- Setting an unnecessarily high gas limit directly costs users more MON.
- Always set tight, accurate gas limits especially for transactions with known fixed costs.
- For native MON transfers, the gas cost is always 21,000. Hardcode this instead of relying on
eth_estimateGas.
EIP-1559 Transaction Pricing
Monad uses type 2 (EIP-1559) transactions:
price_per_gas = min(base_price_per_gas + priority_price_per_gas, max_price_per_gas)
Users specify two values when signing:
priority_price_per_gas— tip for transaction prioritization within a blockmax_price_per_gas— safety cap on total gas price
The network controls base_price_per_gas, which is the same for all transactions in a block.
Block and Transaction Limits
| Parameter | Value |
|---|---|
| Block gas limit | 200M gas |
| Transaction gas limit | 30M gas |
| Minimum base fee | 100 MON-gwei (100 x 10^-9 MON) |
These are significantly higher than Ethereum's 30M block gas limit, which means Monad blocks can fit more transactions.
Base Fee Controller
Monad's base fee controller is different from Ethereum's. It increases more slowly and decreases more quickly to prevent blockspace underutilization from overpricing.
Controller parameters:
- max_step_size = 1/28
- target = 160M gas (80% of block capacity)
- beta = 0.96
- epsilon = 160M
The base fee updates each block using an exponential adjustment based on how full the block was relative to the target. The formula uses exponential smoothing (beta = 0.96) to track historical variance in block fullness, producing smoother fee transitions than Ethereum's simpler mechanism.
In practice, this means gas prices on Monad are more stable and recover faster after spikes.
Transaction Ordering
The default Monad client orders transactions using a Priority Gas Auction, transactions are sorted by descending total gas price (base fee + priority fee).
Developer Guidelines
Always Set Explicit Gas Limits for Known Costs
For operations with fixed gas costs, set the gas limit explicitly before submitting to wallets:
// Good: explicit gas limit for a native transfer
const tx = {
to: recipient,
value: parseEther("1.0"),
gasLimit: 21000n,
};
This is important because some wallets (like MetaMask) use eth_estimateGas to determine the gas limit. If that call reverts (e.g., the contract call would fail), the wallet may fall back to a very high gas limit. On Monad, the user would then pay for that entire inflated limit since gas is charged on the limit, not on actual usage.
Gas Estimation in Frontend Code
When using viem or wagmi to estimate gas, remember that the estimate is what users will actually pay not a lower bound. Add only a small buffer if needed:
// If you must estimate, keep the buffer small
const estimate = await publicClient.estimateGas({ ... });
const gasLimit = estimate + (estimate / 10n); // 10% buffer at most
Displaying Gas Costs to Users
When showing gas costs in your UI, calculate from the gas limit (not "gas used" from receipts on other chains):
const gasCost = gasLimit * gasPrice;
Smart Contract Considerations
- Monad's 30M transaction gas limit is the same as Ethereum's block gas limit, so individual transactions can be very large.
- Optimize your contracts to use less gas on Monad this directly saves users money since they pay for the limit, and tighter estimates mean tighter limits.
- If your contract has functions with predictable gas costs, document them so frontends can set explicit limits.
Opcode Pricing Differences
Monad adjusts a few opcode prices upward rather than discounting everything. This achieves the same relative effect with minimal disruption. The changes reflect different resource scarcity in Monad's high-performance architecture, particularly for disk-based state operations.
Cold State Access is Much More Expensive
| Operation | Ethereum | Monad | Increase |
|---|---|---|---|
| Account access (cold) | 2,600 gas | 10,100 gas | +7,500 |
| Storage access (cold) | 2,100 gas | 8,100 gas | +6,000 |
| Account access (warm) | 100 gas | 100 gas | unchanged |
| Stora |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- SKILL.zh.md
FAQ
Что делает скилл gas?
How gas pricing works on Monad and how it differs from Ethereum. Monad charges gas based on gas_limit (not gas used), has a different base fee controller, and different block gas limits. Fetch this skill whenever writing smart contracts, setting gas limits, estimating gas, or building any transaction-related UI on Monad incorrect gas handling can cost users real money.
Как установить скилл gas?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gas запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…