bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 13쪽
**dips below** 10 MON.
* *'Dips below'* means *'decrements **and** drops below'*.
* Transactions where the EOA's balance ends above or at 10 MON are fine.
* Transactions where the EOA's balance is unchanged or increases are fine.
* **Only** transactions that decrement the balance **and** result in a final balance
below 10 MON are reverted.
* Delegated EOAs cannot use the emptying exception described above.
For example, many sponsored gas workflows have users set up EIP-7702-delegated EOAs that
don't interact with MON at all (i.e. they start out empty, and only receive MON involuntarily).
Under a typical such workflow, a sponsor submits a transaction that calls into the EOA as
smart contract. This workflow works fine in Monad; it's fine for the EOA in question to
have a zero or very small balance.
The only case where a sponsored gas workflow will be blocked is if the EOA's balance is
(say) 6 MON, and the sponsored transaction calls code that tries to transfer (say) 1 MON out of the EOA.
### Transactions that are included but revert
Because of the Reserve Balance rules, you may see transactions *included* in the chain whose
execution *reverts*, such as transactions trying to transfer out more MON than are in the account
balance.
These transactions are still *valid* transactions that pay for gas, but the
*result* of these transactions is nothing except for gas being decremented from the sender.
They are included because at the time of consensus, the proposer cannot be sure that the account
isn't going to receive more MON from someone else, and the sender has the budget to pay for gas.
Ethereum includes many transactions whose execution reverts, so this is not a protocol difference.
However, in practice, Ethereum block builders may screen out transactions with insufficient balance
to process a transfer out, so this behavior may be different from what you're accustomed to seeing.
### Detecting a reserve balance dip
A contract can check at execution time whether its current execution has dipped into the reserve
balance by calling the
[reserve balance precompile](/developer-essentials/precompiles#reserve-balance-precompile)
at `0x1001`. It exposes a single method, `dippedIntoReserve()` (selector `0x3a61584e`, gas cost
`100`), which returns a `bool`. It is specified in [MIP-4](https://mips.monad.xyz/MIPs/MIP-4).
`dippedIntoReserve()` must be invoked via `CALL`. Invoking it via `STATICCALL` - or via
`DELEGATECALL` or `CALLCODE` - reverts. Although it reads state and returns a value, it is
intentionally not a `view` function, so that a Solidity call site compiles to `CALL` rather than
`STATICCALL`.
## Full specification
See the
[reserve balance spec](https://category-labs.github.io/category-research/monad-initial-spec-proposal.pdf)
for the formal set of Reserve Balance rules.
Algorithms 1 and 2 implement this check for consensus and execution, respectively.
Algorithm 3 implements the mechanism to detect the dipping into the reserve balance
(Algorithm 2 uses Algorithm 3 to revert transactions that dip).
Algorithm 4 specifies the criteria for emptying transactions:
* The sender account must be undelegated in the prior `k` blocks. This is checked
statically by verifying the account was undelegated in a known state in the past
`k` blocks, and there have been no delegation or undelegation requests in the last
`k` blocks (this can be inspected statically).
* There must not be another transaction from the same sender in the prior k blocks.
Here is a quick summary of the reserve balance rules at consensus time:
#### If the account is not delegated and there are no inflight transactions
If the account is not delegated, and there are no previous inflight transactions, then consensus
checks that the gas fee for this transaction is less than the balance from the lagged state.
$$
\text{gas\_fees}(\text{tx}) \leq \text{balance}
$$
#### If the account is not delegated and has one emptying inflight transaction
If the account is not delegated, and there is one previous inflight transaction, then
consensus has to take into account the inflight transaction's total MON expenditures
(including `value`):
$$
\text{let adjusted\_balance} = \text{balance} - (\text{first\_tx.value} + \text{gas\_fees}(\text{first\_tx}))
$$
$$
\text{let } \text{reserve} = \min(\text{user\_reserve\_balance}(t.\text{sender}), \text{adjusted\_balance}) \quad
$$
A new transaction can only be included if the sum of all inflight transactions' gas fees
(excluding the first one) is less than the reserve:
$$
\sum_{tx \in I[1:]} \text{gas\_fees}(tx) \leq \text{reserve}
$$
#### All other cases
The reserve is equal to minimum of systemwide reserve balance (`10 MON`) or the
account's balance at block `n - k`:
$$
\text{reserve} = \min(\text{user\_reserve\_balance}(t.\text{sender}), \text{balance})
$$
A new transaction can only be included if the sum of all inflight transactions' gas fees
is less than the reserve:
$$
\sum_{tx \in I} \text{gas\_fees}(tx) \leq \text{reserve}
$$
## Adjusting the reserve balance
The reserve balance is currently the same for every account (`10 MON`).
In a future version, the protocol could allow users, through a stateful precompile, to
customize their reserve balance.
## Coq proofs
The safety of the reserve balance specification has been formally proved in Coq.
The full proofs documentation is available
[here](https://category-labs.github.io/category-research/formalverif/reserve-balance/monad.proofs.reservebal.html).
The consensus check is formalized in Coq as `consensusAcceptableTxs`. The predicate,
`consensusAcceptableTxs s ltx`, defines the criteria for the consensus module to accept
the list of transactions `ltx` on top of state `s`.
The proof shows that `consensusAcceptableTxs s ltx` implies that when the execution
module executes all the transactions in ltx one by one on top of s, none of them will
fail due to having insufficient balance to cover gas fees. The proof is by induction
on the list `ltx`: one can think of this as doing natural induction on the length of `ltx`.
The proof in the inductive step involves unfolding the definitions of the consensus
and execution checks and considering all the cases. In each case, the estimates of
effective reserve balance in consensus checks is shown to be conservative with respect
to what happens in execution.
## Additional examples
To test your understanding, here are some examples along with the expected outcome.
Each example is independent.
In the following examples, we use `start_block = 2`, meaning the initial balances
and reserves are after block 1. We also specify the reserve balance parameter for
each example, although it is a constant system wide parameter.
For each transaction, the expected result is indicated by a code:
* **2**: Successfully executed
* **1**: Included but reverted during execution (due to reserve balance dip)
* **0**: Excluded by consensus
### Example 1: Basic transaction inclusion
Initial state:
```
Alice: balance = 100, reserve = 10
Bob: balance = 5, reserve = 10
```
Transactions:
```
Block 2: [
Alice: send 1 MON, fee 0.05 — Expected: 2
Bob: send 2 MON, fee 0.05 — Expected: 2
]
```
Final balances:
```
Alice: 98.95
Bob: 2.95
```
### Example 2: Low reserve balance but high balance
Initial state:
```
Alice: balance = 100, reserve = 1
```
Transactions:
```
Block 2: [
Alice: send 3 MON, fee 2 — Expected: 2 (emptying transaction)
Alice: send 3 MON, fee 2 — Expected: 0 (excluded)
]
```
Final balance:
```
Alice: 95.0
```
### Example 3: Multi-block, low reserve but high balance
Initial state:
```
Alice: balance = 100, reserve = 1
```
Transactions:
```
Block 2: [
Alice: send 3 MON, fee 2 — Expected: 2
]
Block 5: [
Alice: send 3 MON, fee 2 — Expected: 2
]
```
Final balance:
```
Alice: 90.0
```
### Example 4: Comprehensive
Initial state:
```
Alice: balance = 100, reserve = 1
```
Transactions:
```
Block 2: [
Alice: send 99 MON, fee 0.1 — Expected: 2 (large emptying transaction)
]
Block 3: [
Alice: send 0.5 MON, fee 0.99 — Expected: 0 (excluded)
]
Block 4: [
Alice: send 0.8 MON, fee 0.1 — Expected: 1 (included but reverted)
]
Block 5: [
Alice: send 0 MON, fee 0.9 — Expected: 0 (excluded)
Alice: send 5 MON, fee 0.1 — Expected: 1 (included but reverted)
Alice: send 5 MON, fee 0.8 — Expected: 0 (excluded)
]
```
Final balance:
```
Alice: 0.70
```
### Example 5: Edge case — zero value transactions
Initial state:
```
Alice: balance = 2, reserve = 1
```
Transactions:
```
Block 2: [
Alice: send 0 MON, fee 0.5 — Expected: 2
Alice: send 0 MON, fee 0.6 — Expected: 2
Alice: send 0 MON, fee 0.5 — Expected: 0 (exceeds reserve)
]
```
Final balance:
```
Alice: 0.9
```
### Example 6: Reserve balance boundary
Initial state:
```
Alice: balance = 10, reserve = 2
```
Transactions:
```
Block 2: [
Alice: send 1 MON, fee 2 — Expected: 2 (matches reserve)
Alice: send 0 MON, fee 0.01 — Expected: 2
]
```
Final balance:
```
Alice: 6.99
```
### Example 7: Account delegated in the interim
Initial state:
```
Alice: balance = 15, reserve = 10
```
Transactions:
```
Block 1: []
Block 2: [
Alice is delegated
Bob on behalf of Alice: send 5 MON, fee 0 — Expected: 2 (executed)
Alice is undelegated
]
Block 3: [
Alice: send 3 MON, fee 0.1 — Expected: 1 (included but reverted)
]
Block 4: []
Block 5: [
Alice: send 0 MON, fee 8 - Expected: 2 (executed)
]
```
Final balance:
```
Alice: 1.9
```
**NOTE**: If execution would not have reverted transaction in `Block 3` (by checking delegation
status in prior `k` blocks), consensus would include transaction in `Block 5` which would later run
out of MON for the fee.
Also, consider `Block 2` is empty instead. Transaction in `Block 3` is then an emptying transaction,
which proceeds with execution, but transaction in `Block 5` is excluded as not having enough reserve
for fee.
### Example 8: Account receives MON before second inflight tx
Initial state:
```
Alice: balance = 15, reserve = 10
```
Transactions:
```
Block 1: []
Block 2: [
Alice: send 6 MON, fee 0.1 - Expected: 2 (executed, emptying tx)
]
Block 3: [
Alice receives 6 MON from a smart contract
Alice: send 7 MON, fee 0.1 — Expected: 1 (included but reverted, cannot be 2nd emptying so soon)
]
Block 4: []
Block 5: [
Alice: send 0 MON, fee 8 - Expected: 2 (executed)
]
```
Final balance:
```
Alice: 6.8
```
**NOTE**: If execution would not have reverted the 2nd transaction in `Block 3` (from Alice; by
checking existence of emptying transactions in prior `k` blocks), consensus would include
transaction in `Block 5` which would later run out of MON for the fee.
Also, consider `Block 2` is empty instead. Transaction in `Block 3` (from Alice) is then an emptying
transaction, which proceeds with execution, but transaction in `Block 5` is excluded as one
potentially not having enough reserve for fee - consensus doesn't see Alice being credited in
`Block 3`.
# Deployment Summary for Developers
Source: https://docs.monad.xyz/developer-essentials/summary
Deployment Summary for Developers
This page summarizes what you need to know when developing or deploying smart contracts for
Monad.
## Start with
* [Network Information](/developer-essentials/network-information) - for RPC & block explorer URLs, and canonical
contract deployments.
* [Differences between Monad and Ethereum](/developer-essentials/differences)
* [`protocols` repo](https://github.com/monad-crypto/protocols) (add yours!)
* [`token-list` repo](https://github.com/monad-crypto/token-list) (add yours!)
* [RPC API](/reference/json-rpc/) - an interactive reference
## Supported Tooling & Infra
Here are some of the most commonly-requested tools:
| Tool | Status | Notes |
| - | - | - |
| [Tenderly](https://dashboard.tenderly.co/explorer) | ✅ | |
| [Safe](https://app.safe.global) | ✅ | |
| [Monadscan](https://monadscan.com) (by Etherscan) | ✅ | |
| [MonadVision](https://monadvision.com) (by Blockvision) | ✅ | |
| [Foundry](https://getfoundry.sh) | ✅ | Use [Foundry v1.8+](/tooling-and-infra/toolkits/foundry) with the Monad execution network enabled |
| [Viem](https://github.com/wevm/viem) | ✅ | `viem >= 2.40.0` |
<br />
See [Tooling and Infra](/tooling-and-infra) for a complete list of what is supported,
including:
| Category |
| - |
| [AA Infra](/tooling-and-infra/wallet-infra/account-abstraction) |
| [Analytics](/tooling-and-infra/analytics) |
| [Block Explorers](/tooling-and-infra/block-explorers) |
| [Cross-Chain](/tooling-and-infra/cross-chain) |
| [Custody](/tooling-and-infra/custody) |
| [Embedded Wallets](/tooling-and-infra/wallet-infra/embedded-wallets) |
| [Indexers - Common Data](/tooling-and-infra/indexers/common-data) (e.g. token balances, transfers, trades) |
| [Indexing Frameworks (incl Subgraphs)](/tooling-and-infra/indexers/indexing-frameworks) |
| [Onramps](/tooling-and-infra/onramps) |
| [Oracles](/tooling-and-infra/oracles) |
| [RPC Providers](/tooling-and-infra/rpc-providers) |
## Accounts
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Address space</td>
<td>Same address space as Ethereum (last 20 bytes of ECDSA public key)</td>
</tr>
<tr>
<td>EIP-7702</td>
<td>Supported. See [EIP-7702 reference](/developer-essentials/eip-7702)</td>
</tr>
</tbody>
</table>
</div>
## Smart Contracts
For deployment and verification guides, see:
* [Deploy a Contract](/guides/deploy-smart-contract)
* [Verify a Contract](/guides/verify-smart-contract)
* [MonadVision verification guide](https://docs.blockvision.org/reference/verify-smart-contract-on-monad-explorer)
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Opcodes</td>
<td>All [opcodes](https://www.evm.codes/) as of the Fusaka fork are supported.</td>
</tr>
<tr>
<td>Precompiles</td>
<td>All Ethereum precompiles as of the Fusaka fork (`0x01` to `0x11`), plus P256 signature verification at `0x0100` ([EIP-7951](https://eips.ethereum.org/EIPS/eip-7951)) and the staking precompile at `0x1000`. See [Precompiles](/developer-essentials/precompiles)</td>
</tr>
<tr>
<td>Max contract size</td>
<td>128 kb (up from 24.5 kb in Ethereum)</td>
</tr>
</tbody>
</table>
</div>
## Transaction types
Full article: [Transactions](/developer-essentials/transactions)
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Transaction types</td>
<td>Supported:
<ul><li>0 ("legacy")</li>
<li>1 ("EIP-2930")</li>
<li>2 ("EIP-1559", the "default" on Ethereum)</li>
<li>4 (["EIP-7702"](/developer-essentials/eip-7702))</li></ul>
Not supported:
<ul><li>3 ("EIP-4844")</li></ul></td>
</tr>
</tbody>
</table>
</div>
## Gas limits
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Per-transaction gas limit</td>
<td>30M gas</td>
</tr>
<tr>
<td>Block gas limit</td>
<td>150M gas</td>
</tr>
<tr>
<td>Block gas target</td>
<td>80% (120M gas)</td>
</tr>
<tr>
<td>Gas throughput</td>
<td>500M gas/sec (150M gas/block divided by 0.3 sec/block)</td>
</tr>
</tbody>
</table>
</div>
## Gas pricing
Full article: [Gas pricing](/developer-essentials/gas-pricing)
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Gas charged</td>
<td>The **gas limit** is what is charged. That is: total tokens deducted from the sender's balance is `value + gas_price * gas_limit`. See [discussion](/developer-essentials/gas-pricing#gas-limit-not-gas-used).</td>
</tr>
<tr>
<td>EIP-1559 dynamics</td>
<td>Monad is EIP-1559-compatible; base fee and priority fee work as on Ethereum. [EIP-1559 explainer](/developer-essentials/gas-pricing#eip-1559-compatibility)</td>
</tr>
<tr>
<td>Base fee</td>
<td>Min base fee of 100 MON-gwei (100 \* 10^-9 MON).<br />The base fee controller is similar to Ethereum's but stays elevated for less time ([details](/developer-essentials/gas-pricing#base_price_per_gas-controller)).</td>
</tr>
</tbody>
</table>
</div>
## Opcode pricing
Full article: [Opcode Pricing](/developer-essentials/opcode-pricing)
Opcode pricing is the same as on Ethereum (see: [evm.codes](https://www.evm.codes/)), **except**
for the below repricings needed to reweight relative scarcities of resources due to Monad
optimizations.
<div>
<table>
<thead>
<tr>
<th>Item</th>
<th>Ethereum</th>
<th>Monad</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cold access cost - account</td>
<td>2,600</td>
<td>10,100</td>
<td>Affected opcodes: `BALANCE`, `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALL`, `CALLCODE`, `DELEGATECALL`, `STATICCALL`, `SELFDESTRUCT`<br />See [details](/developer-essentials/opcode-pricing#cold-access-cost)</td>
</tr>
<tr>
<td>Cold access cost - storage</td>
<td>2,100 per slot</td>
<td>8,100 per 128-slot page</td>
<td>Affected opcodes: `SLOAD`, `SSTORE`. Storage is warmed a page of 128 consecutive slots at a time, so the cold cost is paid once per page.<br />See [Storage](/developer-essentials/differences#storage) and [details](/developer-essentials/opcode-pricing#storage-pages)</td>
</tr>
<tr>
<td>`SSTORE` write and state growth</td>
<td>20,000 fresh slot<br />2,900 overwrite</td>
<td>2,800 first write per page<br />17,000 per net new slot in a page</td>
<td>Charged on top of the cold access cost above.<br />See [details](/developer-essentials/opcode-pricing#sstore)</td>
</tr>
<tr>
<td>Memory expansion cost</td>
<td>`3*w + w^2/512`</td>
<td>`w/2`</td>
<td>`w` is the memory size in 32-byte words. Memory per transaction is capped at 8 MB.<br />See [details](/developer-essentials/opcode-pricing#memory-expansion)</td>
</tr>
<tr>
<td>`ecRecover`, `ecAdd`, `ecMul`, `ecPairing`, `blake2f`, `point_eval` precompiles</td>
<td />
<td />
<td>See [details](/developer-essentials/opcode-pricing#precompiles)<br /><br />Precompiles `0x01`, `0x06`, `0x07`, `0x08`, `0x09`, `0x0a`</td>
</tr>
</tbody>
</table>
</div>
## Timing considerations
<div>
<table>
<thead>
<tr>
<th />
<th />
</tr>
</thead>
<tbody>
<tr>
<td>Block frequency</td>
<td>300 ms</td>
</tr>
<tr>
<td>`TIMESTAMP` opcode</td>
<td>As in Ethereum, `TIMESTAMP` is a second-granularity unix timestamp. Since blocks
are every 300 ms, this means that 3-4 blocks will likely have the same timestamp.</td>
</tr>
<tr>
<td>Finality</td>
<td>Blocks are finalized after two blocks (600 ms). Once a block is finalized, it
cannot be reorged. See
[MonadBFT](/monad-arch/consensus/monad-bft) for a fuller discussion.</td>
</tr>
<tr>
<td>Speculative finality</td>
<td>Blocks can be
[speculatively finalized](/monad-arch/consensus/monad-bft#speculative-finality)
after one block (300 ms), when it is marked as being in the `Voted` stage.<br /><br />
Speculative finality can revert under very rare circumstances (see fuller discussion
[here](/monad-arch/consensus/monad-bft#speculative-finality)).</td>
</tr>
</tbody>
</table>
</div>
## Mempool
Full article: [Local Mempool](/monad-arch/consensus/local-mempool)
Monad does not have a global mempool, as this approach is not suitable for high-performance
blockchains.
Each validator maintains a local mempool with transactions that it is aware of. When an RPC
receives a transaction, it forwards it strategically to upcoming leaders, repeating this process
if it doesn't observe the transaction getting included.
Although this is an important part of Monad's design, it is not one that should generally affect
smart contract developers in their system designs.
## Parallel Execution and JIT Compilation
Monad utilizes [parallel execution](/monad-arch/execution/parallel-execution) and
[JIT compilation](/monad-arch/execution/native-compilation) for efficiency,
but smart contract developers don't need to change anything to account for this.
In Monad, transactions are still linearly ordered, and the only correct outcome of execution is
the result as if the transactions프로젝트로 돌아가기