Monad 백서

Monad

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 37쪽

"uint256","internalType":"uint256"},{"name":"commission","type":"uint256","internalType":"uint256"},{"name":"unclaimedRewards","type":"uint256","internalType":"uint256"},{"name":"consensusStake","type":"uint256","internalType":"uint256"},{"name":"consensusCommission","type":"uint256","internalType":"uint256"},{"name":"snapshotStake","type":"uint256","internalType":"uint256"},{"name":"snapshotCommission","type":"uint256","internalType":"uint256"},{"name":"secpPubkey","type":"bytes","internalType":"bytes"},{"name":"blsPubkey","type":"bytes","internalType":"bytes"}],"stateMutability":"nonpayable"}, {"type":"function","name":"getWithdrawalRequest","inputs":[{"name":"validatorId","type":"uint64","internalType":"uint64"},{"name":"delegator","type":"address","internalType":"address"},{"name":"withdrawId","type":"uint8","internalType":"uint8"}],"outputs":[{"name":"withdrawalAmount","type":"uint256","internalType":"uint256"},{"name":"accRewardPerToken","type":"uint256","internalType":"uint256"},{"name":"withdrawEpoch","type":"uint64","internalType":"uint64"}],"stateMutability":"nonpayable"}, {"type":"function","name":"syscallOnEpochChange","inputs":[{"name":"epoch","type":"uint64","internalType":"uint64"}],"outputs":[],"stateMutability":"nonpayable"}, {"type":"function","name":"syscallReward","inputs":[{"name":"blockAuthor","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"}, {"type":"function","name":"syscallSnapshot","inputs":[],"outputs":[],"stateMutability":"nonpayable"}, {"type":"function","name":"undelegate","inputs":[{"name":"validatorId","type":"uint64","internalType":"uint64"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"withdrawId","type":"uint8","internalType":"uint8"}],"outputs":[{"name":"success","type":"bool","internalType":"bool"}],"stateMutability":"nonpayable"}, {"type":"function","name":"withdraw","inputs":[{"name":"validatorId","type":"uint64","internalType":"uint64"},{"name":"withdrawId","type":"uint8","internalType":"uint8"}],"outputs":[{"name":"success","type":"bool","internalType":"bool"}],"stateMutability":"nonpayable"}, {"type":"event","name":"ClaimRewards","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"delegator","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"epoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"CommissionChanged","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"oldCommission","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"newCommission","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}, {"type":"event","name":"Delegate","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"delegator","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"activationEpoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"EpochChanged","inputs":[{"name":"oldEpoch","type":"uint64","indexed":false,"internalType":"uint64"},{"name":"newEpoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"Undelegate","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"delegator","type":"address","indexed":true,"internalType":"address"},{"name":"withdrawId","type":"uint8","indexed":false,"internalType":"uint8"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"activationEpoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"ValidatorCreated","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"authAddress","type":"address","indexed":true,"internalType":"address"},{"name":"commission","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}, {"type":"event","name":"ValidatorRewarded","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"epoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"ValidatorStatusChanged","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"flags","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}, {"type":"event","name":"Withdraw","inputs":[{"name":"validatorId","type":"uint64","indexed":true,"internalType":"uint64"},{"name":"delegator","type":"address","indexed":true,"internalType":"address"},{"name":"withdrawId","type":"uint8","indexed":false,"internalType":"uint8"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"withdrawEpoch","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false} ] ``` ## FAQ <Accordion title="Is there a `removeValidator` function?"> There is no direct `removeValidator` function. Instead, if a validator's `auth_account` removes enough stake through [`undelegate`](#undelegate), the validator is removed from the consensus set in a future epoch. This occurs in either epoch `n+1` or epoch `n+2`, depending on whether the `undelegate` occurred within the epoch delay rounds. Even when not active, a validator's information is always retained. Validator ids are permanent since other delegators may still be delegating and need to reference that `val_id` to undelegate/withdraw. </Accordion> <Accordion title="How does a validator change their `commission`?"> A validator can change their `commission` by calling [`changeCommission`](#changecommission). </Accordion> <Accordion title="Which functions give visibility into the list of validator ids?"> See the [valset getters](#get-validatorset). </Accordion> <Accordion title="Which functions give visibility into a validator's state?"> See [`getValidator`](#getvalidator). </Accordion> <Accordion title="Which functions give visibility into a delegator's delegation to one particular validator?"> See [`getDelegator`](#getdelegator). For pending withdrawals by that delegator from that validator, see [`getWithdrawalRequest`](#getwithdrawalrequest). </Accordion> <Accordion title="Is it more like a contract or a precompile?"> Despite using Solidity selectors and ABI, it is a precompile. Accessing code at <CopyToClipboard>`0x0000000000000000000000000000000000001000`</CopyToClipboard> returns empty code. Its account is always accessed warm, and calls with invalid arguments consume all gas. Exception: if an account attempts to delegate to the staking precompile using [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702), all calls to it will revert. </Accordion> # Staking Overview Source: https://docs.monad.xyz/reference/staking/overview How to interact with Monad's staking system Monad uses a [precompile](/developer-essentials/precompiles) to manage validator delegation and rewards. This page covers the key concepts and workflows for interacting with the staking precompile. For the full interface reference, visit the [API](/reference/staking/api) page. To learn how Monad's staking system works, visit the [learn](/monad-arch/consensus/staking) tab. The staking precompile is at address <CopyToClipboard>`0x1000`</CopyToClipboard>. ## Key concepts ### Epochs and timing Staking state changes don't take effect immediately. Monad divides time into **epochs**, and most actions only activate at the start of a new epoch. Every 50,000 blocks (\~4 hours 12 minutes) is a **boundary block** that commits upcoming staking changes. After a 5,000-round delay (`EPOCH_DELAY_ROUNDS`), the new epoch starts. <img alt="timeline showing the placement of boundary blocks within an epoch" /> This means your action activates in either: * **Epoch n+1** — if submitted before the boundary block * **Epoch n+2** — if submitted after the boundary block (in the epoch delay period) Use [`getEpoch()`](/reference/staking/api#getepoch) to check the current epoch and whether the boundary has passed: ```solidity theme={null} (uint64 epoch, bool inEpochDelayPeriod) = IMonadStaking(STAKING_ADDRESS).getEpoch(); // If inEpochDelayPeriod is false: changes take effect in epoch + 1 // If inEpochDelayPeriod is true: changes take effect in epoch + 2 ``` <Note> A round is not a block — rounds increment even on missed proposals. You cannot calculate epoch boundaries with modular arithmetic on block numbers. Always use `getEpoch()`. </Note> ### Withdrawal delay Undelegated stake is not immediately available. After calling `undelegate`, you must wait `WITHDRAWAL_DELAY` (1 epoch) before calling `withdraw` to reclaim the funds. ## Common actions ### Delegate To delegate MON to a validator, call `delegate(validatorId)` with the amount as `msg.value`: ```solidity theme={null} IMonadStaking(STAKING_ADDRESS).delegate{value: amount}(validatorId); ``` * `msg.value` must be at least `DUST_THRESHOLD` (1 gwei). * Your delegation becomes active in the next epoch (or the one after, if past the boundary block). * If this causes the validator's total stake to meet `ACTIVE_VALIDATOR_STAKE`, the validator is added to the active set. ### Undelegate and withdraw Removing stake is a two-step process: **Step 1: Undelegate** — Initiate the withdrawal by specifying the amount and a `withdrawId` (0–255): ```solidity theme={null} IMonadStaking(STAKING_ADDRESS).undelegate(validatorId, amount, withdrawId); ``` **Step 2: Withdraw** — After `WITHDRAWAL_DELAY` epochs have passed, call `withdraw` to reclaim the funds: ```solidity theme={null} IMonadStaking(STAKING_ADDRESS).withdraw(validatorId, withdrawId); ``` <img alt="timeline of undelegation and withdrawal" /> <p>Timeline of withdrawability of stake relative to <code>undelegate</code></p> * You can only undelegate **active** stake (not pending delegations). * Each `(validator, delegator)` pair supports up to 256 concurrent withdrawal requests. * `withdrawId`s can be reused after the withdrawal completes. ### Claim and compound rewards Rewards accumulate automatically as your validator produces blocks. You have two options: * **Claim rewards** — withdraw accumulated rewards to your account: ```solidity theme={null} IMonadStaking(STAKING_ADDRESS).claimRewards(validatorId); ``` Claims take effect **immediately** — no epoch delay. * **Compound rewards** — re-delegate accumulated rewards, increasing your stake: ```solidity theme={null} IMonadStaking(STAKING_ADDRESS).compound(validatorId); ``` Compounded rewards activate in the next epoch (following the standard timing rules). ### Query staking state Key view methods for reading staking state: | Method | Purpose | | - | - | | [`getValidator(validatorId)`](/reference/staking/api#getvalidator) | Full validator state across execution, consensus, and snapshot views | | [`getDelegator(validatorId, address)`](/reference/staking/api#getdelegator) | Delegator's stake, rewards, and pending changes for a specific validator | | [`getWithdrawalRequest(validatorId, address, withdrawId)`](/reference/staking/api#getwithdrawalrequest) | Status of a pending withdrawal | | [`getEpoch()`](/reference/staking/api#getepoch) | Current epoch and whether boundary has passed | | [`getConsensusValidatorSet(startIndex)`](/reference/staking/api#get-validatorset) | Current epoch's leader validators (paginated) | | [`getSnapshotValidatorSet(startIndex)`](/reference/staking/api#get-validatorset) | Next epoch's leader validators (paginated) | | [`getExecutionValidatorSet(startIndex)`](/reference/staking/api#get-validatorset) | All validators meeting active staking criteria (paginated) | | [`getProposerValId()`](/reference/staking/api#getproposervalid) | Validator ID of the current block's proposer | | [`getDelegations(address, startValId)`](/reference/staking/api#getdelegations) | All validators a delegator has delegated to (paginated) | | [`getDelegators(validatorId, startDelegator)`](/reference/staking/api#getdelegators) | All delegators for a validator (paginated) | Paginated methods return up to 100 results per call. Pass `startIndex = 0` for the first call, then use `nextIndex` for subsequent calls until `isDone` is true. ## Constraints Because the staking system is a precompile rather than a smart contract, it has some behavioral differences. * **Only `CALL` is allowed.** `STATICCALL`, `DELEGATECALL`, and `CALLCODE` will revert. This means all view methods use `nonpayable` state mutability rather than `view`. * **No forked environment testing.** The staking system is a precompile, not a smart contract — there is no code at the address, so forked testing environments won't work. * **Boundary block timing.** Actions submitted during the epoch delay period (after the boundary block) won't take effect until two epochs later. Check `getEpoch()` if timing matters. * **Dust threshold.** Delegations below `DUST_THRESHOLD` (1 gwei) will revert. * **EIP-7702 caveat.** If an account delegates to the staking precompile address using EIP-7702, all calls to it will revert. ## Further reading * [API reference](/reference/staking/api) — Full reference for the staking precompile with method signatures, parameters, gas costs, events, structs, and ABI * [How staking works](/monad-arch/consensus/staking) — How Monad's staking system determines validator voting weights, epoch scheduling, and reward distribution # Agentic Payments Source: https://docs.monad.xyz/tooling-and-infra/agentic-payments <Note> See also the [x402 guide](/guides/x402) for a step-by-step tutorial on building x402-enabled endpoints. </Note> ## Overview Agentic payments enable autonomous, machine-to-machine transactions over HTTP. Rather than requiring accounts, subscriptions, or API keys, any HTTP endpoint can become instantly payable using onchain payment authorization. Monad's high throughput, sub-second finality, and low fees make it an ideal settlement layer for micropayments and agent-to-agent commerce. ## Provider summary <div> <table> <thead> <tr> <th>Service</th> <th>Protocol</th> <th>Docs</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>Monad x402 Facilitator</td> <td>[x402](https://www.x402.org/)</td> <td>[Guide](/guides/x402)</td> <td>URL: <CopyToClipboard>`https://x402-facilitator.molandak.org`</CopyToClipboard></td> </tr> <tr> <td>MPP SDK</td> <td>[MPP](https://mpp.dev/)</td> <td>[Reference](/reference/mpp/overview)</td> <td>NPM: [`@monad-crypto/mpp`](https://www.npmjs.com/package/@monad-crypto/mpp)</td> </tr> </tbody> </table> </div> ## Provider details ### Monad x402 Facilitator The Monad x402 Facilitator is a hosted service that simplifies [x402](https://www.x402.org/) payment flows on Monad. x402 brings the HTTP 402 "Payment Required" status code to life as a minimal protocol for internet-native micropayments. **How it works:** 1. A client requests a resource from a server. 2. The server responds with HTTP 402 and a JSON payment requirement. 3. The client signs a payment authorization (no onchain transaction needed from the client). 4. The server verifies the signature and serves the content. 5. The facilitator settles the payment onchain, covering gas fees. **Facilitator URL:** <CopyToClipboard>`https://x402-facilitator.molandak.org`</CopyToClipboard> **Key features:** * Supports Monad mainnet and testnet * Handles payment verification and onchain settlement * Covers gas fees on behalf of clients * Enables usage-based billing and per-call micropayments * Works with USDC on Monad **Facilitator API endpoints:** * `GET /supported` — Returns supported networks, schemes, and signer addresses * `POST /verify` — Verifies a payment signature before serving content * `POST /settle` — Executes the payment onchain after content is served To get started building x402-enabled endpoints on Monad, see the [x402 guide](/guides/x402). Learn more at [x402.org](https://www.x402.org/). ### MPP SDK The MPP SDK ([`@monad-crypto/mpp`](https://www.npmjs.com/package/@monad-crypto/mpp)) is a TypeScript/JavaScript library for integrating [Machine Payments Protocol](https://mpp.dev/) into your applications on Monad. It provides utilities for constructing and managing payment transactions programmatically. * **NPM package:** [`@monad-crypto/mpp`](https://www.npmjs.com/package/@monad-crypto/mpp) * **Reference docs:** [`@monad-crypto/mpp` Reference](/reference/mpp/overview) # Analytics Source: https://docs.monad.xyz/tooling-and-infra/analytics <Note> **See also:** [Indexers → Common Data](/tooling-and-infra/indexers/common-data) for providers of standard indexed chain data. </Note> ## Provider Summary <Tabs> <Tab title="Mainnet"> <div> <table> <thead> <tr> <th>Service</th> <th>Docs</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>[Blockaid](https://www.blockaid.io//)</td> <td /> <td>Real-time detection platform for on-chain monitoring and fraud prevention</td> </tr> <tr> <td>[Birdeye](https://birdeye.so)</td> <td>[Docs](https://docs.birdeye.so/)</td> <td>Birdeye platform provides comprehensive multi-market data for cryptocurrency tokens, pulling information from both decentralized exchanges (DEX) and centralized exchanges (CEX). </td> </tr> <tr> <td>[Bubblemaps](https://bubblemaps.io/)</td> <td>[Docs](https://docs.bubblemaps.io/)</td> <td>Visual analytics platform to investigate wallets, trace funds, and map token activity in real time</td> </tr> <tr> <td>[Chainalysis (including Hexagate)](https://www.chainalysis.com/)</td> <td>[Docs](https://auth-developers.chainalysis.com/)</td> <td>Blockchain data platform for compliance, investigations, and risk management, including Hexagate real-time threat detection and prevention</td> </tr> <tr> <td>[CoinGecko](https://www.coingecko.com/)</td> <td>[Docs](https://docs.coingecko.com/)</td> <td>Comprehensive crypto price & market data provider with on-chain DEX data, token discovery, and trading analytics</td> </tr> <tr> <td>[Collab.Land](https://collab.land)</td> <td>[Docs](https://docs.collab.land/)</td> <td>Community management tool that supports a wide range of projects, including DAOs, NFT communities, brands, and creators of all sizes</td> </tr> <tr> <td>[DeBank](https://debank.com/)</td> <td>[Docs](https://docs.cloud.debank.com/)</td> <td>DeFi portfolio tracker and analytics platform</td> </tr> <tr> <td>[DeFiLlama](https://defillama.com/)</td> <td>[Docs](https://defillama.com/docs/api)</td> <td>Open-source DeFi TVL and analytics platform aggregating data from thousands of protocols across multiple chains. See [How to list a DeFi project](https://docs.llama.fi/list-your-project/submit-a-project)</td> </tr> <tr> <td>[Dune](https://www.dune.com/)</td> <td>[Docs](https://docs.dune.com/home)</td> <td>Datasets and dashboards about on-chain activity</td> </tr> <tr> <td>[Elliptic](https://www.elliptic.co/)</td> <td>[Docs](https://developers.elliptic.co/)</td> <td>Analytics for compliance, risk management, and intelligence</td> </tr> <tr> <td>[Flipside](https://www.flipsidecrypto.xyz/)</td> <td>[Docs](https://docs.flipsidecrypto.xyz/)</td> <td>AI-powered analytics for on-chain activity</td> </tr> <tr> <td>[InsightX](https://app.insightx.network)</td> <td>[Docs](https://docs.insightx.network/docs)</td> <td>Web3 transparency and security platform combining smart contract scanning with real-time holder maps for on-chain trading</td> </tr> <tr> <td>[Matrica](https://matrica.io/)</td> <td>[Docs](https
프로젝트로 돌아가기