# Moonbeam Developer Documentation (LLMS Format) This file contains documentation for Moonbeam (https://moonbeam.network/). Moonbeam is a smart contract platform that makes it easy to build natively interoperable applications on Polkadot and Ethereum. It is intended for use with large language models (LLMs) to support developers working with Moonbeam. The content includes selected pages from the official docs, organized by section. This file includes documentation related to the product: XCM ## AI Prompt Template You are an AI developer assistant for Moonbeam (https://moonbeam.network/). Your task is to assist developers in understanding and using the product described in this file. - Provide accurate answers based on the included documentation. - Do not assume undocumented features, behaviors, or APIs. - If unsure, respond with “Not specified in the documentation. ## List of doc pages: Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/learn/features/xchain-plans.md [type: learn] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/mrl.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/core-concepts/instructions.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/core-concepts/multilocations.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/core-concepts/sovereign-accounts.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/core-concepts/weights-fees.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/overview.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/send-execute-xcm.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/xc-registration/forum-templates.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/xc-registration/self-serve-asset-registration.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/xc-registration/xc-integration.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/xc20/send-xc20s/eth-api.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/interoperability/xcm/xcm-utils.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/tutorials/interoperability/remote-staking-xcm.md [type: tutorials] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/tutorials/interoperability/uniswapv2-swap-xcm.md [type: tutorials] ## Full content for each doc page Doc-Content: https://docs.moonbeam.network/learn/features/xchain-plans/ --- BEGIN CONTENT --- --- title: Cross-Chain Communication description: This guide covers the ways you can build cross-chain dApps with Moonbeam, including via XCM, cross consensus messaging, and GMP, general message passing. categories: Basics, XCM --- # Cross-Chain Communication Methods Moonbeam makes it easy for developers to build smart contracts that connect across chains, both within the Polkadot ecosystem and outside the Polkadot ecosystem. This page will provide an overview of the underlying protocols that enable cross-chain communication and how you can leverage them to build connected contracts. For step-by-step guides of how to put these principles into practice, be sure to check out the [interoperability tutorials](/tutorials/interoperability/){target=\_blank}. Two key terms that will come up frequently in this guide are XCM and GMP. [XCM](/builders/interoperability/xcm/){target=\_blank} refers to cross-consensus messaging, and it's Polkadot's native interoperability language that facilitates communication between Polkadot blockchains. You can read more about the [standardized XCM message format](https://docs.polkadot.com/develop/interoperability/intro-to-xcm/){target=\_blank} and [How to Get Started Building with XCM](/builders/interoperability/xcm/){target=\_blank}. [GMP](https://moonbeam.network/news/seamless-blockchain-interoperability-the-power-of-general-message-passing-gmp){target=\_blank}, or general message passing, refers to the sending and receiving of messages within decentralized blockchain networks. While XCM is a type of general message passing, GMP colloquially refers to cross-chain communication between Moonbeam and blockchains outside of Polkadot. Similarly, in this guide, XCM refers to cross-chain messaging within Polkadot, and GMP refers to cross-chain messaging between Moonbeam and other ecosystems outside of Polkadot. ## Quick Reference {: #quick-reference } === "Comparison of XCM vs GMP" | Specification | XCM | GMP | |:---------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | **Scope** | Polkadot and its connected parachains | Any blockchain supported by a GMP provider | | **Provider** | Polkadot | [Axelar](/builders/interoperability/protocols/axelar/){target=\_blank}, [Wormhole](/builders/interoperability/protocols/wormhole/){target=\_blank}, [LayerZero](/builders/interoperability/protocols/layerzero/){target=\_blank}, [Hyperlane](/builders/interoperability/protocols/hyperlane/){target=\_blank}, etc. | | **Implementation** | [XCM Virtual Machine](https://wiki.polkadot.com/learn/learn-xcvm/){target=\_blank} | Smart contracts | | **Security** | Polkadot's shared security | Proprietary consensus determined by GMP provider | | **Fees** | [Purchased with `BuyExecution` XCM instruction with supported asset](/builders/interoperability/xcm/core-concepts/weights-fees/){target=\_blank} | User sends value with transaction to pay for gas on the destination chain | | **Adding New Chains** | Requires creation of XCM channels by both connected chains | Requires GMP provider to add support | ## XCM Transport Methods {: #xcm-transport-methods } XCMP is the protocol that carries messages conforming to the XCM standard. The difference between the two is easy to remember with the added letter "P" for protocol. While XCM is the language that defines the format of the message to send, XCMP can be thought of as the pipes that enable the delivery of said messages. XCMP is comprised of channels that enable communication between connected blockchains. When a parachain launches on Polkadot, two XCM channels are established automatically to allow for communication between the Polkadot relay chain and the parachain itself. XCM channels are omnidirectional, so two channels must be established for bidirectional communication. Polkadot parachains can optionally choose to establish additional XCM channels with other parachains. Establishing XCM channels with other chains is a double opt-in process, so the receiving chain must also agree to have the channel established. Establishing XCM channels with another parachain allows for the exchange of XCM messages, enabling the flow of cross-chain assets and remote contract calls, to name a few examples. There are several different subcategories of XCM transport methods, including: ### VMP {: #vmp } VMP, or [Vertical Message Passing](https://wiki.polkadot.com/learn/learn-xcm-transport/#vmp-vertical-message-passing){target=\_blank}, refers to message passing between the relay chain and a parachain. Given that XCM channels are one-way, there are two types of message passing that comprise VMP, namely: - **UMP** - Upward Message Passing refers to message passing from a parachain to the relay chain - **DMP** - Downward Message Passing refers to message passing from the relay chain to a parachain ### HRMP {: #HRMP } [Horizontal Relay-routed Message Passing](https://wiki.polkadot.com/learn/learn-xcm-transport/#hrmp-xcmp-lite){target=\_blank} (HRMP) is a temporary protocol that is currently being used while XCMP (Cross-Chain Message Passing) is still under development. HRMP serves as a placeholder and provides the same functionality and interface as XCMP. However, HRMP is more resource-intensive because it stores all messages within the Relay Chain's storage. When opening XCM channels with other parachains today, those channels are using HRMP in place of the aforementioned XCMP. Once the implementation of XCMP is complete, the plan is to phase out HRMP and replace it with XCMP gradually. For more information about each one, be sure to check out [Polkadot's Guide to XCM Transport](https://wiki.polkadot.com/learn/learn-xcm-transport/){target=\_blank}. ## General Message Passing {: #general-message-passing } As you know, GMP colloquially refers to cross-chain communication between Moonbeam and other blockchains outside of Polkadot. General message passing is enabled by cross-chain protocols that specialize in cross-chain communication. Each GMP provider takes a slightly different approach, but conceptually, they are quite similar. There are different contracts and functions for each provider, but each GMP provider has the same end goal: to provide secure and reliable cross-chain communication. ### Happy Path of a Cross-Chain Message {: #happy-path-of-a-cross-chain-message } At a high level, the happy path of a message sent via GMP is as follows. A user or developer will call a contract specific to the GMP protocol, sometimes referred to as a mailbox contract or a gateway contract. This call typically includes parameters like the destination chain, the destination contract address, and includes sufficient value to pay for the transaction on the destination chain. A GMP provider listens for specific events on the origin blockchain pertaining to their gateway or mailbox contracts that indicate that a user wants to send a cross-chain message using their protocol. The GMP provider will validate certain parameters, including whether or not sufficient value was provided to pay for gas on the destination chain. In fact, the GMP provider may have a decentralized network of many nodes checking the authenticity of the message and verifying parameters. The GMP provider will not validate the integrity of the contract call to be delivered on the destination chain. E.g., the GMP provider will happily deliver a valid, paid-for message that contains a smart contract call that reverts on arrival. Finally, if everything checks out according to the consensus mechanism of the GMP provider, the message will be delivered to the destination chain, triggering the respective contract call at the destination. ![Happy Path of a cross chain GMP message](/images/learn/features/xchain-plans/xchain-plans-1.webp) ### GMP Providers Integrated with Moonbeam {: #gmp-providers-integrated-with-moonbeam } A large number of GMP providers have integrated with Moonbeam, which is beneficial for several reasons. For one, it enables you to work with whichever GMP provider you prefer. Second, it means that Moonbeam is connected to a rapidly growing number of chains. Whenever a GMP provider integrated with Moonbeam adds support for another chain, Moonbeam is automatically now connected with that chain. GMP providers are constantly adding support for new chains, and it's exciting to see those new integrations benefit the Moonbeam community. Additionally, having a variety of GMP providers allows for redundancy and backup. GMP providers have occasional maintenance windows or downtime; thus, it may make sense to add support for multiple GMP providers to ensure consistent uptime. A significant number of GMP providers have integrated with Moonbeam, offering multiple benefits. Firstly, this integration allows users the flexibility to choose their preferred GMP provider. Secondly, Moonbeam's connectivity is enhanced as it automatically links with any new chains that its GMP providers support. Given that GMP providers frequently expand their support to new chains, the continuous roll out of new chains is a promising ongoing benefit for the Moonbeam community. Additionally, the diversity of GMP providers ensures better reliability and backup options. Since GMP providers can occasionally experience downtime or scheduled maintenance, the ability to integrate with multiple GMP providers is an important benefit. The following GMP providers have integrated with Moonbeam: - [Axelar](/builders/interoperability/protocols/axelar/){target=\_blank} - [Hyperlane](/builders/interoperability/protocols/hyperlane/){target=\_blank} - [LayerZero](/builders/interoperability/protocols/layerzero/){target=\_blank} - [Wormhole](/builders/interoperability/protocols/wormhole/){target=\_blank} ## Implementing Both XCM and GMP {: #implementing-both-xcm-and-gmp } Building with XCM or GMP does not preclude building with the other. As they suit different use cases, a team may seek to utilize XCM to handle interoperability needs within Polkadot, and GMP to deliver cross-chain messages to and from blockchains outside of Polkadot. As an example, several DEXes on Moonbeam support the trading of tokens migrated to Moonbeam via XCM, such as xcDOT, and assets bridged from ecosystems outside of Polkadot, such as USDC via Wormhole. ### Moonbeam Routed Liquidity {: #moonbeam-routed-liquidity } [Moonbeam Routed Liquidity](/builders/interoperability/mrl/) (MRL) enables seamless liquidity between external blockchains connected to Moonbeam via Wormhole to Polkadot parachains connected to Moonbeam via XCM. This combination of GMP and XCM means that any ERC-20 token on a chain that Wormhole has integrated with can be routed through Moonbeam to a destination parachain (and back). A diagram of the happy path of a token transfer to a parachain via MRL is shown below, and you can find more information at the [MRL docs](/builders/interoperability/mrl/). ![Happy Path of an MRL token transfer](/images/learn/features/xchain-plans/xchain-plans-2.webp)
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/mrl/ --- BEGIN CONTENT --- --- title: Moonbeam Routed Liquidity description: Learn how to receive Moonbeam Routed Liquidity after establishing a cross-chain integration with a Moonbeam-based network. categories: XCM --- # Moonbeam Routed Liquidity ## Introduction {: #introduction } Moonbeam Routed Liquidity (MRL) refers to a use case in which liquidity in any blockchain ecosystem that Moonbeam is connected to can be routed to Polkadot parachains. This is possible because of multiple components that work together: - **General Message Passing (GMP)** - technology connecting multiple blockchains, including Moonbeam. With it, developers can pass messages with arbitrary data, and tokens can be sent across non-parachain blockchains through [chain-agnostic GMP protocols](/builders/interoperability/protocols/){target=\_blank} - [**Cross-Consensus Message Passing (XCM)**](/builders/interoperability/xcm/overview/){target=\_blank} - Polkadot's flavor of GMP. Main technology driving cross-chain interactions between Polkadot and its parachains, including Moonbeam - **XCM-Enabled ERC-20s** - also referred to as [local XC-20s](/builders/interoperability/xcm/xc20/overview/#local-xc20s){target=\_blank}, are all of the ERC-20 tokens that exist on Moonbeam's EVM that are XCM-enabled out of the box - [**GMP Precompile**](/builders/ethereum/precompiles/interoperability/gmp/){target=\_blank} - a [precompiled contract](/builders/ethereum/precompiles/overview/){target=\_blank} that acts as an interface between a message passed from [Wormhole GMP protocol](/builders/interoperability/protocols/wormhole/){target=\_blank} and XCM These components are combined to offer seamless liquidity routing into parachains through Moonbeam. Liquidity can be routed to parachains using either the [GMP Precompile](/builders/ethereum/precompiles/interoperability/gmp/){target=\_blank} or traditional smart contracts that interact with XCM-related precompiles, like the [X-Tokens](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-precompile/){target=\_blank} Precompile. GMP protocols typically move assets in a lock/mint or burn/mint fashion. This liquidity exists on Moonbeam normally as ERC-20 tokens. All ERC-20s on Moonbeam are now XCM-enabled, meaning they can now exist as XC-20s in any other parachain, as long as they are registered on the other parachain. XCM-enabled ERC-20s are referred to as [local XC-20s](/builders/interoperability/xcm/xc20/overview/#local-xc20s){target=\_blank} on Moonbeam. MRL is currently available through Wormhole-connected chains, but nothing stops a parachain team from implementing a similar pathway through a different GMP provider. This guide will primarily cover the process of integrating with Wormhole's SDKs and interfaces so that your parachain can access liquidity from non-parachain blockchains through Moonbeam. It will also cover the requirements to get started and the tokens available through Wormhole. ## Prerequisites {: #prerequisites } To begin an MRL integration with your parachain, you will first need to: - [Establish a cross-chain integration with Moonbeam via HRMP channels](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} so assets can be sent from Moonbeam to your parachain - [Register Moonbeam’s asset on your parachain](/builders/interoperability/xcm/xc-registration/assets/#register-moonbeam-native-assets){target=\_blank}. This is required due to a temporary drawback of pallets that send XCM messages for asset transfer, making Moonbeam’s native gas asset the only asset that can be used as a cross-chain fee on the way back - [Register the local XC-20 token(s) you want routed to your parachain](/builders/interoperability/xcm/xc-registration/assets/#register-local-xc20){target=\_blank} - Allow these local XC-20 token(s) to be used for XCM fees - Allow users to send the `Transact` XCM instruction (via `polkadotXcm.Send` or with the [XCM Transactor Pallet](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/#xcm-transactor-pallet-interface){target=\_blank}), which enables remote EVM calls, allowing accounts on a remote parachain to interact with the bridging smart contracts on Moonbeam ## MRL Through Wormhole {: #mrl-through-wormhole } While MRL intends to encompass many different GMP providers, Wormhole is the first built for the public.After you have completed all of the [prerequisites](#prerequisites), to receive liquidity through Wormhole, you'll need to: - Notify the Moonbeam team of your desire to integrate into the MRL program so that we can help you with the technical implementation - Connect with the Wormhole team and other MRL-dependent frontends to finalize technical details and sync announcements. They will likely need the following information: - Parachain ID - The account type that your parachain uses (i.e., AccountId32 or AccountKey20) - The addresses and names of the tokens that you have registered - An endpoint that a [Wormhole Connect](https://wormhole.com/products/connect){target=\_blank} frontend can use - Why do you want your parachain to be connected through Wormhole Connect? ### Send Tokens Through Wormhole to a Parachain {: #sending-tokens-through-wormhole } MRL provides a one-click solution that allows you to define a multilocation as the final destination for your assets arriving from any Wormhole chain with a [Wormhole Connect integration](https://wormhole.com/products/connect){target=\_blank}. To send tokens through Wormhole and MRL, user interfaces will use a mixture of the [Wormhole TokenBridge](https://github.com/wormhole-foundation/wormhole/blob/main/ethereum/contracts/bridge/interfaces/ITokenBridge.sol){target=\_blank} and [Moonbeam’s GMP Precompile](/builders/ethereum/precompiles/interoperability/gmp/){target=\_blank}. Users transferring liquidity will invoke the `transferTokensWithPayload` method on the origin chain's deployment of the Wormhole TokenBridge smart contract, which implements the `ITokenBridge.sol` interface to send tokens to the GMP Precompile. This function requires a bytes payload, formatted as a SCALE-encoded multilocation object wrapped within another precompile-specific versioned type. To learn how to build this payload, please refer to the [Building the Payload for Wormhole](/builders/ethereum/precompiles/interoperability/gmp/#building-the-payload-for-wormhole){target=\_blank} section of the GMP Precompile documentation. Wormhole relies on a set of distributed nodes that monitor the state on several blockchains. In Wormhole, these nodes are referred to as [Guardians](https://wormhole.com/docs/protocol/infrastructure/guardians/){target=\_blank}. The Guardian's role is to observe messages and sign the corresponding payloads. If 2/3rds of Wormhole's signing Guardians validate a particular message, the message becomes approved and can be received on other chains. The Guardian signatures and the message form a proof called a [Verified Action Approval (VAA)](https://wormhole.com/docs/protocol/infrastructure/vaas/){target=\_blank}. These VAAs are delivered to their destinations by [relayers](https://wormhole.com/docs/protocol/infrastructure/relayer/){target=\_blank} within the Wormhole network. On the destination chain, the VAA is used to perform an action. In this case, the VAA is passed into the `wormholeTransferERC20` function of the GMP Precompile, which processes the VAA through the Wormhole bridge contract (which mints the tokens) and relays the tokens to a parachain using XCM messages. Please note that as a parachain integrating MRL, you will likely not need to implement or use the GMP Precompile. A relayer's only job is to pass the transactions approved by Wormhole Guardians to the destination chain. MRL is supported by some relayers already, but anyone can run one. Furthermore, users can manually execute their transaction in the destination chain when bridging through Wormhole and avoid relayers altogether. ![Transferring wormhole MRL](/images/builders/interoperability/mrl/mrl-1.webp) ### Send Tokens From a Parachain Back Through Wormhole {: #sending-tokens-back-through-wormhole } To send tokens from a parachain back through Wormhole to a destination chain, a user must send a transaction, preferably using the `utility.batchAll` extrinsic, which will batch a token transfer and a remote execution action into a single transaction. For example, a batch with a `xTokens.transferMultiassets` call and a `polkadotXcm.send` call with the `Transact` instruction. The reason for batching is to offer a one-click solution. Nevertheless, for now, the user must also own xcGLMR (representation of GLMR) on the parachain. There are two main reasons as to why: - Local XC-20s (XCM-enabled ERC-20s) can't be used to pay for XCM execution on Moonbeam. This was a design decision, as it was preferred to treat them as ERC-20s and utilize the native `transfer` function of the ERC-20 interface. Consequently, XCM instructions handling the XC-20s are only limited to moving funds from one account to another and don't understand the Holding Register that is inherent to the XCM flow - Currently, XCM-related pallets limit XCM messages' ability to send tokens with different reserve chains. Consequently, you can't send an XC-20 and set the fee token to be the native parachain token Note that as of late 2024, the X-Tokens precompile now uses the Polkadot XCM pallet under the hood, replacing the X-Tokens pallet. Parachains using a different pallet must implement their own solution to transfer reserve and non-reserve assets in a single message. As an example, a brief overview of the entire process of sending MRL tokens from a parachain back through Wormhole to a destination chain is as follows: 1. Send a batch transaction using the `batchAll` extrinsic of the [Utility Pallet](/builders/substrate/interfaces/utility/utility/){target=\_blank} that contains the following two calls: - **`xTokens.transferMultiassets`** - sends xcGLMR and the local XC-20 to the user’s [Computed Origin account](#calculate-computed-origin-account). The Computed Origin account is a keyless account on Moonbeam that an account on another parachain has control of via XCM - **`polkadotXcm.send`** - with the `Transact` instruction. Sends a [remote EVM call via XCM](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank} to the Batch Precompile on Moonbeam, which batches the following two calls into a single remote EVM transaction using the `ethereumXcm.transact` extrinsic: - **`approve`** (of the local XC-20 contract) - approves the Wormhole relayer to transfer the local XC-20 - **`transferTokensWithRelay`** (of the relayer contract) - calls the `transferTokensWithPayload` function of the Wormhole TokenBridge smart contract on Moonbeam to transfer the tokens cross-chain, which broadcasts the message for the Wormhole Guardians to pick up 2. The Guardian Network will pick up on the Wormhole transaction and sign it 3. A Wormhole relayer will relay the tokens to the destination chain and destination account ![Transferring Wormhole MRL out](/images/builders/interoperability/mrl/mrl-2.webp) Now that you have a general idea of the game plan, you can begin implementing it. The example in this guide will show you how to transfer assets from a parachain to Moonbase Alpha and back through Wormhole to the destination chain, but this guide can be adapted for Moonbeam. #### Calculate the Computed Origin Account {: #calculate-computed-origin-account } To send tokens back through Wormhole, you'll need to calculate the user's Computed Origin account (previously referred to as a multilocation-derivative account) on Moonbeam. This can be done off-chain using the [`calculate-multilocation-derivative-account.ts` script](https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-multilocation-derivative-account.ts){target=\_blank} from the [xcm-tools repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank}. For more details, you can refer to the [Computed Origins](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank} guide. Alternatively, the `multilocationToAddress` function of the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank} can also be used. #### Create a Project {: #create-a-project } You'll need to create a new project directory for the files you'll be building in this guide. Take the following steps to set up your project: 1. Create a new directory and change into the directory ```bash mkdir wormhole-mrl-demo && cd wormhole-mrl-demo ``` 2. Create a `package.json` file: ```bash npm init -y ``` 3. Install packages that you'll need to build the remote EVM calls and the XCM extrinsics ```bash npm i @polkadot/api ethers ``` 4. Create the files that you'll need for this guide: - `build-transfer-multiassets-call.js` - for creating the `xTokens.transferMultiassets` extrinsic that transfers assets cross-chain. This contains the logic for the first call of the batch transaction - `build-remote-calldata.js` - for creating the encoded calldata that approves the Wormhole relayer to transfer the local XC-20 and initiates the transfer via the Wormhole TokenBridge contract. This is required for the second call of the batch transaction - `build-remote-evm-call.js` - to create the `polkadotXcm.send` extrinsic that executes the remote EVM call. This contains the logic for the second call of the batch transaction - `send-batch-transaction.js` - for assembling and sending the batch transaction for the asset transfer and the remote EVM call ```bash touch build-transfer-multiassets.js build-remote-calldata.js \ build-remote-evm-call.js send-batch-transaction.js ``` 5. Create a directory and files for the ABIs of each of the contracts you'll be working within this guide: ```bash mkdir abi && touch abi/ERC20.js abi/TokenRelayer.js abi/Batch.js ``` ??? code "ERC-20 Interface ABI" ```js title="ERC20.js" export default [ { anonymous: false, inputs: [ { indexed: true, internalType: 'address', name: 'owner', type: 'address', }, { indexed: true, internalType: 'address', name: 'spender', type: 'address', }, { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256', }, ], name: 'Approval', type: 'event', }, { anonymous: false, inputs: [ { indexed: true, internalType: 'address', name: 'from', type: 'address', }, { indexed: true, internalType: 'address', name: 'to', type: 'address', }, { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256', }, ], name: 'Transfer', type: 'event', }, { inputs: [ { internalType: 'address', name: 'owner', type: 'address', }, { internalType: 'address', name: 'spender', type: 'address', }, ], name: 'allowance', outputs: [ { internalType: 'uint256', name: '', type: 'uint256', }, ], stateMutability: 'view', type: 'function', }, { inputs: [ { internalType: 'address', name: 'spender', type: 'address', }, { internalType: 'uint256', name: 'amount', type: 'uint256', }, ], name: 'approve', outputs: [ { internalType: 'bool', name: '', type: 'bool', }, ], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { internalType: 'address', name: 'account', type: 'address', }, ], name: 'balanceOf', outputs: [ { internalType: 'uint256', name: '', type: 'uint256', }, ], stateMutability: 'view', type: 'function', }, { inputs: [], name: 'totalSupply', outputs: [ { internalType: 'uint256', name: '', type: 'uint256', }, ], stateMutability: 'view', type: 'function', }, { inputs: [ { internalType: 'address', name: 'to', type: 'address', }, { internalType: 'uint256', name: 'amount', type: 'uint256', }, ], name: 'transfer', outputs: [ { internalType: 'bool', name: '', type: 'bool', }, ], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { internalType: 'address', name: 'from', type: 'address', }, { internalType: 'address', name: 'to', type: 'address', }, { internalType: 'uint256', name: 'amount', type: 'uint256', }, ], name: 'transferFrom', outputs: [ { internalType: 'bool', name: '', type: 'bool', }, ], stateMutability: 'nonpayable', type: 'function', }, ]; ``` ??? code "TokenBridge Relayer ABI" ```js title="TokenRelayer.js" export default [ { inputs: [ { internalType: 'uint16', name: 'targetChainId', type: 'uint16', }, { internalType: 'address', name: 'token', type: 'address', }, { internalType: 'uint8', name: 'decimals', type: 'uint8', }, ], name: 'calculateRelayerFee', outputs: [ { internalType: 'uint256', name: 'feeInTokenDenomination', type: 'uint256', }, ], stateMutability: 'view', type: 'function', }, { inputs: [ { internalType: 'address', name: 'token', type: 'address', }, { internalType: 'uint256', name: 'amount', type: 'uint256', }, { internalType: 'uint256', name: 'toNativeTokenAmount', type: 'uint256', }, { internalType: 'uint16', name: 'targetChain', type: 'uint16', }, { internalType: 'bytes32', name: 'targetRecipient', type: 'bytes32', }, { internalType: 'uint32', name: 'batchId', type: 'uint32', }, ], name: 'transferTokensWithRelay', outputs: [ { internalType: 'uint64', name: 'messageSequence', type: 'uint64', }, ], stateMutability: 'payable', type: 'function', }, { inputs: [ { internalType: 'uint256', name: 'toNativeTokenAmount', type: 'uint256', }, { internalType: 'uint16', name: 'targetChain', type: 'uint16', }, { internalType: 'bytes32', name: 'targetRecipient', type: 'bytes32', }, { internalType: 'uint32', name: 'batchId', type: 'uint32', }, ], name: 'wrapAndTransferEthWithRelay', outputs: [ { internalType: 'uint64', name: 'messageSequence', type: 'uint64', }, ], stateMutability: 'payable', type: 'function', }, ]; ``` ??? code "Batch Precompile ABI" ```js title="Batch.js" export default [ { anonymous: false, inputs: [ { indexed: false, internalType: 'uint256', name: 'index', type: 'uint256', }, ], name: 'SubcallFailed', type: 'event', }, { anonymous: false, inputs: [ { indexed: false, internalType: 'uint256', name: 'index', type: 'uint256', }, ], name: 'SubcallSucceeded', type: 'event', }, { inputs: [ { internalType: 'address[]', name: 'to', type: 'address[]', }, { internalType: 'uint256[]', name: 'value', type: 'uint256[]', }, { internalType: 'bytes[]', name: 'callData', type: 'bytes[]', }, { internalType: 'uint64[]', name: 'gasLimit', type: 'uint64[]', }, ], name: 'batchAll', outputs: [], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { internalType: 'address[]', name: 'to', type: 'address[]', }, { internalType: 'uint256[]', name: 'value', type: 'uint256[]', }, { internalType: 'bytes[]', name: 'callData', type: 'bytes[]', }, { internalType: 'uint64[]', name: 'gasLimit', type: 'uint64[]', }, ], name: 'batchSome', outputs: [], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { internalType: 'address[]', name: 'to', type: 'address[]', }, { internalType: 'uint256[]', name: 'value', type: 'uint256[]', }, { internalType: 'bytes[]', name: 'callData', type: 'bytes[]', }, { internalType: 'uint64[]', name: 'gasLimit', type: 'uint64[]', }, ], name: 'batchSomeUntilFailure', outputs: [], stateMutability: 'nonpayable', type: 'function', }, ]; ``` #### Build the Transfer Multiassets Extrinsic {: #build-transfer-multiassets } You can begin to tackle the `xTokens.transferMultiassets` extrinsic, which accepts four parameters: - `assets` - defines the multilocation and amount of xcDEV (xcGLMR for Moonbeam) and the local XC-20 to send to Moonbase Alpha, with the xcDEV positioned as the first asset and the local XC-20 as the second - `feeItem` - set to the index of the xcDEV asset, which in this case is `0`, so that DEV is used to pay for the execution fees in Moonbase Alpha - `dest` - a multilocation that defines the Computed Origin account that you calculated in the previous section on Moonbase Alpha - `destWeightLimit` - the weight to be purchased to pay for XCM execution on the destination chain You can find more information on each parameter in the [X-Tokens Precompile page](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-precompile/#xtokens-solidity-interface){target=\_blank} documentation. In the `build-transfer-multiassets-call.js` file, you'll build the `xTokens.transferMultiassets` extrinsic and export it. ```js title="build-transfer-multiassets-call.js" import { ApiPromise, WsProvider } from '@polkadot/api'; // Input data const originChainProviderWsURL = 'INSERT_ORIGIN_CHAIN_WSS_URL'; const computedOriginAccount = 'INSERT_COMPUTED_ORIGIN_ADDRESS'; const localXC20Address = 'INSERT_LOCAL_XC20_ADDRESS'; const transferAmount = 'INSERT_AMOUNT_TO_TRANSFER'; // Transfer multiassets parameters const assets = { V4: [ { // xcDEV id: { parents: 1, interior: { X2: [ { Parachain: 1000 }, // Parachain ID { PalletInstance: 3 }, // Index of the Balances Pallet ], }, }, fun: { Fungible: '100000000000000000', // 0.1 DEV as an estimation for XCM and EVM transaction fee }, }, { // Local XC-20 token id: { parents: 1, interior: { X3: [ { Parachain: 1000 }, // Parachain ID { PalletInstance: 48 }, // Index of the ERC-20 XCM Bridge Pallet { AccountKey20: { key: localXC20Address, }, }, ], }, }, fun: { Fungible: transferAmount, }, }, ], }; const feeItem = 0; const destination = { V4: { parents: 1, interior: { X2: [ { Parachain: 1000 }, { AccountKey20: { key: computedOriginAccount } }, ], }, }, }; const weightLimit = 'Unlimited'; export const getTransferMultiassetsCall = async () => { // Create origin chain API provider const originChainProvider = new WsProvider(originChainProviderWsURL); const originChainAPI = await ApiPromise.create({ provider: originChainProvider, }); // Create the transferMultiasset extrinsic const transferMultiassets = originChainAPI.tx.xTokens.transferMultiassets( assets, feeItem, destination, weightLimit ); originChainAPI.disconnect(); return transferMultiassets; }; ``` To modify the code for Moonbeam, you'll use the following configurations: | Parameter | Value | |:------------------------------:|:-----:| | Parachain ID | 2004 | | Balances Pallet Index | 10 | | ERC-20 XCM Bridge Pallet Index | 110 | #### Build the Remote EVM Call {: #build-the-remote-evm-call } To generate the second call of the batch transaction, the `polkadotXcm.send` extrinsic, you'll need to create the EVM transaction and then assemble the XCM instructions that execute said EVM transaction. For now, you'll focus on generating the calldata for the EVM transaction. For this, you'll construct a transaction that interacts with the [Batch Precompile](/builders/ethereum/precompiles/ux/batch/){target=\_blank} so that two transactions can happen in one. This is helpful because this EVM transaction has to approve both a Wormhole relayer to relay the local XC-20 token and the relay action itself. To create the batch transaction and wrap it in a remote EVM call to be executed on Moonbeam, you'll need to take the following steps: 1. Create contract instances of the local XC-20, [the Wormhole relayer](https://github.com/wormhole-foundation/example-token-bridge-relayer/blob/main/evm/src/token-bridge-relayer/TokenBridgeRelayer.sol){target=\_blank}, and the [Batch Precompile](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank}. For this, you'll need the ABI for each contract and the address of a Wormhole relayer. You can use the [xLabs relayer](https://xlabs.xyz/){target=\_blank}: === "Moonbeam" ```text 0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca ``` === "Moonbase Alpha" ```text 0x9563a59c15842a6f322b10f69d1dd88b41f2e97b ``` 2. Use Ether's `encodeFunctionData` function to get the encoded call data for the two calls in the batch transaction: the `approve` transaction and the `transferTokensWithRelay` transaction 3. Combine the two transactions into a batch transaction and use Ether's `encodeFunctionData` to get the encoded call data for the batch transaction 4. Use the encoded call data for the batch transaction to create the remote EVM call via the `ethereumXcm.transact` extrinsic, which accepts the `xcmTransaction` as the parameter. For more information, please refer to the [Remote EVM Calls documentation](/builders/interoperability/xcm/remote-execution/remote-evm-calls/#ethereum-xcm-pallet-interface){target=\_blank} In the `build-remote-calldata.js` file, add the following code: ```js title="build-remote-calldata.js" import { ApiPromise, WsProvider } from '@polkadot/api'; import { ethers } from 'ethers'; import batchABI from './abi/Batch.js'; import erc20ABI from './abi/ERC20.js'; import tokenRelayerABI from './abi/TokenRelayer.js'; const localXC20Address = 'INSERT_LOCAL_XC20_ADDRESS'; const transferAmount = 'INSERT_AMOUNT_TO_TRANSFER'; const xLabsRelayer = '0x9563a59c15842a6f322b10f69d1dd88b41f2e97b'; const destinationChainId = 'INSERT_DESTINATION_CHAIN_ID'; const computedOriginAccount = 'INSERT_COMPUTED_ORIGIN_ADDRESS'; // The recipient address on the destination chain needs to be formatted in 32 bytes // You'll pad the address to the left with zeroes. Add the destination address below // without the 0x const destinationAddress = '0x000000000000000000000000' + 'INSERT_DESTINATION_ADDRESS'; // Create contract instances const batchInterface = new ethers.Interface(batchABI); const localXC20Interface = new ethers.Interface(erc20ABI); const tokenRelayer = new ethers.Contract( xLabsRelayer, tokenRelayerABI, new ethers.JsonRpcProvider('https://rpc.api.moonbase.moonbeam.network') ); // Get the encoded calldata for the approve transaction const approve = localXC20Interface.encodeFunctionData('approve', [ xLabsRelayer, // Spender transferAmount, // Amount ]); // Get the encoded calldata for the transferTokensWithRelay transaction. // Use wrapAndTransferEthWithRelay if the token is GLMR const transferTokensWithRelay = tokenRelayer.interface.encodeFunctionData( 'transferTokensWithRelay', [ localXC20Address, // Token transferAmount, // Amount to be transferred 0, // Amount to swap into native assets on the target chain destinationChainId, // Target chain ID, like Ethereum MainNet or Fantom destinationAddress, // Target recipient address 0, // Batch ID for Wormhole message batching ] ); const encodedBatchAllCall = batchInterface.encodeFunctionData('batchAll', [ [localXC20Address, xLabsRelayer], // Addresses to call [0, 0], // Value to send for each call [approve, transferTokensWithRelay], // Call data for each call [], // Gas limit for each call ]); export const getTransactCall = async () => { // Create Moonbeam API provider const moonbeamProvider = new WsProvider( 'wss://wss.api.moonbase.moonbeam.network' ); const moonbeamAPI = await ApiPromise.create({ provider: moonbeamProvider }); // Create the extrinsic for the remote EVM call const transact = moonbeamAPI.tx.ethereumXcm.transact({ V2: { gasLimit: 350000n, action: { Call: '0x0000000000000000000000000000000000000808', }, value: 0n, input: encodedBatchAllCall, }, }); const txWeight = (await transact.paymentInfo(computedOriginAccount)).weight; moonbeamAPI.disconnect(); return { transact, txWeight }; }; ``` #### Build the XCM Message for the Remote EVM Call {: #build-xcm-message-for-remote-evm-call } Next, you'll need to create the extrinsic to send the remote EVM call to Moonbeam. To do so, you'll want to send an XCM message such that the [`Transact`](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} XCM instruction gets successfully executed. The most common method to do this is through `polkadotXcm.send` with the [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank}, [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank}, and [`Transact`](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} instructions. [`RefundSurplus`](/builders/interoperability/xcm/core-concepts/instructions/#refund-surplus){target=\_blank} and [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank} can also be used to ensure no assets get trapped, but they are technically optional. In the `build-remote-evm-call.js` file, add the following code: ```js title="build-remote-evm-call.js" import { ApiPromise, WsProvider } from '@polkadot/api'; import { getTransactCall } from './build-batch-evm-call.js'; const originChainProviderWsURL = 'INSERT_ORIGIN_CHAIN_WSS_URL'; const computedOriginAccount = 'INSERT_COMPUTED_ORIGIN_ADDRESS'; export const getPolkadotXcmCall = async () => { // Create origin chain API provider const originChainProvider = new WsProvider(originChainProviderWsURL); const originChainAPI = await ApiPromise.create({ provider: originChainProvider, }); // Get the weight required to execute the Transact calldata const { transact, txWeight } = await getTransactCall(); // Create the extrinsic for the remote EVM call const sendXcm = originChainAPI.tx.polkadotXcm.send( { V4: { parents: 1, interior: { X1: [{ Parachain: 1000 }] } } }, { V4: [ { // Withdraw DEV asset (0.06) from the target account WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 60000000000000000n }, }, ], }, { // Buy execution with the DEV asset BuyExecution: { fees: { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 60000000000000000n }, }, weightLimit: 'Unlimited', }, }, { Transact: { originKind: 'SovereignAccount', requireWeightAtMost: { refTime: txWeight.refTime, proofSize: txWeight.proofSize, }, call: { encoded: transact.method.toHex(), }, }, }, { RefundSurplus: {}, }, { DepositAsset: { // Note that this must be AllCounted and not All, since All has too high of a gas requirement assets: { Wild: { AllCounted: 1 } }, beneficiary: { parents: 0, interior: { X1: [{ AccountKey20: { key: computedOriginAccount } }], }, }, }, }, ], } ); return sendXcm; }; ``` #### Build the Batch Extrinsic {: #build-batch-extrinsic } To ensure that both the `xTokens.transferMultiassets` and the `polkadotXcm.send` transactions are sent together, you can batch them together using `utility.batchAll`. This helps ensure that the asset transfer happens before the EVM transaction, which is a necessary distinction. Unfortunately, this is subject to change with future XCM updates. In the `send-batch-transaction.js` file, add the following code: ```js title="send-batch-transaction.js" import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; import { cryptoWaitReady } from '@polkadot/util-crypto'; import { getTransferMultiassetsCall } from './build-transfer-multiassets-call.js'; import { getPolkadotXcmCall } from './build-remote-evm-call.js'; const originChainProviderWsURL = 'INSERT_ORIGIN_CHAIN_WSS_URL'; const sendBatchTransaction = async () => { // Create origin chain API provider const originChainProvider = new WsProvider(originChainProviderWsURL); const originChainAPI = await ApiPromise.create({ provider: originChainProvider, }); // Create the batch transaction const batchTransaction = originChainAPI.tx.utility.batchAll([ await getTransferMultiassetsCall(), await getPolkadotXcmCall(), ]); // Create a keyring instance to sign the transaction await cryptoWaitReady(); const keyring = new Keyring({ type: 'ethereum' }); const account = keyring.addFromUri(privateKey); // Send the batch transaction const transaction = await batchTransaction.signAndSend(account, ({ status }) => { if (status.isInBlock) console.log(`Transaction sent!`); }); originChainAPI.disconnect(); return transaction; }; sendBatchTransaction(); ``` If you want to see an example project that fully implements this, an example is available in a [GitHub repository](https://github.com/jboetticher/mrl-mono){target=\_blank}. It's important to note that not every parachain will have X-Tokens and the other pallets implemented in a way that will allow this path. Substrate-based chains are very flexible, to the point where a standard doesn't exist. If you believe your parachain does not support this path, please provide an alternative solution in the [Moonbeam forum](https://forum.moonbeam.network){target=\_blank} and to the Wormhole team. ### Tokens Available Through Wormhole {: #tokens-available-through-wormhole } While Wormhole has the technical capability to bridge any token across chains, relayers will not support every token for fees. The ERC-20 assets that can be bridged through Wormhole's MRL solution depend on the tokens the [xLabs relayer](https://xlabs.xyz){target=\_blank} takes in. The tokens that are available to Moonbeam and Moonbase Alpha are listed in the table below: === "Moonbeam" | Token Name | Symbol | Decimals | Address | |:-----------------:|:------:|:--------:|:------------------------------------------:| | Wrapped AVAX | wAVAX | 18 | 0xd4937A95BeC789CC1AE1640714C61c160279B22F | | Wrapped Bitcoin | wBTC | 8 | 0xE57eBd2d67B462E9926e04a8e33f01cD0D64346D | | Wrapped BNB | wBNB | 18 | 0xE3b841C3f96e647E6dc01b468d6D0AD3562a9eeb | | Celo Native Asset | CELO | 18 | 0xc1a792041985F65c17Eb65E66E254DC879CF380b | | Dai Stablecoin | DAI | 18 | 0x06e605775296e851FF43b4dAa541Bb0984E9D6fD | | Wrapped Ethereum | wETH | 18 | 0xab3f0245B83feB11d15AAffeFD7AD465a59817eD | | Wrapped Fantom | wFTM | 18 | 0x609AedD990bf45926bca9E4eE988b4Fb98587D3A | | Wrapped GLMR | wGLMR | 18 | 0xAcc15dC74880C9944775448304B263D191c6077F | | Wrapped Matic | wMATIC | 18 | 0x82DbDa803bb52434B1f4F41A6F0Acb1242A7dFa3 | | Wrapped SOL | SOL | 9 | 0x99Fec54a5Ad36D50A4Bba3a41CAB983a5BB86A7d | | Sui | SUI | 9 | 0x484eCCE6775143D3335Ed2C7bCB22151C53B9F49 | | Tether USD | USDT | 6 | 0xc30E9cA94CF52f3Bf5692aaCF81353a27052c46f | | USDC (Wormhole) | USDC | 6 | 0x931715FEE2d06333043d11F658C8CE934aC61D0c | === "Moonbase Alpha" | Token Name | Symbol | Decimals | Address | |:------------------------:|:------:|:--------:|:------------------------------------------:| | Wrapped Avax | wAVAX | 18 | 0x2E8afeCC19842229358f3650cc3F091908dcbaB4 | | Wrapped BNB | wBNB | 18 | 0x6097E80331B0c6aF4F74D7F2363E70Cb2Fd078A5 | | Celo Native Asset | CELO | 18 | 0x3406a9b09adf0cb36DC04c1523C4b294C6b79513 | | Dai Stablecoin | DAI | 18 | 0xc31EC0108D8e886be58808B4C2C53f8365f1885D | | Wrapped Ether | wETH | 18 | 0xD909178CC99d318e4D46e7E66a972955859670E1 | | Wrapped Ether (Wormhole) | wETH | 18 | 0xd27d8883E31FAA11B2613b14BE83ad8951C8783C | | Wrapped Fantom | wFTM | 18 | 0x566c1cebc6A4AFa1C122E039C4BEBe77043148Ee | | Wrapped Matic | wMATIC | 18 | 0xD2888f015BcB76CE3d27b6024cdEFA16836d0dbb | | Sui | SUI | 9 | 0x2ed4B5B1071A3C676664E9085C0e3826542C1b27 | | USDC | USDC | 6 | 0x6533CE14804D113b1F494dC56c5D60A43cb5C3b5 | Please take the time to verify that these assets are still Wormhole assets on Moonbeam by using the [Wormhole asset verifier](https://portalbridge.com/#/token-origin-verifier){target=\_blank}.
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/core-concepts/instructions/ --- BEGIN CONTENT --- --- title: XCM Instructions description: When XCM instructions are combined, they form an XCM message that performs a cross-chain action. Take a look at some of the most common instructions. categories: XCM, Basics --- # XCM Instructions ## Introduction {: #introduction } XCM messages contain a series of [actions and instructions](https://github.com/paritytech/xcm-format#5-the-xcvm-instruction-set){target=\_blank} that are executed by the Cross-Consensus Virtual Machine (XCVM). An action (for example, transferring a token from one blockchain to another) consists of instructions that the XCVM partly executes in the origin and destination chains. For example, an XCM message that transfers DOT from Polkadot to Moonbeam will include the following XCM instructions (in that order), some of which are executed on Polkadot and some of which are executed on Moonbeam: 1. [TransferReserveAsset](#transfer-reserve-asset) — executed in Polkadot 2. [ReserveAssetDeposited](#reserve-asset-deposited) — executed in Moonbeam 3. [ClearOrigin](#clear-origin) — executed in Moonbeam 4. [BuyExecution](#buy-execution) — executed in Moonbeam 5. [DepositAsset](#deposit-asset) — executed in Moonbeam Building the instructions for an XCM message from scratch is not an easy task. Consequently, there are wrapper functions and pallets that developers can leverage to use XCM features. The [Polkadot XCM](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} and [XCM Transactor](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank} Pallets provide functions with a predefined set of XCM instructions to either send [XC-20s](/builders/interoperability/xcm/xc20/overview/){target=\_blank} or remotely execute on other chains via XCM. If you're interested in experimenting with different combinations of instructions, you can [use the Polkadot XCM Pallet to execute and send custom XCM messages](/builders/interoperability/xcm/send-execute-xcm/){target=\_blank}. This guide provides an overview of some of the most commonly used XCM instructions, including those in the above example. ## Buy Execution {: #buy-execution } The [`BuyExecution`](https://github.com/paritytech/xcm-format#buyexecution){target=\_blank} instruction typically gets executed in the target chain. It takes assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), to pay for execution fees. The target chain determines the fees to pay. ## Clear Origin {: #clear-origin } The [`ClearOrigin`](https://github.com/paritytech/xcm-format#clearorigin){target=\_blank} instruction gets executed in the target chain. It clears the origin of the XCM author, thereby ensuring that later XCM instructions cannot command the authority of the author. ## Deposit Asset {: #deposit-asset } The [`DepositAsset`](https://github.com/paritytech/xcm-format#depositasset){target=\_blank} instruction gets executed in the target chain. It removes the assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), and sends them to a destination account on the target chain. ## Descend Origin {: #descend-origin } The [`DescendOrigin`](https://github.com/paritytech/xcm-format#descendorigin){target=\_blank} instruction gets executed in the target chain. It mutates the origin on the target chain to match the origin on the source chain, ensuring execution on the target chain occurs on behalf of the same entity initiating the XCM message on the source chain. ## Initiate Reserve Withdraw {: #initiate-reserve-withdraw } The [`InitiateReserveWithdraw`](https://github.com/paritytech/xcm-format#initiatereservewithdraw){target=\_blank} instruction gets executed in the source chain. It removes the assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), (essentially burning them), and sends an XCM message to the reserve chain starting with the `WithdrawAsset` instruction. ## Refund Surplus {: #refund-surplus } The [`RefundSurplus`](https://github.com/paritytech/xcm-format#refundsurplus){target=\_blank} instruction typically gets executed in the target chain after the XCM is processed. This instruction will take any leftover assets from the `BuyExecution` instruction and put the assets into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). ## Reserve Asset Deposited {: #reserve-asset-deposited } The [`ReserveAssetDeposited`](https://github.com/paritytech/xcm-format#reserveassetdeposited-){target=\_blank} instruction gets executed in the target chain. It takes a representation of the assets received in the Sovereign account and places them into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). ## Set Appendix {: #set-appendix } The [`SetAppendix`](https://github.com/paritytech/xcm-format#setappendix){target=\_blank} instruction gets executed in the target chain. It sets the appendix register, which holds code that should be run after the current execution is finished. ## Transfer Reserve Asset {: #transfer-reserve-asset } The [`TransferReserveAsset`](https://github.com/paritytech/xcm-format#transferreserveasset){target=\_blank} instruction gets executed in the reserve chain. It moves assets from the origin account and deposits them into a destination account on the target chain. It then sends an XCM message to the target chain with the `ReserveAssetDeposited` instruction, followed by the XCM instructions that are to be executed. ## Transact {: #transact } The [`Transact`](https://github.com/paritytech/xcm-format#transact){target=\_blank} instruction gets executed in the target chain. It dispatches encoded call data from a given origin, allowing for the execution of specific operations or functions on the target chain. ## Withdraw Asset {: #withdraw-asset } The [`WithdrawAsset`](https://github.com/paritytech/xcm-format#withdrawasset){target=\_blank} instruction can be executed in either the source or target chain. It removes assets and places them into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/core-concepts/multilocations/ --- BEGIN CONTENT --- --- title: XCM Multilocations description: Learn everything there is to know about multilocations, their role in XCM, and how to format a multilocation to target a specific point in the ecosystem. categories: XCM --- # Multilocations ## Introduction {: #introduction } A multilocation defines a specific point in the entire relay chain/parachain ecosystem relative to a given origin. It can be used to target a specific parachain, asset, account, or even a pallet inside a parachain. Multilocations follow a hierarchical structure, in which some locations are encapsulated within others. For example, a relay chain encapsulates all of the parachains that are connected to it. Similarly, a parachain encapsulates all of the pallets, accounts, and assets that exist within it. ![Hierarchy of multilocations](/images/builders/interoperability/xcm/core-concepts/multilocations/multilocations-1.webp) ## Defining a Multilocation {: #defining-a-multilocation } A multilocation contains two parameters: - `parents` - refers to how many "hops" up into a parent blockchain you need to take from a given origin. From the perspective of a parachain within the relay chain ecosystem, there can only be one parent, so the value for `parents` can only ever be `0` to represent the parachain or `1` to represent the relay chain. When defining universal locations that consider other consensus systems like Ethereum, `parents` can have higher values - `interior` - refers to how many fields you need to define the target point. From the relay chain, you can drill down to target a specific parachain, or account, asset, or pallet on that parachain. Since this downward movement can be more complex, [Junctions](#junctions) are used to represent the steps needed to reach the target location and are defined by `XN`, where `N` is the number of Junctions required. If no Junctions are required to define the target point, its value would be `Here` as opposed to `X1` For example, if you are targeting the relay chain specifically, you'll use `Here` since you aren't defining an account on the relay chain, a parachain, or a specific point within a parachain. On the flip side, if you're targeting an account on the relay chain, or a parachain, or a specific point within a parachain, you'll use one or more Junctions, as needed. ### Junctions {: #junctions } A Junction can be any of the following: - `Parachain` - describes a parachain using the parachain's ID ```js { Parachain: INSERT_PARACHAIN_ID } ``` - `AccountId32` - describes a 32-byte Substrate-style account. Accepts an optional `network` parameter, which can be one of the following: `Any`, `Named`, `Polkadot`, or `Kusama` ```js { AccountId32: { id: INSERT_ADDRESS, network: INSERT_NETWORK } } ``` - `AccountIndex64` - describes a 64-bit (8-byte) index for an account. Accepts an optional `network` parameter, which can be one of the following: `Any`, `Named`, `Polkadot`, or `Kusama` ```js { AccountIndex64: { index: INSERT_ACCOUNT_INDEX, network: INSERT_NETWORK } } ``` - `AccountKey20` - describes a 20-byte Ethereum-style account, as is used in Moonbeam. Accepts an optional `network` parameter, which can be one of the following: `Any`, `Named`, `Polkadot`, or `Kusama` ```js { AccountKey20: { key: INSERT_ADDRESS, network: INSERT_NETWORK } } ``` - `PalletInstance` - describes the index of a pallet on the target chain ```js { PalletInstance: INSERT_PALLET_INSTANCE_INDEX } ``` - `GeneralIndex` - describes a nondescript index that can be used to target data stored in a key-value format ```js { GeneralIndex: INSERT_GENERAL_INDEX } ``` - `GeneralKey` - describes a nondescript key that can be used to target more complex data structures. This requires you to specify the `data` and the `length` of the data ```js { GeneralKey: { length: INSERT_LENGTH_OF_DATA, data: [INSERT_DATA] } } ``` - `OnlyChild` - describes the child of a location if there is only a one-to-one relation between the parent and child. This is currently not used except as a fallback when deriving context - `Plurality` - describes multiple elements that meet specific conditions or share common characteristics. This requires you to specify the [Body ID](https://github.com/paritytech/polkadot-sdk/blob/{{ polkadot_sdk }}/polkadot/xcm/src/v3/junction.rs#L150-L176){target=\_blank} and the [Body Part](https://github.com/paritytech/polkadot-sdk/blob/{{ polkadot_sdk }}/polkadot/xcm/src/v3/junction.rs#L222-L251){target=\_blank} that the Junction represents ```js { Plurality: { id: INSERT_BODY_ID, part: INSERT_BODY_PART } } ``` When using Junctions, you'll use `XN`, where `N` is the number of Junctions required to reach the target location. For example, if you're targeting an account on Moonbeam from a parachain, `parents` needs to be set to `1`, and you'll need to define two Junctions, the `Parachain` and the `AccountKey20`, so you'll use `X2`, which is an array that will contain each Junction: ```js { parents: 1, interior: { X2: [ { Parachain: 2004 }, { AccountKey20: { key: 'INSERT_MOONBEAM_ADDRESS' } }, ], }, }; ``` ## Example Multilocations {: #example-multilocations } ### Target Moonbeam from Another Parachain {: #target-moonbeam-from-parachain } To target a Moonbeam-based chain from another parachain, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: { X1: [{ Parachain: 2004 }], }, }; ``` === "Moonriver" ```js { parents: 1, interior: { X1: [{ Parachain: 2023 }], }, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: { X1: [{ Parachain: 1000 }], }, }; ``` ### Target an Account on Moonbeam from Another Parachain {: #target-account-moonbeam-from-parachain } To target a specific account on a Moonbeam-based chain from another parachain, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: { X2: [ { Parachain: 2004 }, { AccountKey20: { key: 'INSERT_MOONBEAM_ADDRESS' } }, ], }, }; ``` === "Moonriver" ```js { parents: 1, interior: { X2: [ { Parachain: 2023 }, { AccountKey20: { key: 'INSERT_MOONBEAM_ADDRESS' } }, ], }, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: { X2: [ { Parachain: 1000 }, { AccountKey20: { key: 'INSERT_MOONBEAM_ADDRESS' } }, ], }, }; ``` ### Target Moonbeam's Native Asset from Another Parachain {: #target-moonbeam-native-asset-from-parachain } To target the native asset of a Moonbeam-based chain from another parachain, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: { X2: [ { Parachain: 2004 }, { PalletInstance: 10 }, // Index of the Balances Pallet on Moonbeam ], }, }; ``` === "Moonriver" ```js { parents: 1, interior: { X2: [ { Parachain: 2023 }, { PalletInstance: 10 }, // Index of the Balances Pallet on Moonriver ], }, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: { X2: [ { Parachain: 1000 }, { PalletInstance: 3 }, // Index of the Balances Pallet on Moonbase Alpha ], }, }; ``` ### Target Moonbeam from the Relay Chain {: #target-moonbeam-from-relay } To target a Moonbeam-based chain from the relay chain, you would use the following multilocation: === "Moonbeam" ```js { parents: 0, interior: { X1: [{ Parachain: 2004 }], }, }; ``` === "Moonriver" ```js { parents: 0, interior: { X1: [{ Parachain: 2023 }], }, }; ``` === "Moonbase Alpha" ```js { parents: 0, interior: { X1: [{ Parachain: 1000 }], }, }; ``` ### Target the Relay Chain from Moonbeam {: #target-relay-from-moonbeam } To target the relay chain from a Moonbeam-based chain, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: Here, }; ``` === "Moonriver" ```js { parents: 1, interior: Here, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: Here, }; ``` ### Target an Account on the Relay Chain from Moonbeam {: #target-account-relay-from-moonbeam } To target a specific account on the relay chain, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: { X1: { AccountId32: { id: INSERT_RELAY_ADDRESS } } }, }; ``` === "Moonriver" ```js { parents: 1, interior: { X1: { AccountId32: { id: INSERT_RELAY_ADDRESS } } }, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: { X1: { AccountId32: { id: INSERT_RELAY_ADDRESS } } }, }; ``` ### Target Another Parachain from Moonbeam {: #target-parachain-from-moonbeam } To target another parachain (for example, a parachain that has an ID of 1234) from Moonbeam, you would use the following multilocation: === "Moonbeam" ```js { parents: 1, interior: { X1: [{ Parachain: 1234 }], }, }; ``` === "Moonriver" ```js { parents: 1, interior: { X1: [{ Parachain: 1234 }], }, }; ``` === "Moonbase Alpha" ```js { parents: 1, interior: { X1: [{ Parachain: 1234 }], }, }; ``` ### Location to Account API {: #location-to-account-api } The Location to Account API is an easy way to convert a multilocation into an `AccountID20` address. The Location to Account API can be accessed from the [Runtime Calls](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/runtime){target=\_blank} tab of the **Developer** section of Polkadot.js Apps. The `convertLocation` method of the Location to Account API takes a multilocation as a parameter and returns an `AccountID20` address. ```javascript // Query the locationToAccountApi using convertLocation method const result = await api.call.locationToAccountApi.convertLocation(multilocation); console.log('Conversion result:', result.toHuman()); ``` You can view the complete script below. ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); // Define the multilocation parameter const multilocation = { V4: { parents: 1, interior: 'Here', }, }; // Query the locationToAccountApi using convertLocation method const result = await api.call.locationToAccountApi.convertLocation(multilocation); console.log('Conversion result:', result.toHuman()); // Disconnect the API await api.disconnect(); }; main().catch(console.error); ``` The method will return the `AccountID20` address corresponding to the provided multilocation as follows: ```bash Conversion result: { Ok: '0x506172656E740000000000000000000000000000' } ``` --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/core-concepts/sovereign-accounts/ --- BEGIN CONTENT --- --- title: Sovereign Accounts and Reserve-Backed Transfers description: Discover how sovereign accounts work on Moonbeam, how to calculate them, and their role in cross-chain asset transfers. categories: XCM --- # Overview of Sovereign Accounts ## Introduction {: #introduction } In Polkadot-based ecosystems, a sovereign account is a unique, keyless account controlled by a blockchain’s runtime through XCM rather than an individual or organization. These accounts are used to store assets when transferring tokens cross-chain. For example, if you send a reserve tokens transfer from a parachain to Moonbeam, the originating parachain locks those tokens in Moonbeam’s sovereign account on the source chain, while a wrapped representation of those tokens is minted on Moonbeam. Sovereign accounts play a central role in [reserve-backed transfers](https://wiki.polkadot.com/learn/learn-xcm-usecases/#reserve-asset-transfer){target=\_blank}, where one chain (the “reserve”) holds the real assets and other chains hold derivative tokens. When tokens move across chains, the reserve (or origin) chain locks or unlocks the underlying asset, and derivative tokens are minted or burned on the destination chain. ## Calculating a Parachain Sovereign Account {: #calculating-sovereign } You can calculate a parachain’s sovereign account on a given relay chain using the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} repository. This is especially useful when you need to verify where underlying tokens are locked or to fund a parachain’s sovereign account directly. 1. Clone or navigate to the [xcm-tools repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} 2. Use the `calculate-sovereign-account` script, specifying the **Parachain ID** with the `--p` flag and the relay chain with the `--r` flag (default is `polkadot`; other accepted values are `kusama` or `moonbase`) The parachain ID you need can be found on the respective relay chain’s [Polkadot.js Apps **Parachains** page](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frelay.api.moonbase.moonbeam.network#/parachains){target=\_blank}. The **Parachains** page can be accessed under the **Network** dropdown. For example, to calculate the sovereign account address for parachain `1000` on the Moonbase Alpha testnet: ```bash yarn calculate-sovereign-account --p 1000 --r moonbase ``` Running the script will generate output like the following:
yarn calculate-sovereign-account --p 1000 --r moonbase yarn run v1.22.22 $ ts-node 'scripts/calculate-sovereign-account.ts' --p 1000 --r moonbase Sovereign Account Address on Relay: 0x70617261e8030000000000000000000000000000000000000000000000000000 Sovereign Account Address on other Parachains (Generic): 0x7369626ce8030000000000000000000000000000000000000000000000000000 Sovereign Account Address on Moonbase Alpha: 0x7369626ce8030000000000000000000000000000
The relay address is how the Polkadot or Kusama relay chain references the sovereign account. Generic parachain address is typically used for referencing this parachain’s sovereign account from other parachains. The Moonbase Alpha address is the corresponding sovereign account in the H160 EVM address format used by Moonbase Alpha. ## Learn More {: #learn-more } Sovereign accounts form the backbone of reserve-backed transfers, enabling safe custody of assets for minting wrapped tokens across Polkadot’s ecosystem. By combining sovereign accounts with the XCM framework, parachains can interoperate seamlessly—locking and unlocking assets in a transparent, trust-minimized way. For more information about how sovereign accounts facilitate cross-chain transfers with XCM, be sure to check out the [Send XC-20s section](/builders/interoperability/xcm/xc20/send-xc20s/overview/){target=\_blank}. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/core-concepts/weights-fees/ --- BEGIN CONTENT --- --- title: XCM Execution Fees description: Learn about the XCM instructions involved in handling XCM execution fee payments and how to calculate fees on Polkadot, Kusama, and Moonbeam-based networks. categories: XCM --- # XCM Fees on Moonbeam ## Introduction {: #introduction} XCM aims to be a language that communicates ideas between consensus systems. Sending an XCM message consists of a series of instructions that are executed in both the origin and the destination chains. The combination of XCM instructions results in actions such as token transfers. In order to process and execute each XCM instruction, there are typically associated fees that must be paid. However, XCM is designed to be general, extensible, and efficient so that it remains valuable and future-proof throughout a growing ecosystem. As such, the generality applies to concepts including payments of fees for XCM execution. In Ethereum, fees are baked into the transaction protocol, whereas in the Polkadot ecosystem, each chain has the flexibility to define how XCM fees are handled. This guide will cover aspects of fee payment, such as who is responsible for paying XCM execution fees, how it is paid for, and how the fees are calculated on Moonbeam. !!! note **The following information is provided for general information purposes only.** The weight and extrinsic base cost might have changed since the time of writing. Please ensure you check the actual values, and never use the following information for production apps. ## Payment of Fees {: #payment-of-fees } Generally speaking, the fee payment process can be described as follows: 1. Some assets need to be provided 2. The exchange of assets for computing time (or weight) must be negotiated 3. The XCM operations will be performed as instructed, with the provided weight limit or funds available for execution Each chain can configure what happens with the XCM fees and in which tokens they can be paid (either the native reserve token or an external one). For example: - **Polkadot and Kusama** - the fees are paid in DOT or KSM (respectively) and given to the validator of the block - **Moonbeam and Moonriver** - the XCM execution fees can be paid in the reserve asset (GLMR or MOVR, respectively), but also in assets originated in other chains if they are registered as an [XCM execution asset](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank}. When XCM execution (token transfers or remote execution) is paid in the native chain reserve asset (GLMR or MOVR), {{ networks.moonbeam.treasury.tx_fees_burned }}% is burned. When XCM execution is paid in a foreign asset, the fee is sent to the Treasury Consider the following scenario: Alice has some DOT on Polkadot, and she wants to transfer it to Alith on Moonbeam. She sends an XCM message with a set of XCM instructions that will retrieve a given amount of DOT from her account on Polkadot and mint them as xcDOT into Alith's account. Part of the instructions are executed on Polkadot, and the other part is executed on Moonbeam. How does Alice pay Moonbeam to execute these instructions and fulfill her request? Her request is fulfilled through a series of XCM instructions that are included in the XCM message, which enables her to buy execution time minus any related XCM execution fees. The execution time is used to issue and transfer xcDOT, a representation of DOT on Moonbeam. This means that when Alice sends some DOT to Alith's account on Moonbeam, she'll receive a 1:1 representation of her DOT as xcDOT minus any XCM execution fees. Note that in this scenario, XCM execution fees are paid in xcDOT and sent to the treasury. The exact process for Alice's transfer is as follows: 1. Assets are sent to an account on Polkadot that is owned by Moonbeam, known as the Sovereign account. After the assets are received, an XCM message is sent to Moonbeam 2. The XCM message in Moonbeam will: 1. Mint the corresponding asset representation 2. Buy the corresponding execution time 3. Use that execution time to deposit the representation (minus fees) to the destination account ### XCM Instructions {: #xcm-instructions } An XCM message is comprised of a series of XCM instructions. As a result, different combinations of XCM instructions result in different actions. For example, to move DOT to Moonbeam, the following XCM instructions are used: When DOT is transferred from Polkadot to Moonbeam, the following XCM instructions are executed in sequence: 1. [`TransferReserveAsset`](/builders/interoperability/xcm/core-concepts/instructions/#transfer-reserve-asset){target=_blank} - executes on Polkadot, moving the DOT from the sender and depositing it into Moonbeam’s Sovereign account on Polkadot 2. [`ReserveAssetDeposited`](/builders/interoperability/xcm/core-concepts/instructions/#reserve-asset-deposited){target=_blank} - executes on Moonbeam, minting the corresponding ERC-20 representation of DOT (xcDOT) on Moonbeam 3. [`ClearOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#clear-origin){target=_blank} - executes on Moonbeam, clearing any origin data—previously set to Polkadot’s Sovereign account 4. [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=_blank} - executes on Moonbeam, determining the execution fees. Here, a portion of the newly minted xcDOT is used to pay the cost of XCM 5. [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=_blank} - executes on Moonbeam, delivering the xcDOT to the intended recipient’s account on Moonbeam To check how the instructions for an XCM message are built to transfer self-reserve assets to a target chain, such as DOT to Moonbeam, you can refer to the [X-Tokens Open Runtime Module Library](https://github.com/moonbeam-foundation/open-runtime-module-library/blob/master/xtokens/src/lib.rs){target=\_blank} repository (as an example). You'll want to take a look at the [`transfer_self_reserve_asset`](https://github.com/moonbeam-foundation/open-runtime-module-library/blob/master/xtokens/src/lib.rs#L699){target=\_blank} function. You'll notice it calls `TransferReserveAsset` and passes in `assets`, `dest`, and `xcm` as parameters. In particular, the `xcm` parameter includes the `BuyExecution` and `DepositAsset` instructions. If you then head over to the Polkadot GitHub repository, you can find the [`TransferReserveAsset` instruction](https://github.com/paritytech/polkadot-sdk/blob/{{ polkadot_sdk }}/polkadot/xcm/xcm-executor/src/lib.rs#L671){target=\_blank}. The XCM message is constructed by combining the `ReserveAssetDeposited` and `ClearOrigin` instructions with the `xcm` parameter, which as mentioned includes the `BuyExecution` and `DepositAsset` instructions. In scenarios where you want to move an asset back to its reserve chain, such as sending xcDOT from Moonbeam to Polkadot, Moonbeam uses the following set of XCM instructions: 1. [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=_blank} – executes on Moonbeam, taking the specified token (xcDOT) from the sender 2. [`InitiateReserveWithdraw`](/builders/interoperability/xcm/core-concepts/instructions/#initiate-reserve-withdraw){target=_blank} – executes on Moonbeam, which, burns the token on Moonbeam (removing the wrapped representation), and sends an XCM message to Polkadot, indicating the tokens should be released there 3. [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=_blank} – executes on Polkadot, removing the tokens from Moonbeam’s Sovereign account on Polkadot 4. [`ClearOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#clear-origin){target=_blank} – gets executed on Polkadot. Clears any origin data (e.g., the Sovereign account on Moonbeam) 5. [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=_blank} – Polkadot determines the execution fees and uses part of the DOT being transferred to pay for them 6. [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=_blank} – finally, the native DOT tokens are deposited into the specified Polkadot account To check how the instructions for an XCM message are built to transfer reserve assets to a target chain, such as xcDOT to Polkadot, you can refer to the [X-Tokens Open Runtime Module Library](https://github.com/moonbeam-foundation/open-runtime-module-library/tree/master/xtokens){target=\_blank} repository. You'll want to take a look at the [`transfer_to_reserve`](https://github.com/moonbeam-foundation/open-runtime-module-library/blob/master/xtokens/src/lib.rs#L719){target=\_blank} function. You'll notice that it calls `WithdrawAsset`, then `InitiateReserveWithdraw` and passes in `assets`, `dest`, and `xcm` as parameters. In particular, the `xcm` parameter includes the `BuyExecution` and `DepositAsset` instructions. If you then head over to the Polkadot GitHub repository, you can find the [`InitiateReserveWithdraw` instruction](https://github.com/paritytech/polkadot-sdk/blob/{{polkadot_sdk}}/polkadot/xcm/xcm-executor/src/lib.rs#L903){target=\_blank}. The XCM message is constructed by combining the `WithdrawAsset` and `ClearOrigin` instructions with the `xcm` parameter, which as mentioned includes the `BuyExecution` and `DepositAsset` instructions. ## Relay Chain XCM Fee Calculation {: #rel-chain-xcm-fee-calc } Substrate has introduced a weight system that determines how heavy or, in other words, how expensive from a computational cost perspective an extrinsic is. One unit of weight is defined as one picosecond of execution time. When it comes to paying fees, users will pay a transaction fee based on the weight of the call that is being made, in addition to factors such as network congestion. The following sections will break down how to calculate XCM fees for Polkadot and Kusama. It's important to note that Kusama, in particular, uses benchmarked data to determine the total weight costs for XCM instructions and that some XCM instructions might include database reads and writes, which add weight to the call. There are two databases available in Polkadot and Kusama: RocksDB (which is the default) and ParityDB, both of which have their own associated weight costs for each network. ### Polkadot {: #polkadot } The total weight costs on Polkadot take into consideration database reads and writes in addition to the weight required for a given instruction. Polkadot uses benchmarked weights for instructions, and database read-and-write operations. The breakdown of weight costs for the database operations can be found on the respective repository files for [RocksDB (default)](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.polkadot.spec_version }}/relay/polkadot/constants/src/weights/rocksdb_weights.rs){target=\_blank} and [ParityDB](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.polkadot.spec_version }}/relay/polkadot/constants/src/weights/paritydb_weights.rs){target=\_blank}. Now that you are aware of the weight costs for database reads and writes on Polkadot, you can calculate the weight cost for a given instruction using the base weight for instructions. On Polkadot, the benchmarked base weights are broken up into two categories: fungible and generic. Fungible weights are for XCM instructions that involve moving assets, and generic weights are for everything else. You can view the current weights for [fungible assets](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.polkadot.spec_version }}/relay/polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs#L46){target=\_blank} and [generic assets](https://github.com/polkadot-fellows/runtimes/blob/{{networks.polkadot.spec_version}}/relay/polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs#L46){target=\_blank} directly in the Polkadot Runtime code. With the instruction weight cost established, you can calculate the cost of each instruction in DOT. In Polkadot, the [`ExtrinsicBaseWeight`](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.polkadot.spec_version }}/relay/polkadot/constants/src/weights/extrinsic_weights.rs#L56){target=\_blank} is set to `{{ networks.polkadot.extrinsic_base_weight.display }}` which is [mapped to 1/10th](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.polkadot.spec_version }}/relay/polkadot/constants/src/lib.rs#L92){target=\_blank} of a cent. Where 1 cent is `10^10 / 100`. Therefore, to calculate the cost of executing an XCM instruction, you can use the following formula: ```text XCM-DOT-Cost = XCMInstrWeight * DOTWeightToFeeCoefficient ``` Where `DOTWeightToFeeCoefficient` is a constant (map to 1 cent), and can be calculated as: ```text DOTWeightToFeeCoefficient = 10^10 / ( 10 * 100 * DOTExtrinsicBaseWeight ) ``` Now, you can begin to calculate the final fee in DOT, using `DOTWeightToFeeCoefficient` as a constant and `TotalWeight` as the variable: ```text XCM-Planck-DOT-Cost = TotalWeight * DOTWeightToFeeCoefficient XCM-DOT-Cost = XCM-Planck-DOT-Cost / DOTDecimalConversion ``` ### Kusama {: #kusama } The total weight costs on Kusama take into consideration database reads and writes in addition to the weight required for a given instruction. The breakdown of weight costs for the database operations can be found on the respective repository files for [RocksDB (default)](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.kusama.spec_version }}/relay/kusama/constants/src/weights/rocksdb_weights.rs){target=\_blank} and [ParityDB](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.kusama.spec_version }}/relay/kusama/constants/src/weights/paritydb_weights.rs){target=\_blank}. On Kusama, the benchmarked base weights are broken up into two categories: fungible and generic. Fungible weights are for XCM instructions that involve moving assets, and generic weights are for everything else. You can view the current weights for [fungible assets](https://github.com/polkadot-fellows/runtimes/blob/{{ networks.kusama.spec_version }}/relay/kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs#L46){target=\_blank} and [generic assets](https://github.com/polkadot-fellows/runtimes/blob/{{networks.kusama.spec_version}}/relay/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs#L46){target=\_blank} directly in the Kusama Runtime code. With the instruction weight cost established, you can calculate the cost of the instruction in KSM with the [`ExtrinsicBaseWeight`](https://github.com/polkadot-fellows/runtimes/blob/{{networks.kusama.spec_version}}/relay/kusama/constants/src/weights/extrinsic_weights.rs#L56){target=\_blank} and the [weight fee mapping](https://github.com/polkadot-fellows/runtimes/blob/{{networks.kusama.spec_version}}/relay/kusama/constants/src/lib.rs#L90){target=\_blank}. To calculate the cost of executing an XCM instruction, you can use the following formula: ```text XCM-KSM-Cost = XCMInstrWeight * KSMWeightToFeeCoefficient ``` Where `KSMWeightToFeeCoefficient` is a constant (map to 1 cent), and can be calculated as: ```text KSMWeightToFeeCoefficient = 10^12 / ( 10 * 3000 * KSMExtrinsicBaseWeight ) ``` Now, you can begin to calculate the final fee in KSM, using `KSMWeightToFeeCoefficient` as a constant and `TotalWeight` as the variable: ```text XCM-Planck-KSM-Cost = TotalWeight * KSMWeightToFeeCoefficient XCM-KSM-Cost = XCM-Planck-KSM-Cost / KSMDecimalConversion ``` ## Moonbeam-based Networks XCM Fee Calculation {: #moonbeam-xcm-fee-calc } Substrate has introduced a weight system that determines how heavy or, in other words, how expensive an extrinsic is from a computational cost perspective. One unit of weight is defined as one picosecond of execution time. When it comes to paying fees, users will pay a transaction fee based on the weight of the call being made, and each parachain can decide how to convert weight to fee. For example, this may account for additional costs related to transaction size and storage. For all Moonbeam-based networks, the generic XCM instructions are benchmarked, while the fungible XCM instructions still use a fixed amount of weight per instruction. Consequently, the total weight cost of the benchmarked XCM instructions considers the number of database reads and writes in addition to the weight required for a given instruction. The Polkadot SDK has a breakdown of the relevant [RocksDB database weights](https://github.com/paritytech/polkadot-sdk/blob/{{polkadot_sdk}}/substrate/frame/support/src/weights/rocksdb_weights.rs#L27-L28){target=\_blank}. Now you can calculate the weight cost for both fungible and generic XCM instructions using the base weight for instruction and the extra database reads and writes if applicable. For example, the `WithdrawAsset` instruction is part of the fungible XCM instructions. Therefore, it is not benchmarked, and the total weight cost of the [`WithdrawAsset` instruction](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbeam.spec_version }}/runtime/moonbeam/src/weights/xcm/fungible.rs#L36){target=\_blank} is `{{ xcm.fungible_weights.display }}`, except for when transferring local XC-20s. The total weight cost for the `WithdrawAsset` instruction for local XC-20s is based on converting Ethereum gas to Substrate weight. The `BuyExecution` instruction is generic and therefore has a predefined benchmarked weight. You can view its current base weight in the [Moonbeam runtime source code](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbeam.spec_version }}/runtime/moonbeam/src/weights/xcm/generic.rs#L132-L133){target=\_blank}. In addition to the base weight, the instruction performs four database reads, which are added to calculate the total weight. You can find all the weight values for all the XCM instructions in the following table, which apply to all Moonbeam-based networks: | Benchmarked Instructions | Non-Benchmarked Instructions | |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [Generic XCM Instructions](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbeam.spec_version }}/runtime/moonbeam/src/weights/xcm/generic.rs){target=\_blank} | [Fungible XCM Instructions](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbeam.spec_version }}/runtime/moonbeam/src/weights/xcm/fungible.rs){target=\_blank} | The following sections will break down how to calculate XCM fees for Moonbeam-based networks. There are two main scenarios: - Fees paid in the reserve token (native tokens like GLMR, MOVR, or DEV) - Fees paid in external assets (XC-20s) ### Fee Calculation for Reserve Assets {: #moonbeam-reserve-assets } For each XCM instruction, the weight units are converted to balance units as part of the fee calculation. The amount of Wei per weight unit for each of the Moonbeam-based networks is as follows: | Moonbeam | Moonriver | Moonbase Alpha | |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [{{ networks.moonbeam.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbeam.spec_version}}/runtime/moonbeam/src/lib.rs#L163){target=\_blank} | [{{ networks.moonriver.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonriver.spec_version}}/runtime/moonriver/src/lib.rs#L171){target=\_blank} | [{{ networks.moonbase.xcm.instructions.wei_per_weight.display }}](https://github.com/moonbeam-foundation/moonbeam/blob/{{networks.moonbase.spec_version}}/runtime/moonbase/src/lib.rs#L169){target=\_blank} | This means that on Moonbeam, for example, the formula to calculate the cost of one XCM instruction in the reserve asset is as follows: ```text XCM-Wei-Cost = XCMInstrWeight * WeiPerWeight XCM-GLMR-Cost = XCM-Wei-Cost / 10^18 ``` Therefore, the actual calculation for fungible instructions, for example, is: ```text XCM-Wei-Cost = {{ xcm.fungible_weights.numbers_only }} * {{ networks.moonbeam.xcm.instructions.wei_per_weight.numbers_only }} XCM-GLMR-Cost = {{ networks.moonbeam.xcm.transfer_glmr.wei_cost }} / 10^18 ``` The total cost is `{{ networks.moonbeam.xcm.transfer_glmr.glmr_cost }} GLMR` for an XCM instruction on Moonbeam. ### Fee Calculation for External Assets {: #fee-calc-external-assets } Moonbeam charges fees for external assets based on the weight of the call. Weight is a struct that contains two fields, `refTime` and `proofSize`. `refTime` refers to the amount of computational time that can be used for execution. `proofSize` refers to the size of the PoV (Proof of Validity) of the Moonbeam block that gets submitted to the Polkadot Relay Chain for validation. Since both `refTime` and `proofSize` are integral components of determining a weight, it is impossible to obtain an accurate weight value with just one of these values. You can query the `refTime` and `proofSize` of an XCM instruction with the [`queryXcmWeight` method of the `xcmPaymentApi`](#query-xcm-weight). You can do this [programmatically](#query-xcm-weight) or by visiting the [Runtime Calls tab of Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmoonbeam.api.onfinality.io%2Fpublic-ws#/runtime){target=\_blank}. The `queryXcmWeight` method takes an XCM version and instruction has a parameter and returns the corresponding `refTime` and `proofSize` values. #### Weight to Gas Mapping {: #weight-to-gas-mapping } For calls that are derived from EVM operations, such as the `DepositAsset` instruction which relies on the EVM operation `MintInto`, you can calculate their respective weight values by multiplying the gas limit by weight multipliers. For `refTime`, you'll need to multiply the gas limit by `{{ xcm.generic_weights.weight_per_gas.numbers_only }}` and for `proofSize` you'll need to multiply the gas limit by `{{ xcm.generic_weights.proof_size.weight_per_gas }}`. A chart is included below for convenience. | Weight Type | Multiplier Value | |:-----------:|:---------------------------------------------------:| | Ref Time | {{ xcm.generic_weights.weight_per_gas.display }} | | Proof Size | {{ xcm.generic_weights.proof_size.weight_per_gas }} | To determine the total weight for Alice's transfer of DOT to Moonbeam, you'll need the weight for each of the four XCM instructions required for the transfer. Note that while the first three instructions have specific `refTime` and `proofSize` values corresponding to these instructions that can be retrieved via [`queryXcmWeight` method of the `xcmPaymentApi`](#query-xcm-weight), `DepositAsset` relies on the EVM operation [`MintInto`](https://github.com/moonbeam-foundation/moonbeam/blob/{{ networks.moonbeam.spec_version }}/pallets/moonbeam-foreign-assets/src/evm.rs#L40){target=\_blank} and a `WeightPerGas` conversion of `{{ xcm.generic_weights.weight_per_gas.display }}` per gas. The `refTime` of `DepositAsset` can thus be calculated as: ```text {{ xcm.generic_weights.ref_time.mint_into_gas.numbers_only }} gas * {{ xcm.generic_weights.weight_per_gas.numbers_only }} weight per gas = {{ xcm.generic_weights.ref_time.deposit_asset.numbers_only }} ``` And the `proofSize` of `DepositAsset` can be calculated as: ```text {{ xcm.generic_weights.ref_time.mint_into_gas.numbers_only }} gas * {{ xcm.generic_weights.proof_size.weight_per_gas }} weight per gas = {{ xcm.generic_weights.proof_size.deposit_asset.numbers_only }} ``` ### Weight to Asset Fee Conversion {: #weight-to-asset-fee-conversion} Once you have the sum of the `refTime` and `proofSize` values, you can easily retrieve the required commensurate fee amount. The [`queryWeightToAssetFee` method of the `xcmPaymentApi`](#weight-to-asset-fee-conversion) takes a `refTime`, `proofSize`, and asset multilocation as parameters and returns the commensurate fee. By providing the amounts obtained above of `{{ networks.moonbeam.xcm.transfer_dot.total_weight.display }}` `refTime` and `{{ xcm.generic_weights.proof_size.transfer_dot_total.display }}` `proofSize`, and the asset multilocation for DOT, we get a fee amount of `88,920,522` Plank, which is the smallest unit in Polkadot. We can convert this to DOT by dividing by `10^10` which gets us a DOT fee amount of `{{ networks.moonbeam.xcm.transfer_dot.xcdot_cost }}` DOT. ## XCM Payment API Expanded Examples {: #xcm-payment-api-exanded-examples } The XCM Payment API methods provide various helpful ways to calculate fees, evaluate acceptable fee payment currencies, and more. Remember that in addition to accessing this via API, you can also interact with the XCM Payment API via the [Runtime Calls tab of Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmoonbeam.api.onfinality.io%2Fpublic-ws#/runtime){target=\_blank}. ### Query Acceptable Fee Payment Assets {: #query-acceptable-fee-payment-assets } This function takes the XCM Version as a parameter and returns a list of acceptable fee assets in multilocation form. ```javascript const allowedAssets = await api.call.xcmPaymentApi.queryAcceptablePaymentAssets(3); console.log(allowedAssets); ``` ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); const allowedAssets = await api.call.xcmPaymentApi.queryAcceptablePaymentAssets(4); console.log(allowedAssets); // Disconnect the API await api.disconnect(); }; main(); ``` ### Weight to Asset Fee Conversion {: #weight-to-asset-fee-conversion } This method converts a weight into a fee for the specified asset. It takes as parameters a weight and an asset multilocation and returns the respective fee amount. ```javascript const fee = await api.call.xcmPaymentApi.queryWeightToAssetFee( { refTime: 10_000_000_000n, proofSize: 0n, }, { V3: { Concrete: { parents: 1, interior: 'Here' }, }, } ); console.log(fee); ``` ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); const fee = await api.call.xcmPaymentApi.queryWeightToAssetFee( { refTime: 10_000_000_000n, proofSize: 0n, }, { V3: { Concrete: { parents: 1, interior: 'Here' }, }, } ); console.log(fee); // Disconnect the API await api.disconnect(); }; main(); ``` ### Query XCM Weight {: #query-xcm-weight} This method takes an XCM message as a parameter and returns the weight of the message. ```javascript const message = { V3: [instr1, instr2] }; const theWeight = await api.call.xcmPaymentApi.queryXcmWeight(message); console.log(theWeight); ``` ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); const amountToSend = BigInt(1 * 10 ** 12); // Sending 1 token (assuming 12 decimal places) const assetMultiLocation = { parents: 0, interior: { X1: { PalletInstance: 3 } }, }; // The asset's location (adjust PalletInstance as needed) const recipientAccount = '0x1234567890abcdef1234567890abcdef12345678'; // The recipient's account on the destination chain // 2. XCM Destination (e.g., Parachain ID 2000) const dest = { V3: { parents: 1, interior: { X1: { Parachain: 2000 } } } }; // 3. XCM Instruction 1: Withdraw the asset from the sender const instr1 = { WithdrawAsset: [ { id: { Concrete: assetMultiLocation }, fun: { Fungible: amountToSend }, }, ], }; // 4. XCM Instruction 2: Deposit the asset into the recipient's account on the destination chain const instr2 = { DepositAsset: { assets: { Wild: 'All' }, // Sending all withdrawn assets (in this case, 1 token) beneficiary: { parents: 0, interior: { X1: { AccountKey20: { key: recipientAccount } } }, }, }, }; // 5. Build the XCM Message const message = { V3: [instr1, instr2] }; const theWeight = await api.call.xcmPaymentApi.queryXcmWeight(message); console.log(theWeight); // Disconnect the API await api.disconnect(); }; main(); ``` --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/overview/ --- BEGIN CONTENT --- --- title: Cross-Consensus Messaging (XCM) description: An overview of how cross-consensus messaging (XCM) works and how developers can leverage Polkadot/Kusama XCM to gain access to new assets. categories: Basics, XCM --- # Cross-Consensus Messaging (XCM) ## Introduction {: #introduction } [Polkadot's architecture](https://wiki.polkadot.com/learn/learn-architecture/){target=\_blank} allows parachains to natively interoperate with each other, enabling cross-blockchain transfers of any type of data or asset. To do so, a [Cross-Consensus Message (XCM)](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank} format defines a language around how the message transfer between two interoperating blockchains should be performed. XCM is not specific to Polkadot, as it aims to be a generic and extensible language between different consensus systems. This page is a brief introduction and overview of XCM and other related elements. More information can be found in [Polkadot's Wiki](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank}. If you want to jump to more XCM-related content, feel free to check out the following pages: - [**Core XCM Concepts**](/builders/interoperability/xcm/core-concepts/){target=\_blank} - learn topics related to [XCM Instructions](/builders/interoperability/xcm/core-concepts/instructions/){target=\_blank}, [Multilocations](/builders/interoperability/xcm/core-concepts/multilocations/){target=\_blank}, and [XCM Fees](/builders/interoperability/xcm/core-concepts/weights-fees/){target=\_blank} - [**XC Registration**](/builders/interoperability/xcm/xc-registration/){target=\_blank} - go through the process of [Opening an XCM Channel with Moonbeam](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} and how to [Register Polkadot Native Assets as XC-20s](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} - [**XC-20s**](/builders/interoperability/xcm/xc20/){target=\_blank} - read an [Overview](/builders/interoperability/xcm/xc20/overview/){target=\_blank} of this Moonbeam-only asset class and learn how to [Interact with XC-20s](/builders/interoperability/xcm/xc20/interact/){target=\_blank} and how to [Send them via XCM](/builders/interoperability/xcm/xc20/send-xc20s/){target=\_blank} - [**Remote Execution via XCM**](/builders/interoperability/xcm/remote-execution/){target=\_blank} - grasp all concepts related to remote execution via XCM, starting with a [High-Level Overview](/builders/interoperability/xcm/remote-execution/overview/){target=\_blank}, then [Computed Origins](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank} and wrapping up with [Remote Calls via XCM](/builders/interoperability/xcm/remote-execution/substrate-calls/){target=\_blank} and [Remote EVM Calls via XCM](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank} - [**XCM SDK**](https://moonbeam-foundation.github.io/xcm-sdk/latest/){target=\_blank} - learn how to [Use Moonbeam's XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm/){target=\_blank} - **XCM Debugging and Tools** - learn how to test some XCM scenarios by [Sending and Executing Generic XCM Messages](/builders/interoperability/xcm/send-execute-xcm/){target=\_blank}, or how to use the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank} to access XCM_related utility functions directly within the EVM ## General XCM Definitions {: #general-xcm-definitions } - **XCM** — stands for Cross-Consensus Message. It is a general way for consensus systems to communicate with each other - **VMP** — stands for Vertical Message Passing, one of the transport methods for XCMs. It allows parachains to exchange messages with the relay chain. *UMP* (Upward Message Passing) enables parachains to send messages to their relay chain, while *DMP* (Downward Message Passing) enables the relay chain to pass messages down to one of their parachains - **XCMP** — stands for Cross-Consensus Message Passing, one of the transport methods for XCMs. It allows parachains to exchange messages with other parachains on the same relay chain - **HRMP** — stands for Horizontal Relay-routed Message Passing, a stop-gap protocol while a full XCMP implementation is launched. It has the same interface as XCMP, but messages are stored on the relay chain - **Sovereign account** — an account each chain in the ecosystem has, one for the relay chain and the other for other parachains. It is calculated as the `blake2` hash of a specific word and parachain ID concatenated (`blake2(para+ParachainID)` for the Sovereign account in the relay chain, and `blake2(sibl+ParachainID)` for the Sovereign account in other parachains), truncating the hash to the correct length. The account is owned by root and can only be used through SUDO (if available) or [governance (referenda)](/learn/features/governance/){target=\_blank}. The Sovereign account typically signs XCM messages in other chains in the ecosystem - **Multilocation** — a way to specify a point in the entire relay chain/parachain ecosystem relative to a given origin. For example, it can be used to specify a specific parachain, asset, account, or even a pallet inside a parachain. In general terms, a multilocation is defined with a `parents` and an `interior`: - `parents` - refers to how many "hops" into a parent blockchain you need to take from a given origin - `interior` - refers to how many fields you need to define the target point. For example, to target a parachain with ID `1000` from another parachain, the multilocation would be `{ "parents": 1, "interior": { "X1": [{ "Parachain": 1000 }]}}` ## Cross-Chain Transport Protocols via XCM {: #xcm-transport-protocols } XCM implements two cross-consensus or transport protocols for acting on XCM messages between its constituent parachains, Moonbeam being one of them: - **Vertical Message Passing (VMP)** — once a project is onboarded as a parachain, it automatically has a bi-directional communication channel with the relay chain. Therefore, there is no need for chain registration. VMP is divided into two kinds of message-passing transport protocols: * **Upward Message Passing (UMP)** — allows parachains to send messages to their relay chain, for example, from Moonbeam to Polkadot * **Downward Message Passing (DMP)** — allows the relay chain to pass messages down to one of their parachains, for example, from Polkadot to Moonbeam - **Cross-Chain Message Passing (XCMP)** — allows two parachains to exchange messages as long as they are connected to the same relay chain. Cross-chain transactions are resolved using a simple queuing mechanism based on a Merkle tree to ensure fidelity. Collators exchange messages between parachains, while the relay chain validators will verify that the message transmission happened !!! note Currently, while XCMP is being developed, a stop-gap protocol is implemented called Horizontal Relay-routed Message Passing (HRMP), in which the messages are stored in and read from the relay chain. This will be deprecated in the future for the full XCMP implementation. ![Vertical Message Passing and Cross-chain Message Passing Overview](/images/builders/interoperability/xcm/overview/overview-1.webp) ## Establishing Cross-Chain Communication {: #channel-registration } Before two chains can start communicating, a messaging channel must be opened. Channels are unidirectional, meaning that a channel from chain A to chain B will only pass messages from A to B. Therefore, two channels must be opened to send messages back and forth. A channel for XCMs between the relay chain and parachain is automatically opened when a connection is established. However, when parachain A wants to open a communication channel with parachain B, parachain A must send an open channel extrinsic to its network. This extrinsic is an XCM as well! Even though parachain A has expressed its intentions of opening an XCM channel with parachain B, the latter has not signaled to the relay chain its intentions to receive messages from parachain A. Therefore, to have an established channel, parachain B must send an extrinsic (an XCM) to the relay chain. The accepting channel extrinsic is similar to the previous one. However, the encoded call data only includes the new method (accept channel) and the parachain ID of the sender (parachain A in this example). Once both parachains have agreed, the channel is opened within the following epoch. To learn more about the channel registration process, please refer to the [How to Establish an XC Integration with Moonbeam](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} guide. ![XCM Channel Registration Overview](/images/builders/interoperability/xcm/overview/overview-2.webp) Once the channel is established, cross-chain messages can be sent between parachains. For asset transfers, assets need to be registered before being transferred through XCMs, either by being baked into the runtime as a constant or through a pallet. Moonbeam relies on a Substrate pallet to handle asset registration without the need for runtime upgrades, making the process a lot simpler. To learn how to register an asset on Moonbeam and the information necessary to add Moonbeam assets to another chain, please refer to the [How to Register Cross-Chain Assets](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} guide. ## XCM on Moonbeam {: #moonbeam-and-xcm } As Moonbeam is a parachain within the Polkadot ecosystems, one of the most direct implementations of XCM is to enable asset transfer from Polkadot and other parachains from/to Moonbeam. This allows users to bring their tokens to Moonbeam and all its dApps. To this end, Moonbeam has introduced [XC-20s](/builders/interoperability/xcm/xc20/overview/){target=\_blank}, which expand on Moonbeam's unique Ethereum compatibility features. XC-20s allow Polkadot native assets to be represented via a standard [ERC-20 interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/assets-erc20/ERC20.sol){target=\_blank} through a precompiled contract. When these assets are registered on Moonbeam, they can be set as XCM execution fee assets. Consequently, when a user transfers such an asset to Moonbeam, a small part of the amount will be used to cover the XCM execution fees. In addition, ERC-20s that are deployed to Moonbeam can be sent to other chains in the Polkadot ecosystem via XCM. Consequently, from a developer's perspective, XC-20s are ERC-20 tokens with the added benefit of being an XCM cross-chain asset, and dApps can easily support them through a familiar ERC-20 interface. ![Moonbeam XC-20 XCM Integration With Polkadot](/images/builders/interoperability/xcm/overview/overview-3.webp) To send XC-20s across the Polkadot ecosystem from Moonbeam, developers need to use the [Polkadot XCM Pallet](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} for transfers via the Substrate API and the [X-Tokens Precompile](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-precompile/){target=\_blank} or the [XCM Precompile](/builders/interoperability/xcm/xc20/send-xc20s/eth-api/){target=\_blank} for transfers via the Ethereum API. Another unique feature of Moonbeam is the ability to initiate XCM actions from EVM smart contracts or to call its EVM through XCM messages via remote execution. This unlocks a new set of possibilities, where contracts on Moonbeam can access parachain-specific functionalities via XCM, or other parachain ecosystems can use EVM smart contracts on Moonbeam to expand their functions. The following sections provide a high-level overview of the main use cases mentioned before. ### XCM Transfers between Moonbeam & Polkadot {: #transfers-moonbeam-polkadot } As Moonbeam is a parachain within the Polkadot ecosystem, a straightforward implementation of XCM + VMP is DOT transfers from/to Polkadot/Moonbeam. To this end, DOT was registered as [_xcDOT_](https://moonscan.io/token/0xffffffff1fcacbd218edc0eba20fc2308c778080){target=\_blank} on Moonbeam. Alice (Polkadot) wants to transfer a certain amount of DOT from Polkadot to her account on Moonbeam, named Alith. Therefore, she initiates an XCM that expresses her intentions. For such transfers, Moonbeam owns a Sovereign account on Polkadot. Consequently, the XCM message execution on Polkadot will transfer the amount of DOT to Moonbeam's Sovereign account on Polkadot. Once the assets are deposited, the second part of the message is sent to Moonbeam. Moonbeam will locally execute the action the XCM message is programmed to do. In this case, it is to mint and transfer the same amount of _xcDOT_ to the account defined by Alice, which in this case is Alith. The fee to execute the XCM in the target parachain is paid in the asset being transferred (_xcDOT_ for this example). ![Transfers from the Relay Chain to Moonbeam](/images/builders/interoperability/xcm/overview/overview-4.webp) Note the following: - The Alice and Alith accounts can be different. For example, Polkadot's accounts are SR25519 (or ED25519), while Moonbeam's are ECDSA (Ethereum-styled) accounts. They can also have different owners - There is a certain degree of trust where one chain relies on the other to execute its part of the XCM message. This is programmed at a runtime level so that it can be easily verified - For this example, _xcDOT_ is a wrapped representation of the original DOT being held in Moonbeam's Sovereign account on Polkadot. _xcDOT_ can be transferred within Moonbeam at any time, and they can be redeemed for DOT on a 1:1 basis as well (minus some fees) Alith deposited her _xcDOT_ in a liquidity pool. Next, Charleth acquires some _xcDOT_ by swapping against that liquidity pool, and he wants to transfer some _xcDOT_ to Charley's Polkadot account. Therefore, he initiates an XCM that expresses his intentions. Consequently, the XCM message execution on Moonbeam will burn the number of _xcDOT_. Once the assets are burned, the second part of the message is sent to Polkadot. Polkadot will execute the action the XCM message is programmed to do locally. In this case, it is to transfer the same amount of _xcDOT_ burned from the Moonbeam Sovereign account to the account defined by Charleth, which in this case is Charley. ![Transfers Back from Moonbeam to the Relay Chain](/images/builders/interoperability/xcm/overview/overview-5.webp) ### XCM Transfers between Moonbeam & Other Parachains {: #transfers-moonbeam-other-parachains } Since Moonbeam is a parachain within the Polkadot ecosystem, a straightforward implementation of XCM and XCMP asset transfers from and to Moonbeam and other parachains. This section gives a high-level overview of the main differences compared to XCMs from Polkadot/Moonbeam. The first requirement is that a bidirectional channel between the parachains must exist, and the asset being transferred must be registered in the target parachain. Only when both conditions are met can XCMs be sent between parachains. Then, when Alith (Moonbeam) transfers a certain amount of GLMR from Moonbeam to another account (Alice) in a target parachain, tokens are sent to a Sovereign Account owned by that target parachain on Moonbeam. As the XCM message is executed in the target parachain, it is expected that this will mint and transfer the same amount of _xcGLMR_ (cross-chain GLMR) to the account defined by Alith, which in this case is Alice. The fee to execute the XCM in the target parachain is paid in the transferred asset (_xcGLMR_ for this example). ![Transfers from Moonbeam to another Parachain](/images/builders/interoperability/xcm/overview/overview-6.webp) As explained in the previous section, the process is similar for _xcGLMR_ to move back to Moonbeam. First, the XCM message execution burns the number of _xcGLMR_ returned to Moonbeam. Once burned, the remnant part of the message is sent to Moonbeam via the relay chain. Moonbeam will locally execute the XCM message's and transfer GLMR (the same amount of burned _xcGLMR_) from the target parachain Sovereign account to the specified address. ### Remote Execution between Other Chains & Moonbeam {: #execution-chains-moonbeam } As mentioned before, XCM also enables remote execution from/to Moonbeam to other chains in the Polkadot ecosystem. Similarly to the other use cases, it is necessary for XCM-specific channels to be established before remote execution can happen between the chains. Channels are general-purpose, so they can be used for both asset transfers and remote execution. Another important component is the asset for which the remote execution fees are paid. On Moonbeam, when an XC-20 is registered, it can be set as an XCM execution fee asset. Consequently, when transferring that XC-20 to Moonbeam, the XCM execution fee is deducted from the amount being transferred. For remote execution, users can include a small amount of tokens in the XCM message to cover XCM execution fees. Alice (Polkadot) wants to perform a certain remote action through a smart contract on Moonbeam. Therefore, she initiates an XCM that expresses her intentions; she must have previously funded the XCM execution account she owns on Moonbeam with either GLMR or _xcDOT_. Moonbeam will locally execute the action the XCM message is programmed to do. In this case, it is to withdraw the asset decided by Alice for the XCM execution fee and buy some execution time on Moonbeam to execute the smart contract call on Moonbeam's EVM. You can read more about the flow in detail on the [Remote Execution](/builders/interoperability/xcm/remote-execution/overview/){target=\_blank} page. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/send-execute-xcm/ --- BEGIN CONTENT --- --- title: Send, Execute and Test XCM Messages description: Build a custom XCM message, verify its construction and integrity using the XCM Dry Run API, and then execute it locally on Moonbeam to observe the results. categories: XCM --- # Send, Execute, and Test XCM Messages ## Introduction {: #introduction } XCM messages are comprised of a [series of instructions](/builders/interoperability/xcm/core-concepts/instructions/){target=\_blank} that are executed by the Cross-Consensus Virtual Machine (XCVM). Combinations of these instructions result in predetermined actions, such as cross-chain token transfers. You can create your own custom XCM messages by combining various XCM instructions. Pallets such as [Polkadot XCM](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} and [XCM Transactor](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank} provide functions with a predefined set of XCM instructions to either send [XC-20s](/builders/interoperability/xcm/xc20/overview/){target=\_blank} or remotely execute on other chains via XCM. However, to get a better understanding of the results from combining different XCM instructions, you can build and execute custom XCM messages locally on Moonbeam (only available on Moonbase Alpha). You can also send custom XCM messages to another chain (which will start with the [`DescendOrigin`](https://github.com/paritytech/xcm-format#descendorigin){target=\_blank} instruction). Nevertheless, for the XCM message to be successfully executed, the target chain needs to be able to understand the instructions. To execute or send a custom XCM message, you can either use the [Polkadot XCM Pallet](#polkadot-xcm-pallet-interface) directly or through the Ethereum API with the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank}. In this guide, you'll learn how to use both methods to execute and send custom-built XCM messages locally on Moonbase Alpha. This guide assumes that you are familiar with general XCM concepts, such as [general XCM terminology](/builders/interoperability/xcm/overview/#general-xcm-definitions){target=\_blank} and [XCM instructions](/builders/interoperability/xcm/core-concepts/instructions/){target=\_blank}. For more information, you can check out the [XCM Overview](/builders/interoperability/xcm/overview/){target=\_blank} documentation. ## Polkadot XCM Pallet Interface {: #polkadot-xcm-pallet-interface } ### Extrinsics {: #extrinsics } The Polkadot XCM Pallet includes the following relevant extrinsics (functions): ???+ function "**execute**(message, maxWeight) — **supported on Moonbase Alpha only** - executes a custom XCM message on the source chain" === "Parameters" - `message` - the SCALE-encoded versioned XCM message to be executed - `maxWeight` - the maximum weight allowed to be consumed, which is defined by specifying the: - `refTime` - the amount of computational time that can be used for execution - `proofSize` - the amount of storage in bytes that can be used === "Polkadot.js API Example" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const message = { V4: [INSERT_XCM_INSTRUCTIONS] }; const maxWeight = { refTime: INSERT_REF_TIME, proofSize: INSERT_PROOF_SIZE }; const main = async () => { const api = await ApiPromise.create({ provider: new WsProvider('INSERT_WSS_ENDPOINT'), }); const tx = api.tx.polkadotXcm.execute(message, maxWeight); const txHash = await tx.signAndSend('INSERT_ACCOUNT_OR_KEYRING'); }; main(); ``` ???+ function "**send**(dest, message) — **supported on Moonbase Alpha only** - sends a custom XCM message to a destination chain. For the XCM message to be successfully executed, the target chain needs to be able to understand the instructions in the message" === "Parameters" - `dest` - the XCM versioned multilocation representing a chain in the ecosystem where the XCM message is being sent to (the target chain) - `message` - the SCALE-encoded versioned XCM message to be executed === "Polkadot.js API Example" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const dest = { V4: { parents: INSERT_PARENTS, interior: INSERT_INTERIOR } }; const message = { V4: [INSERT_XCM_INSTRUCTIONS] }; const main = async () => { const api = await ApiPromise.create({ provider: new WsProvider('INSERT_WSS_ENDPOINT'), }); const tx = api.tx.polkadotXcm.send(dest, message); const txHash = await tx.signAndSend('INSERT_ACCOUNT_OR_KEYRING'); }; main(); ``` ### Storage Methods {: #storage-methods } The Polkadot XCM Pallet includes the following relevant read-only storage methods: ???+ function "**assetTraps**(hash) — returns the existing number of times an asset has been trapped given a hash of the asset" === "Parameters" `hash` - (optional) the Blake2-256 hash of the [`Asset`](https://github.com/paritytech/xcm-format#6-universal-asset-identifiers){target=\_blank} === "Returns" The number of times an asset has been trapped. If the hash was omitted, it returns an array of all of the hashes and the number of times each asset has been trapped. ```js // If using Polkadot.js API and calling toJSON() on the value // If hash was provided: 10 // If hash was omitted: [ [ 0xf7d4341888be30c6a842a77c52617423e8109aa249e88779019cf731ed772fb7 ], 10 ], ... ``` === "Polkadot.js API Example" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { const api = await ApiPromise.create({ provider: new WsProvider('INSERT_WSS_ENDPOINT'), }); const trappedAssets = await api.query.polkadotXcm.assetTraps.entries(); trappedAssets.forEach( ([ { args: [hash], }, count ]) => { console.log( `Asset with hash ${hash.toJSON()} has been trapped ${count.toJSON()} times` ); } ); }; main(); ``` ??? function "**palletVersion**() — returns current pallet version from storage" === "Parameters" None === "Returns" A number representing the current version of the pallet. ```js // If using Polkadot.js API and calling toJSON() on the unwrapped value 0 ``` === "Polkadot.js API Example" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const main = async () => { const api = await ApiPromise.create({ provider: new WsProvider('INSERT_WSS_ENDPOINT'), }); const palletVersion = await api.query.polkadotXcm.palletVersion(); }; main(); ``` ## Checking Prerequisites {: #checking-prerequisites } To follow along with this guide, you will need the following: - Your account must be funded with DEV tokens. You can get DEV tokens for testing on Moonbase Alpha once every 24 hours from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} ## Execute an XCM Message Locally {: #execute-an-xcm-message-locally } This section of the guide covers the process of building a custom XCM message to be executed locally (i.e., in Moonbeam) via two different methods: the `execute` function of the Polkadot XCM Pallet and the `xcmExecute` function of the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank}. This functionality provides a playground for you to experiment with different XCM instructions and see firsthand the results of these experiments. This also comes in handy to determine the [fees](/builders/interoperability/xcm/core-concepts/weights-fees/){target=\_blank} associated with a given XCM message on Moonbeam. In the following example, you'll transfer DEV tokens from one account to another on Moonbase Alpha. To do so, you'll be building an XCM message that contains the following XCM instructions, which are executed locally (in this case, on Moonbase Alpha): - [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} - removes assets and places them into the holding register - [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank} - removes the assets from the holding register and deposits the equivalent assets to a beneficiary account !!! note Typically, when you send an XCM message cross-chain to a target chain, the [`BuyExecution` instruction](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} is needed to pay for remote execution. However, for local execution, this instruction is not necessary as you are already getting charged via the extrinsic call. ### Execute an XCM Message with the Polkadot.js API {: #execute-an-xcm-message-with-polkadotjs-api } In this example, you'll execute a custom XCM message locally on Moonbase Alpha using the Polkadot.js API to interact directly with the Polkadot XCM Pallet. The `execute` function of the Polkadot XCM Pallet accepts two parameters: `message` and `maxWeight`. You can start assembling these parameters by taking the following steps: 1. Build the `WithdrawAsset` instruction, which will require you to define: - The multilocation of the DEV token on Moonbase Alpha - The amount of DEV tokens to transfer ```js const instr1 = { WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] } }, fun: { Fungible: 100000000000000000n }, // 0.1 DEV }, ], }; ``` 2. Build the `DepositAsset` instruction, which will require you to define: - The asset identifier for DEV tokens. You can use the [`WildAsset` format](https://github.com/paritytech/xcm-format/blob/master/README.md#6-universal-asset-identifiers){target=\_blank}, which allows for wildcard matching, to identify the asset - The multilocation of the beneficiary account on Moonbase Alpha ```js const instr2 = { DepositAsset: { assets: { Wild: { AllCounted: 1, }, }, beneficiary: { parents: 0, interior: { X1: [ { AccountKey20: { key: '0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0', }, }, ], }, }, }, }; ``` 3. Combine the XCM instructions into a versioned XCM message: ```js const message = { V4: [instr1, instr2] }; ``` 4. Specify the `maxWeight`, which includes a value for `refTime` and `proofSize` that you will need to define. You can get both of these values by providing the XCM message as a parameter to the `queryXcmWeight` method of the [`xcmPaymentApi` runtime call](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmoonbeam-alpha.api.onfinality.io%2Fpublic-ws#/runtime){target=\_blank}. ```js const maxWeight = { refTime: 7250000000n, proofSize: 19374n }; ``` Now that you have the values for each of the parameters, you can write the script for the execution. You'll take the following steps: 1. Provide the input data for the call. This includes: - The Moonbase Alpha endpoint URL to create the provider - The values for each of the parameters of the `execute` function 2. Create a Keyring instance that will be used to send the transaction 3. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 4. Craft the `polkadotXcm.execute` extrinsic with the `message` and `maxWeight` 5. Send the transaction using the `signAndSend` extrinsic and the Keyring instance you created in the second step !!! remember This is for demo purposes only. Never store your private key in a JavaScript file. ```js import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; // Version 10.13.1 import { cryptoWaitReady } from '@polkadot/util-crypto'; // 1. Provide input data const providerWsURL = 'wss://wss.api.moonbase.moonbeam.network'; const privateKey = 'INSERT_PRIVATE_KEY'; const instr1 = { WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] } }, fun: { Fungible: 100000000000000000n }, // 0.1 DEV }, ], }; const instr2 = { DepositAsset: { assets: { Wild: { AllCounted: 1, }, }, beneficiary: { parents: 0, interior: { X1: [ { AccountKey20: { key: '0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0', }, }, ], }, }, }, }; const message = { V4: [instr1, instr2] }; const maxWeight = { refTime: 7250000000n, proofSize: 19374n }; const executeXcmMessage = async () => { // 2. Create Keyring instance await cryptoWaitReady(); const keyring = new Keyring({ type: 'ethereum' }); const alice = keyring.addFromUri(privateKey); // 3. Create Substrate API provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 4. Craft the extrinsic const tx = api.tx.polkadotXcm.execute(message, maxWeight); // 5. Send the transaction const txHash = await tx.signAndSend(alice); console.log(`Submitted with hash ${txHash}`); api.disconnect(); }; executeXcmMessage(); ``` !!! note You can view an example of the above script, which sends 1 DEV to Bob's account on Moonbase Alpha, on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/extrinsics/decode/0x1c030408000400010403001300008a5d784563010d010204000103003cd0a705a2dc65e5b1e1205896baa2be8a07c6e007803822b001ba2e0100){target=\_blank} using the following encoded calldata: `0x1c030408000400010403001300008a5d784563010d010204000103003cd0a705a2dc65e5b1e1205896baa2be8a07c6e007803822b001ba2e0100`. Once the transaction is processed, the 0.1 DEV tokens should be withdrawn from Alice's account along with the associated XCM fees, and the destination account should have received 0.1 DEV tokens in their account. A `polkadotXcm.Attempted` event will be emitted with the outcome. ## Test an XCM Message with the Dry Run API {: #test-an-xcm-message-with-the-dry-run-api } The XCM Dry Run API is an easy and convenient way to test the integrity of your XCM message without incurring any transaction fees. The XCM Dry Run API can be accessed from the [Runtime Calls](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/runtime){target=\_blank} tab of the **Developer** section of Polkadot.js Apps. ### Dry Run Call API Method {: #dry-run-call-api-method } This method takes as a parameter the origin and the call data and returns an execution result, actual weight, and event data. ```javascript const testAccount = api.createType( 'AccountId20', '0x88bcE0b038eFFa09e58fE6d24fDe4b5Af21aa798' ); const callData = '0x1c030408000400010403001300008a5d784563010d010204000103003cd0a705a2dc65e5b1e1205896baa2be8a07c6e007803822b001ba2e0100'; const callDataU8a = hexToU8a(callData); const result = await api.call.dryRunApi.dryRunCall( { system: { Signed: testAccount } }, callDataU8a ); ``` ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; import { hexToU8a } from '@polkadot/util'; const main = async () => { try { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); console.log('Connected to the API. Preparing dry run call...'); // Create a test account (you should replace this with an actual account) const testAccount = api.createType( 'AccountId20', '0x88bcE0b038eFFa09e58fE6d24fDe4b5Af21aa798' ); // The call data (replace with your actual call data) const callData = '0x1c030408000400010403001300008a5d784563010d010204000103003cd0a705a2dc65e5b1e1205896baa2be8a07c6e007803822b001ba2e0100'; // Your hex-encoded call data // Convert hex to Uint8Array const callDataU8a = hexToU8a(callData); // Perform the dry run call const result = await api.call.dryRunApi.dryRunCall( { system: { Signed: testAccount } }, // origin callDataU8a // call ); console.log( 'Dry run XCM result:', JSON.stringify(result.toJSON(), null, 2) ); // Disconnect the API await api.disconnect(); console.log('Disconnected from the API.'); } catch (error) { console.error('An error occurred:', error); } }; main().catch(console.error); ``` Upon calling the XCM Dry Run API, the method will tell you whether the call would be successful and returns the event data that would be emitted if the call were actually submitted on chain. You can view the initial output of the `dryRunCall` below. ??? code "View the complete output" ```json Dry run XCM result: { "ok": { "executionResult": { "ok": { "actualWeight": { "refTime": 7301615000, "proofSize": 20928 }, "paysFee": "Yes" } }, "emittedEvents": [ { "index": "0x030b", "data": [ "0x88bcE0b038eFFa09e58fE6d24fDe4b5Af21aa798", "0x0000000000000000016345785d8a0000" ] }, { "index": "0x0300", "data": [ "0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0", "0x0000000000000000016345785d8a0000" ] }, { "index": "0x030a", "data": [ "0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0", "0x0000000000000000016345785d8a0000" ] }, { "index": "0x1c00", "data": [ { "complete": { "used": { "refTime": 7250000000, "proofSize": 19374 } } } ] } ], "localXcm": { "v4": [ { "withdrawAsset": [ { "id": { "parents": 0, "interior": { "x1": [ { "palletInstance": 3 } ] } }, "fun": { "fungible": "0x0000000000000000016345785d8a0000" } } ] }, { "depositAsset": { "assets": { "wild": { "allCounted": 1 } }, "beneficiary": { "parents": 0, "interior": { "x1": [ { "accountKey20": { "network": null, "key": "0x3cd0a705a2dc65e5b1e1205896baa2be8a07c6e0" } } ] } } } } ] } // Additional events returned here // Omitted for clarity ``` ### Dry Run XCM API Method {: #dry-run-xcm-api-method } The `dryRunXCM` method of the XCM Dry Run API takes a full XCM message as a parameter instead of an encoded call, as well as the origin of the message. `dryRunXCM` takes as a parameter the origin and the XCM message and returns an execution result, actual weight, and event data. ```javascript // Define the origin const origin = { V4: { parents: 1, interior: 'Here' } }; const message = []; // Insert XCM Message Here // Perform the dry run XCM call const result = await api.call.dryRunApi.dryRunXcm(origin, message); ``` ??? code "View the complete script" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; import { hexToU8a } from '@polkadot/util'; const main = async () => { try { // Construct API provider const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: wsProvider }); console.log('Connected to the API. Preparing dry run XCM call...'); // Define the origin const origin = { V4: { parents: 1, interior: 'Here' } }; const amountToSend = 1000000000000; const message = { V4: [ { WithdrawAsset: [ { id: { parents: 1, interior: 'Here' }, fun: { Fungible: amountToSend }, }, ], }, { BuyExecution: { fees: { id: { parents: 1, interior: 'Here' }, fun: { Fungible: amountToSend }, }, weightLimit: { Unlimited: null }, }, }, { DepositAsset: { assets: { Wild: { AllOf: { id: { parents: 1, interior: 'Here' } } } }, maxAssets: 1, beneficiary: { parents: 0, interior: { X1: [ { AccountKey20: { network: null, key: hexToU8a('0x3B939FeaD1557C741Ff06492FD0127bd287A421e') } } ] } } } } ], }; // Perform the dry run XCM call const result = await api.call.dryRunApi.dryRunXcm(origin, message); console.log( 'Dry run XCM result:', JSON.stringify(result.toJSON(), null, 2) ); await api.disconnect(); console.log('Disconnected from the API.'); } catch (error) { console.error('An error occurred:', error); } }; main().catch(console.error); ``` Upon calling the XCM Dry Run API, the method will tell you whether the call would be successful and returns the event data that would be emitted if the XCM were to be actually submitted on chain. You can view the initial output of the `dryRunXCM` below. ??? code "View the complete output" ```json Dry run XCM result: { "ok": { "executionResult": { "complete": { "used": { "refTime": 76473048000, "proofSize": 222483 } } }, "emittedEvents": [ { "index": "0x1d03", "data": [ "0x1fcacbd218edc0eba20fc2308c778080", "0x506172656E740000000000000000000000000000", 1000000000000 ] }, { "index": "0x1d01", "data": [ "0x1fcacbd218edc0eba20fc2308c778080", "0x3B939FeaD1557C741Ff06492FD0127bd287A421e", 959944978002 ] }, { "index": "0x1d01", "data": [ "0x1fcacbd218edc0eba20fc2308c778080", "0x6d6F646c70632f74727372790000000000000000", 40055021998 ] } ], // Additional events returned here // Omitted for clarity ``` ## Execute an XCM Message with the XCM Utilities Precompile {: #execute-xcm-utils-precompile } In this section, you'll use the `xcmExecute` function of the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank}, which is only supported on Moonbase Alpha, to execute an XCM message locally. The XCM Utilities Precompile is located at the following address: ```text {{ networks.moonbase.precompiles.xcm_utils }} ``` Under the hood, the `xcmExecute` function of the XCM Utilities Precompile calls the `execute` function of the Polkadot XCM Pallet, which is a Substrate pallet that is coded in Rust. The benefit of using the XCM Utilities Precompile to call `xcmExecute` is that you can do so via the Ethereum API and use [Ethereum libraries](/builders/ethereum/libraries/){target=\_blank} like [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank}. The `xcmExecute` function accepts two parameters: the SCALE encoded versioned XCM message to be executed and the maximum weight to be consumed. First, you'll learn how to generate the encoded calldata, and then you'll learn how to use the encoded calldata to interact with the XCM Utilities Precompile. ### Generate the Encoded Calldata of an XCM Message {: #generate-encoded-calldata } To get the encoded calldata of the XCM message, you can create a script similar to the one you created in the [Execute an XCM Message with the Polkadot.js API](#execute-an-xcm-message-with-polkadotjs-api) section. Instead of building the message and sending the transaction, you'll build the message to get the encoded calldata. You'll take the following steps: 1. Provide the input data for the call. This includes: - The Moonbase Alpha endpoint URL to create the provider - The values for each of the parameters of the `execute` function as defined in the [Execute an XCM Message with the Polkadot.js API](#execute-an-xcm-message-with-polkadotjs-api) section 2. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 3. Craft the `polkadotXcm.execute` extrinsic with the `message` and `maxWeight` 4. Use the transaction to get the encoded calldata The entire script is as follows: ```js import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 10.13.1 // 1. Provide input data const moonbeamAccount = 'INSERT_ADDRESS'; const providerWsURL = 'wss://wss.api.moonbase.moonbeam.network'; const instr1 = { WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] } }, fun: { Fungible: 100000000000000000n }, }, ], }; const instr2 = { DepositAsset: { assets: { Wild: { AllCounted: 1 } }, beneficiary: { parents: 0, interior: { X1: [ { AccountKey20: { key: moonbeamAccount, }, }, ], }, }, }, }; const message = { V4: [instr1, instr2] }; const maxWeight = { refTime: 7250000000n, proofSize: 19374n }; const getEncodedXcmMessage = async () => { // 2. Create Substrate API provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 3. Craft the extrinsic const tx = api.tx.polkadotXcm.execute(message, maxWeight); // 4. Get the encoded XCM message // By using index 0, you'll get just the encoded XCM message. // If you wanted to get the maxWeight, you could use index 1 const encodedXcmMessage = tx.args[0].toHex(); console.log(`Encoded Calldata for XCM Message: ${encodedXcmMessage}`); api.disconnect(); }; getEncodedXcmMessage(); ``` ### Execute the XCM Message {: #execute-xcm-message } Now that you have the SCALE encoded XCM message, you can use the following code snippets to programmatically call the `xcmExecute` function of the XCM Utilities Precompile using your [Ethereum library](/builders/ethereum/libraries/){target=\_blank} of choice. Generally speaking, you'll take the following steps: 1. Create a provider and signer 2. Create an instance of the XCM Utilities Precompile to interact with 3. Define parameters required for the `xcmExecute` function, which will be the encoded calldata for the XCM message and the maximum weight to use to execute the message. You can set the `maxWeight` to be `400000000n`, which corresponds to the `refTime`. The `proofSize` will automatically be set to the default, which is 64KB 4. Execute the XCM message !!! remember The following snippets are for demo purposes only. Never store your private keys in a JavaScript or Python file. === "Ethers.js" ```js import { ethers } from 'ethers'; // Import Ethers library import abi from './xcmUtilsABI.js'; // Import the XCM Utilities Precompile ABI const privateKey = 'INSERT_YOUR_PRIVATE_KEY'; const xcmUtilsAddress = '0x000000000000000000000000000000000000080C'; /* Create Ethers provider and signer */ const provider = new ethers.JsonRpcProvider( 'https://rpc.api.moonbase.moonbeam.network' ); const signer = new ethers.Wallet(privateKey, provider); /* Create contract instance of the XCM Utilities Precompile */ const xcmUtils = new ethers.Contract( xcmUtilsAddress, abi, signer ); const executeXcmMessageLocally = async () => { /* Define parameters required for the xcmExecute function */ const encodedCalldata = 'INSERT_ENCODED_CALLDATA'; const maxWeight = '400000000'; /* Execute the custom XCM message */ const tx = await xcmUtils.xcmExecute(encodedCalldata, maxWeight); await tx.wait(); console.log(`Transaction receipt: ${tx.hash}`); }; executeXcmMessageLocally(); ``` === "Web3.js" ```js import { Web3 } from 'web3'; // Import Web3 library import abi from './xcmUtilsABI.js'; // Import the XCM Utilities Precompile ABI const privateKey = 'INSERT_PRIVATE_KEY'; const accountFrom = web3.eth.accounts.privateKeyToAccount(privateKey).address; const xcmUtilsAddress = '0x000000000000000000000000000000000000080C'; /* Create Web3 provider */ const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); // Change to network of choice /* Create contract instance of the XCM Utilities Precompile */ const xcmUtils = new web3.eth.Contract( abi, xcmUtilsAddress, { from: accountFrom } // 'from' is necessary for gas estimation ); const executeXcmMessageLocally = async () => { /* Define parameters required for the xcmExecute function */ const encodedCalldata = 'INSERT_ENCODED_CALLDATA'; const maxWeight = '400000000'; /* Send the custom XCM message */ // Craft the extrinsic const tx = await xcmUtils.methods.xcmExecute(encodedCalldata, maxWeight); // Sign transaction const signedTx = await web3.eth.accounts.signTransaction( { to: xcmUtilsAddress, data: tx.encodeABI(), gas: await tx.estimateGas(), gasPrice: await web3.eth.getGasPrice(), nonce: await web3.eth.getTransactionCount(accountFrom), }, privateKey ); // Send the signed transaction const sendTx = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); console.log(`Transaction receipt: ${sendTx.transactionHash}`); }; executeXcmMessageLocally(); ``` === "Web3.py" ```py from web3 import Web3 abi = "INSERT_XCM_UTILS_ABI" # Paste or import the XCM Utils ABI # This is for demo purposes, never store your private key in plain text private_key = "INSERT_PRIVATE_KEY" # The wallet address that corresponds to your private key address = "INSERT_ADDRESS" xcm_utils_address = "0x000000000000000000000000000000000000080C" ## Create Web3 provider ## web3 = Web3(Web3.HTTPProvider("https://rpc.api.moonbase.moonbeam.network")) ## Create contract instance of the XCM Utilities Precompile ## xcm_utils = web3.eth.contract( # XCM Utilities Precompile address address=xcm_utils_address, abi=abi, ) def execute_xcm_message_locally(): ## Define parameters required for the xcmExecute function ## encoded_calldata = "INSERT_ENCODED_CALLDATA" max_weight = 400000000 ## Execute the custom XCM message ## # Craft the extrinsic tx = xcm_utils.functions.xcmExecute(encoded_calldata, max_weight).build_transaction( { "from": address, "nonce": web3.eth.get_transaction_count(address), } ) # Sign transaction signedTx = web3.eth.account.sign_transaction(tx, private_key) # Send tx hash = web3.eth.send_raw_transaction(signedTx.rawTransaction) receipt = web3.eth.wait_for_transaction_receipt(hash) print(f"Transaction receipt: { receipt.transactionHash.hex() }") execute_xcm_message_locally() ``` And that's it! You've successfully used the Polkadot XCM Pallet and the XCM Utilities Precompile to execute a custom XCM message locally on Moonbase Alpha! ## Send an XCM Message Cross-Chain {: #send-xcm-message } This section of the guide covers the process of sending a custom XCM message cross-chain (i.e., from Moonbeam to a target chain, such as the relay chain) via two different methods: the `send` function of the Polkadot XCM Pallet and the `xcmSend` function of the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank}. For the XCM message to be successfully executed, the target chain needs to be able to understand the instructions in the message. If it doesn't, you'll see a `Barrier` filter on the destination chain. For security reasons, the XCM message is prepended with the [`DescendOrigin`](https://github.com/paritytech/xcm-format#descendorigin){target=\_blank} instruction to prevent XCM execution on behalf of the origin chain Sovereign account. **The example in this section will not work for the reasons mentioned above, it is purely for demonstration purposes**. In the following example, you'll be building an XCM message that contains the following XCM instructions, which will be executed in the Alphanet relay chain: - [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} - removes assets and places them into the holding register - [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} - takes the assets from holding to pay for execution fees. The fees to pay are determined by the target chain - [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank}- removes the assets from the holding register and deposits the equivalent assets to a beneficiary account Together, the intention of these instructions is to transfer the native asset of the relay chain, which is UNIT for the Alphanet relay chain, from Moonbase Alpha to an account on the relay chain. This example is for demonstration purposes only to show you how a custom XCM message could be sent cross-chain. Please keep in mind that the target chain needs to be able to understand the instructions in the message to execute them. ### Send an XCM Message with the Polkadot.js API {: #send-xcm-message-with-polkadotjs-api } In this example, you'll send a custom XCM message from your account on Moonbase Alpha to the relay chain using the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} to interact directly with the Polkadot XCM Pallet. The `send` function of the Polkadot XCM Pallet accepts two parameters: `dest` and `message`. You can start assembling these parameters by taking the following steps: 1. Build the multilocation of the relay chain token, UNIT, for the `dest`: ```js const dest = { V4: { parents: 1, interior: null } }; ``` 2. Build the `WithdrawAsset` instruction, which will require you to define: - The multilocation of the UNIT token on the relay chain - The amount of UNIT tokens to withdraw ```js const instr1 = { WithdrawAsset: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, ], }; ``` 3. Build the `BuyExecution` instruction, which will require you to define: - The multilocation of the UNIT token on the relay chain - The amount of UNIT tokens to buy for execution - The weight limit ```js const instr2 = { BuyExecution: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, { Unlimited: null }, ], }; ``` 4. Build the `DepositAsset` instruction, which will require you to define: - The asset identifier for UNIT tokens. You can use the [`WildAsset` format](https://github.com/paritytech/xcm-format/blob/master/README.md#6-universal-asset-identifiers){target=\_blank}, which allows for wildcard matching, to identify the asset - The multilocation of the beneficiary account on the relay chain ```js const instr3 = { DepositAsset: { assets: { Wild: 'All' }, beneficiary: { parents: 1, interior: { X1: [ { AccountId32: { id: relayAccount, }, }, ], }, }, }, }; ``` 5. Combine the XCM instructions into a versioned XCM message: ```js const message = { V4: [instr1, instr2, instr3] }; ``` Now that you have the values for each of the parameters, you can write the script to send the XCM message. You'll take the following steps: 1. Provide the input data for the call. This includes: - The Moonbase Alpha endpoint URL to create the provider - The values for each of the parameters of the `send` function 2. Create a Keyring instance that will be used to send the transaction 3. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 4. Craft the `polkadotXcm.send` extrinsic with the `dest` and `message` 5. Send the transaction using the `signAndSend` extrinsic and the Keyring instance you created in the second step !!! remember This is for demo purposes only. Never store your private key in a JavaScript file. ```js import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; // Version 10.13.1 import { cryptoWaitReady, decodeAddress } from '@polkadot/util-crypto'; // 1. Input data const providerWsURL = 'wss://wss.api.moonbase.moonbeam.network'; // You can use the decodeAddress function to ensure that your address is properly // decoded. If it isn't decoded, it will decode it and if it is, it will ignore it const privateKey = 'INSERT_PRIVATE_KEY'; const relayAccount = decodeAddress('INSERT_ADDRESS'); const dest = { V4: { parents: 1, interior: null } }; const instr1 = { WithdrawAsset: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, ], }; const instr2 = { BuyExecution: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, { Unlimited: null }, ], }; const instr3 = { DepositAsset: { assets: { Wild: 'All' }, beneficiary: { parents: 1, interior: { X1: [ { AccountId32: { id: relayAccount, }, }, ], }, }, }, }; const message = { V4: [instr1, instr2, instr3] }; const sendXcmMessage = async () => { // 2. Create Keyring instance await cryptoWaitReady(); const keyring = new Keyring({ type: 'ethereum' }); const alice = keyring.addFromUri(privateKey); // 3. Create Substrate API Provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 4. Create the extrinsic const tx = api.tx.polkadotXcm.send(dest, message); // 5. Send the transaction const txHash = await tx.signAndSend(alice); console.log(`Submitted with hash ${txHash}`); api.disconnect(); }; sendXcmMessage(); ``` !!! note You can view an example of the above script, which sends 1 UNIT to Bob's relay chain account, on [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/extrinsics/decode/0x1c00040100040c0004010000070010a5d4e813010000070010a5d4e8000d0100010101000c36e9ba26fa63c60ec728fe75fe57b86a450d94e7fee7f9f9eddd0d3f400d67){target=\_blank} using the following encoded calldata: `0x1c00040100040c0004010000070010a5d4e813010000070010a5d4e8000d0100010101000c36e9ba26fa63c60ec728fe75fe57b86a450d94e7fee7f9f9eddd0d3f400d67`. Once the transaction is processed, a `polkadotXcm.sent` event is emitted with the details of the sent XCM message. ### Send an XCM Message with the XCM Utilities Precompile {: #send-xcm-utils-precompile } In this section, you'll use the `xcmSend` function of the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank}, which is only supported on Moonbase Alpha, to send an XCM message cross-chain. The XCM Utilities Precompile is located at the following address: === "Moonbase Alpha" ```text {{ networks.moonbase.precompiles.xcm_utils }} ``` Under the hood, the `xcmSend` function of the XCM Utilities Precompile calls the `send` function of the Polkadot XCM Pallet, which is a Substrate pallet that is coded in Rust. The benefit of using the XCM Utilities Precompile to call `xcmSend` is that you can do so via the Ethereum API and use Ethereum libraries like [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank}. For the XCM message to be successfully executed, the target chain needs to be able to understand the instructions in the message. The `xcmSend` function accepts two parameters: the multilocation of the destination and the SCALE encoded versioned XCM message to be sent. First, you'll learn how to generate the encoded calldata for the XCM message, and then you'll learn how to use the encoded calldata to interact with the XCM Utilities Precompile. #### Generate the Encoded Calldata of an XCM Message {: #generate-encoded-calldata } To get the encoded calldata of the XCM message, you can create a script similar to the one you created in the [Send an XCM Message with the Polkadot.js API](#send-xcm-message-with-polkadotjs-api) section. Instead of building the message and sending the transaction, you'll build the message to get the encoded calldata. You'll take the following steps: 1. Provide the input data for the call. This includes: - The Moonbase Alpha endpoint URL to create the provider - The values for each of the parameters of the `send` function as defined in the [Send an XCM Message with the Polkadot.js API](#send-xcm-message-with-polkadotjs-api) section 2. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 3. Craft the `polkadotXcm.execute` extrinsic with the `message` and `maxWeight` 4. Use the transaction to get the encoded calldata The entire script is as follows: ```js import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 10.13.1 import { decodeAddress } from '@polkadot/util-crypto'; // 1. Input data const providerWsURL = 'wss://wss.api.moonbase.moonbeam.network'; // You can use the decodeAddress function to ensure that your address is properly // decoded. If it isn't decoded, it will decode it and if it is, it will ignore it const relayAccount = decodeAddress('INSERT_ADDRESS'); const dest = { V4: { parents: 1, interior: null } }; const instr1 = { WithdrawAsset: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, ], }; const instr2 = { BuyExecution: [ { id: { parents: 1, interior: null }, fun: { Fungible: 1000000000000n }, // 1 UNIT }, { Unlimited: null }, ], }; const instr3 = { DepositAsset: { assets: { Wild: 'All' }, beneficiary: { parents: 1, interior: { X1: [ { AccountId32: { id: relayAccount, }, }, ], }, }, }, }; const message = { V4: [instr1, instr2, instr3] }; const generateEncodedXcmMessage = async () => { // 2. Create Substrate API Provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 3. Create the extrinsic const tx = api.tx.polkadotXcm.send(dest, message); // 4. Get the encoded XCM message // By using index 1, you'll get just the encoded XCM message. // If you wanted to get the dest, you could use index 0 const encodedXcmMessage = tx.args[1].toHex(); console.log(`Encoded Calldata for XCM Message: ${encodedXcmMessage}`); api.disconnect(); }; generateEncodedXcmMessage(); ``` #### Send the XCM Message {: #send-xcm-message } Before you can send the XCM message, you'll also need to build the multilocation of the destination. For this example, you'll target the relay chain with Moonbase Alpha as the origin chain: ```js const dest = [ 1, // Parents: 1 [] // Interior: Here ]; ``` Now that you have the SCALE encoded XCM message and the destination multilocation, you can use the following code snippets to programmatically call the `xcmSend` function of the XCM Utilities Precompile using your [Ethereum library](/builders/ethereum/libraries/){target=\_blank} of choice. Generally speaking, you'll take the following steps: 1. Create a provider and signer 2. Create an instance of the XCM Utilities Precompile to interact with 3. Define parameters required for the `xcmSend` function, which will be the destination and the encoded calldata for the XCM message 4. Send the XCM message !!! remember The following snippets are for demo purposes only. Never store your private keys in a JavaScript or Python file. === "Ethers.js" ```js import { ethers } from 'ethers'; // Import Ethers library import abi from './xcmUtilsABI.js'; // Import the XCM Utilities Precompile ABI const privateKey = 'INSERT_PRIVATE_KEY'; const xcmUtilsAddress = '0x000000000000000000000000000000000000080C'; /* Create Ethers provider and signer */ const provider = new ethers.JsonRpcProvider( 'https://rpc.api.moonbase.moonbeam.network' ); const signer = new ethers.Wallet(privateKey, provider); /* Create contract instance of the XCM Utilities Precompile */ const xcmUtils = new ethers.Contract( xcmUtilsAddress, abi, signer ); const sendXcm = async () => { /* Define parameters required for the xcmSend function */ const encodedCalldata = 'INSERT_ENCODED_CALLDATA'; const dest = [ 1, // Parents: 1 [] // Interior: Here ]; /* Send the custom XCM message */ const tx = await xcmUtils.xcmSend(dest, encodedCalldata); await tx.wait(); console.log(`Transaction receipt: ${tx.hash}`); }; sendXcm(); ``` === "Web3.js" ```js import { Web3 } from 'web3'; // Import Web3 library import abi from './xcmUtilsABI.js'; // Import the XCM Utilities Precompile ABI const privateKey = 'INSERT_PRIVATE_KEY'; const accountFrom = web3.eth.accounts.privateKeyToAccount(privateKey).address; const xcmUtilsAddress = '0x000000000000000000000000000000000000080C'; /* Create Web3 provider */ const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); // Change to network of choice /* Create contract instance of the XCM Utilities Precompile */ const xcmUtils = new web3.eth.Contract( abi, xcmUtilsAddress, { from: accountFrom } // 'from' is necessary for gas estimation ); const sendXcm = async () => { /* Define parameters required for the xcmSend function */ const encodedCalldata = 'INSERT_ENCODED_CALLDATA'; const dest = [ 1, // Parents: 1 [], // Interior: Here ]; /* Send the custom XCM message */ // Craft the extrinsic const tx = await xcmUtils.methods.xcmSend(dest, encodedCalldata); // Sign transaction const signedTx = await web3.eth.accounts.signTransaction( { to: xcmUtilsAddress, data: tx.encodeABI(), gas: await tx.estimateGas(), gasPrice: await web3.eth.getGasPrice(), nonce: await web3.eth.getTransactionCount(accountFrom), }, privateKey ); // Send the signed transaction const sendTx = await web3.eth.sendSignedTransaction(signedTx.rawTransaction); console.log(`Transaction receipt: ${sendTx.transactionHash}`); }; sendXcm(); ``` === "Web3.py" ```py from web3 import Web3 abi = "INSERT_XCM_UTILS_ABI" # Paste or import the XCM Utils ABI # This is for demo purposes, never store your private key in plain text private_key = "INSERT_PRIVATE_KEY" # The wallet address that corresponds to your private key address = "INSERT_ADDRESS" xcm_utils_address = "0x000000000000000000000000000000000000080C" ## Create Web3 provider ## web3 = Web3(Web3.HTTPProvider("https://rpc.api.moonbase.moonbeam.network")) ## Create contract instance of the XCM Utilities Precompile ## xcm_utils = web3.eth.contract( # XCM Utilities Precompile address address=xcm_utils_address, abi=abi, ) def send_xcm(): ## Define parameters required for the xcmSend function ## encoded_calldata = "INSERT_ENCODED_CALLDATA" xcm_dest = [1, []] # Parents: 1 # Interior: Here ## Send the custom XCM message ## # Craft the extrinsic tx = xcm_utils.functions.xcmSend(xcm_dest, encoded_calldata).build_transaction( { "from": address, "nonce": web3.eth.get_transaction_count(address), } ) # Sign transaction signed_tx = web3.eth.account.sign_transaction(tx, private_key) # Send tx hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction) receipt = web3.eth.wait_for_transaction_receipt(hash) print(f"Transaction receipt: { receipt.transactionHash.hex() }") send_xcm() ``` And that's it! You've successfully used the Polkadot XCM Pallet and the XCM Utilities Precompile to send a message from Moonbase Alpha to another chain! --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc-registration/forum-templates/ --- BEGIN CONTENT --- --- title: Forum Templates for XCM Integrations description: Learn about and how to craft the two posts you need to make on the Moonbeam Community Forum when creating a cross-chain integration with Moonbeam. categories: XCM, Integrations --- # Moonbeam Community Forum Templates for XCM Integrations ## Introduction {: #introduction } When starting an XCM integration on Moonriver or Moonbeam MainNet, there are two preliminary posts that must be made on the [Moonbeam Community Forum](https://forum.moonbeam.network){target=\_blank} so that the voting community has the chance to provide feedback. The two preliminary posts are an XCM disclosure and an XCM proposal. **This step is not necessary when connecting to Moonbase Alpha.** If only an asset is being registered, the cross-chain channel must already be established, and so only an XCM proposal post is required to register the asset. It is recommended that this be done five days before the actual proposal is submitted on chain to provide time for community feedback. ## XCM Disclosures {: #xcm-disclosure } The first post that should be made are the key disclosures within the [XCM Disclosures category](https://forum.moonbeam.network/c/xcm-hrmp/xcm-disclosures/15){target=\_blank}, which highlight key information that is important to a voter's decision. This post is only required when establishing an XCM integration; it is not necessary if the integration already exists and you only need to register an asset. Once you hit the **New Topic** button, a template is provided with the relevant information to be filled in. Please use either the Moonbeam/Moonriver tag, depending on the network you are integrating with. In the post, please provide the following information: - **Title** - XCM Disclosure: *YOUR_NETWORK_NAME* - **Network Information** — one sentence summarizing your network and relevant links to your website, Twitter, and other social channels You'll also need to provide answers to the following questions: - Is the blockchain network's code open source? If so, please provide the GitHub link. If not, provide an explanation of why not - Is SUDO disabled on the network? If SUDO is disabled, is the network controlled by a select group of addresses? - Has the integration of the network been tested completely on the Moonbase Alpha TestNet? - (For Moonbeam HRMP proposals only) Does your network have a Kusama deployment? If so, provide its network name and whether the Kusama deployment is integrated with Moonriver - Is the blockchain network's code audited? If so, please provide: - Auditor name(s) - Dates of audit reports - Links to audit reports ## XCM Proposals {: #xcm-proposals } The second post is a preliminary draft of the proposal in the [XCM Proposals category](https://forum.moonbeam.network/c/xcm-hrmp/xcm-proposals/14){target=\_blank}. Once a proposal is submitted on-chain and available for voting, you must also add a description to it in either the [Moonbeam Polkassembly](https://moonbeam.polkassembly.io/opengov){target=\_blank} or [Moonriver Polkassembly](https://moonriver.polkassembly.io/opengov){target=\_blank}. Once you hit the **New Topic** button, a template is provided with the relevant information to be filled in. Please use either the Moonbeam or Moonriver tag, depending on the network you are integrating with. In both the Moonbeam XCM Proposals forum post and in Polkassembly, add the following sections and information: - **Title** — *YOUR_NETWORK_NAME* Proposal to Open Channel & Register *ASSET_NAME*. If you're only registering an asset, you can use: *YOUR_NETWORK_NAME* Proposal to Register *ASSET_NAME* - **Introduction** — one sentence summarizing the proposal - **Network Information** — one sentence summarizing your network and relevant links to your website, Twitter, and other social channels - **Summary** — brief description of the content of the proposal - **On-Chain Proposal Reference** — include if it is a Moonbeam or Moonriver proposal, the proposal number, and the proposal hash - **Technical Details** — provide technical information required for the community to understand the use cases and purpose of the proposal - **Additional Information** — any additional information you would like the community to know --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc-registration/self-serve-asset-registration/ --- BEGIN CONTENT --- --- title: Self-Serve Asset Registration description: This guide shows sibling parachains how to register native tokens as foreign assets on Moonbeam via ForeignAssetOwnerOrigin to unlock ERC-20 UX on Moonbeam. categories: XCM --- # Self-Serve Asset Registration for Sibling Parachains ## Introduction {: #introduction } Registering your parachain's native tokens on Moonbeam or Moonriver lets your community enjoy ERC‑20–style UX and deep EVM integrations while retaining full on‑chain provenance. This guide shows sibling Polkadot parachain teams how to self‑register a foreign asset using the new `ForeignAssetOwnerOrigin` introduced in Moonbeam Runtime 3600. ### Why a New Origin? {: #why-a-new-origin } Moonbeam introduced a new dedicated origin called `ForeignAssetOwnerOrigin`, which only permits an XCM message whose origin contains the asset's multilocation to execute calls in the `evm‑foreign‑assets` pallet. In practice, that means only the sovereign account of the parachain that owns the asset, or Moonbeam governance, can create, freeze, unfreeze, or relocate it. Alongside this, a configurable runtime constant called `ForeignAssetCreationDeposit` is reserved from the caller's sovereign account at creation time. The deposit discourages spam registrations. ## Required Deposits {: #required-deposits } To prevent spam, a `ForeignAssetCreationDeposit` is required and locked for the lifetime of the asset. The deposit is funded from the sibling parachain's sovereign account on the Moonbeam network, which thus needs to be sufficiently funded to cover the asset deposit and the associated transaction fees. If the asset is destroyed through governance, the deposit is unreserved and returned to the original sovereign account. Deposits are network‑specific and can be adjusted by Moonbeam governance via the `parameters` pallet: === "Moonbeam" | Variable | Value | |:--------------:|:-------------------------------------------------:| | Foreign Asset Deposit | {{ networks.moonbeam.xcm.foreign_asset_deposit.display }} GLMR | === "Moonriver" | Variable | Value | |:--------------:|:-------------------------------------------------:| | Foreign Asset Deposit | {{ networks.moonriver.xcm.foreign_asset_deposit.display }} MOVR | === "Moonbase Alpha" | Variable | Value | |:--------------:|:-------------------------------------------------:| | Foreign Asset Deposit | {{ networks.moonbase.xcm.foreign_asset_deposit.display }} DEV | ## Prerequisites {: #prerequisites } There are a few prerequisites to be aware of: - The sibling parachain's [sovereign account](/builders/interoperability/xcm/core-concepts/sovereign-accounts/){target=\_blank} on Moonbeam must be sufficiently funded to cover the asset deposit and the transaction fees. It's recommended that you have an extra buffer of additional funds for any subsequent transactions. See this [guide to calculating a sovereign account](/builders/interoperability/xcm/core-concepts/sovereign-accounts/){target=\_blank} - Your parachain should support XCM V4 - Your parachain needs bidirectional XCM channels with Moonbeam. See this [guide for information on opening XCM channels with Moonbeam](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} ## Assemble Your Asset Details {: #assemble-your-asset-details } Before you register your sibling-parachain token on Moonbeam, you'll need to gather four pieces of information: * **`AssetID`**: A deterministic `u128` derived from the token's `multilocation` (see below). * **`Decimals`**: How many decimal places the token uses (for example, `18`). * **`Symbol`**: A short ticker such as `xcTEST`. The ticker should be prepended with `xc`. * **`Name`**: A human-readable name such as `Test Token`. ```typescript const ASSET_ID = 42259045809535163221576417993425387648n; const DECIMALS = 18n; const SYMBOL = "xcTEST"; const NAME = "Test Token"; ``` ### How to Calculate Asset ID {: #calculate-asset-id } To generate a token's asset ID, you'll first need to know its multilocation. `assetLocation` is a SCALE‑encoded multilocation that pinpoints the existing token on your sibling parachain. There are various ways to define assets and your multilocation may including parachain ID, the pallet that manages assets there, and the local asset index. Because the extrinsic executes on Moonbeam, you describe the path from Moonbeam's perspective: first hop up one level to the Relay `("parents": 1)`, then down into your parachain `(Parachain: )`, the pallet, and the asset index. Moonbeam uses this to verify that the caller actually "contains" the asset before allowing any registration or updates. Once you've constructed your multilocation, keep it handy, as you'll need it in the next step. A typical asset multilocation looks like this: ```jsonc { "parents": 1, // Up to Relay "interior": { "X3": [ // Down to sibling para asset { "Parachain": 4 }, { "PalletInstance": 12 }, { "GeneralIndex": 15 } // Arbitrary example values ] } } ``` The XCM tools repo has a helpful [Calculate External Asset Info script](https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-external-asset-info.ts){target=\_blank} that you can use to generate the asset ID programmatically. The script takes two parameters, namely, the multilocation of your asset and the target network (Moonbeam or Moonriver). Call the `calculate-external-asset-info.ts` helper script with your asset's multilocation and target network, as shown below, to easily generate its asset ID. ```bash ts-node scripts/calculate-external-asset-info.ts \ --asset '{"parents":1,"interior":{"X3":[{"Parachain":4},{"PalletInstance":12},{"GeneralIndex":15}]}}' \ --network moonbeam ``` The script will return the `assetID` you are now ready to pass to `evmForeignAssets.createForeignAsset`. ### Derive the XC-20 Address Convert `assetID` to hex, left-pad it to 32 hex chars, and prepend eight `F`s as follows: ```text xc20Address = 0xFFFFFFFF + hex(assetId).padStart(32, '0') ``` The XC-20 address of xcDOT as an example can be calculated like so: === "Formula" ```ts const xc20Address = `0xFFFFFFFF${hex(assetId).padStart(32, "0")}`; ``` === "Example" ```bash 0xFFFFFFFF1FCACBD218EDC0EBA20FC2308C778080 ``` ## Generate the Encoded Call Data {: #generate-the-encoded-call-data } The snippet below shows how to build the call that needs to be sent to Moonbeam that creates the foreign asset. Save the resulting hex string because you will embed it inside a subsequent XCM `Transact` call dispatched from your sibling parachain. ```ts import '@moonbeam-network/api-augment'; import { ApiPromise, WsProvider } from '@polkadot/api'; import { blake2AsHex } from '@polkadot/util-crypto'; const moonbeam = await ApiPromise.create({ provider: new WsProvider(MOONBEAM_WSS), }); const tx = moonbeam.tx.evmForeignAssets.createForeignAsset( ASSET_ID, assetLocation, DECIMALS, SYMBOL, NAME ); // SCALE-encoded call data (includes call index 0x3800) const encodedCall = tx.method.toHex(); console.log('Encoded call data:', encodedCall); // Optional: 32-byte call hash (blake2_256) console.log('Call hash:', blake2AsHex(encodedCall)); ``` ### Dispatch the Call with XCM Transact {: #dispatch-the-call-with-xcm-transact } To register your asset, wrap the SCALE‑encoded `createForeignAsset` bytes in a single `Transact` instruction executed from your parachain's sovereign account. The basic structure of the call is outlined below: ```text Transact { originKind: SovereignAccount, requireWeightAtMost: , call: } ``` Send the transact instruction via `xcmPallet.send`, targeting parachain `2004` for Moonbeam (or `2023` for Moonriver). ```rust xcmPallet.send( dest: { Parachain: 2004 }, message: VersionedXcm::V4(INSERT_TRANSACT_INSTRUCTION) ); ``` Finally, look for the following event emitted successfully on Moonbeam: ```text EvmForeignAssets.ForeignAssetCreated(assetId, location, creator) ``` Its presence confirms the XC-20 asset is live. ## Managing an Existing Foreign Asset {: #managing-an-existing-foreign-asset } After a foreign asset has been created, the following extrinsics can be used to update it. Note that in the case of the sovereign account sending a call, the sovereign account and location must still be inside the origin. Otherwise, the only other authorized origin is `Root` from a Moonbeam governance action. | Extrinsic | Who can call? | Notes | |-----------------------------------------------|--------------------------------------------------|-------------------------------------------------------| | `changeXcmLocation` | Sibling sovereign account or Moonbeam governance | Requires deposit already reserved. | | `freezeForeignAsset` / `unfreezeForeignAsset` | Sibling sovereign account or Moonbeam governance | `freeze` optionally destroys the asset's metadata. | ## FAQs {: #faqs } ### How do I reclaim the deposit? Deposits remain reserved for the life of the asset. If the asset is destroyed through governance, the deposit is unreserved and returned to the original sovereign account. ### Can a normal EOA register an asset? No. Calls from non‑sovereign, non‑governance accounts fail with `BadOrigin`. ### What happens if my XCM location is outside my origin? The call is rejected with `LocationOutsideOfOrigin`. Double‑check the `Parachain`, `PalletInstance`, and `GeneralIndex` fields. ### Is there a limit to how many assets can be created? Yes, there is a limit of `256` foreign assets per network (e.g., Moonbeam, Moonriver). Attempts beyond this return `TooManyForeignAssets`. If this threshold is approached, a revision can be made in a future runtime upgrade to lift this limit. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc-registration/xc-integration/ --- BEGIN CONTENT --- --- title: Open a Cross-Chain Channel description: Learn how to establish a cross-chain integration with a Moonbeam-based network. Including opening and accepting an HRMP channel and registering assets. categories: XCM, Integrations --- # How to Establish an XC Integration with Moonbeam ## Introduction {: #introduction } While Cross-Chain Message Passing (XCMP) is being developed, a stop-gap protocol has been implemented called Horizontal Relay-routed Message Passing (HRMP). It has the same interface and functionality as XCMP, but the messages are stored in and read from the relay chain. Whereas with XCMP, only the message's associated metadata is stored in the relay chain. Since all messages are passed via the relay chain with HRMP, it is much more demanding on resources. As such, HRMP will be phased out once XCMP is implemented. All XCMP channel integrations with Moonbeam are unidirectional, meaning messages flow only in one direction. If chain A initiates a channel to chain B, chain A will only be allowed to send messages to B, and B will not be able to send messages back to chain A. As such, chain B will also need to initiate a channel with chain A to send messages back and forth between the two chains. Once the XCMP (or HRMP) channels have been opened, the corresponding assets from both chains will need to be registered on the opposing chain before being able to be transferred. To find step-by-step details on how to register an asset, you can refer to the [How to Register Cross-Chain Assets](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} guide. This guide will cover the process of opening and accepting an HRMP channel between a parachain and a Moonbeam-based network. In addition, the guide provides the necessary steps to create a batch proposal that combines opening and accepting a channel and registering an asset on Moonbeam into a single proposal. All of the examples in this guide use a CLI tool developed to ease the entire process, which you can find in the [xcm-tools GitHub repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank}. ```bash git clone https://github.com/Moonsong-Labs/xcm-tools && \ cd xcm-tools && \ yarn ``` ## Moonbase Alpha XCM Integration Overview {: #moonbase-alpha-xcm } The first step for a Moonriver/Moonbeam XCM integration is to integrate with the Moonbase Alpha TestNet through the Alphanet relay chain. Then a Moonriver integration must be completed before proceeding with Moonbeam (if applicable). The entire process of getting started with Moonbase Alpha can be summarized as follows: 1. [Sync a node](#sync-a-node) with the Alphanet relay chain 2. [Calculate your parachain Sovereign account](#calculate-and-fund-the-parachain-sovereign-account) on the Alphanet relay chain 3. Once your node is fully synced, please get in touch with the Moonbeam team on [Telegram](https://t.me/Moonbeam_Official){target=\_blank} or [Discord](https://discord.com/invite/PfpUATX){target=\_blank}, so the team can onboard your parachain to the relay chain. Provide the following information for onboarding: - The WASM/Genesis head hash - Your parachain ID - Your Sovereign account's address. The Moonbeam team will fund your Sovereign account at the relay chain level. This step is required to be able to create the HRMP channel - The encoded call data to open an HRMP channel to your parachain, accept the incoming HRMP channel, and [register the assets](/builders/interoperability/xcm/xc-registration/assets/#register-xc-20s){target=\_blank} (if applicable). This will be executed through sudo 4. Open an HRMP channel to Moonbase Alpha from your parachain (through sudo or via governance) 5. Accept the HRMP channel from Moonbase Alpha (through sudo or via governance) 6. (Optional) [Register Moonbase Alpha's DEV token](/builders/interoperability/xcm/xc-registration/assets/#register-moonbeam-native-assets){target=\_blank} on your parachain 7. For testing the XCM integration, please send some tokens to: ```text AccountId (Encoded): 5GWpSdqkkKGZmdKQ9nkSF7TmHp6JWt28BMGQNuG4MXtSvq3e Decoded (32-Bytes): 0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063 ``` 8. Test the XCM integration ![Moonbase Alpha cross-chain integration process](/images/builders/interoperability/xcm/xc-registration/xc-integration/channels-1.webp) Once all of these steps are completed and both teams have successfully tested asset transfers, your parachain token can be added to the **Cross Chain Assets** section of the [Moonbeam DApp](https://apps.moonbeam.network/moonbase-alpha){target=\_blank}. If deposits and withdrawals work as expected, integration with Moonriver can begin. ### Sync a Node {: #sync-a-node } To sync a node, you can use the [Alphanet relay chain specs](https://raw.githubusercontent.com/moonbeam-foundation/moonbeam/refs/heads/master/specs/alphanet/westend-embedded-specs-v8.json){target=\_blank} (note: the relay chain is Westend-based, and will probably take one day to sync). For reference, you can use [Moonbase Alpha's spec file](https://raw.githubusercontent.com/moonbeam-foundation/moonbeam/runtime-1103/specs/alphanet/parachain-embedded-specs-v8.json){target=\_blank}. You'll need to adapt it to your chain. There are also some [snapshots for the Alphanet ecosystem relay chain](https://www.certhum.com/moonbase-databases){target=\_blank} you can use to quickly get started, these are provided by the community. ### Calculate and Fund the Parachain Sovereign Account {: #calculate-and-fund-the-parachain-sovereign-account } You can calculate the Sovereign account information using [a script from the xcm-tools repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank}. To run the script, you must provide the parachain ID and the name of the associated relay chain. You can find the parachain IDs that have already been used on the [relay chain's Polkadot.js Apps page](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/parachains){target=\_blank}. The accepted values for the relay chain are `polkadot` (default), `kusama`, and `moonbase`. For example, Moonbase Alpha's Sovereign account for both the relay chain and other parachains can be obtained with the following: ```bash yarn calculate-sovereign-account --p 1000 --r moonbase ``` Which should result in the following response: ```text Sovereign Account Address on Relay: 0x70617261e8030000000000000000000000000000000000000000000000000000 Sovereign Account Address on other Parachains (Generic): 0x7369626ce8030000000000000000000000000000000000000000000000000000 Sovereign Account Address on Moonbase Alpha: 0x7369626ce8030000000000000000000000000000 ``` ## Moonriver & Moonbeam XCM Integration Overview {: #moonriver-moonbeam } From a technical perspective, the process of creating an HRMP channel with Moonriver and Moonbeam is nearly identical. However, engagement with the Moonbeam community is crucial and required before a proposal will pass. Please check the HRMP channel guidelines that the community voted on for [Moonriver](https://moonriver.polkassembly.io/referenda/0){target=\_blank} and [Moonbeam](https://moonbeam.polkassembly.io/proposal/21){target=\_blank} before starting. The process can be summarized in the following steps: 1. Open (or ensure there is) an HRMP channel from your chain to Moonriver/Moonbeam. Optionally, register MOVR/GLMR 2. Create [two Moonbeam Community forum posts](#create-forum-posts) with some key information for the XCM integration: - An [XCM Disclosure post](/builders/interoperability/xcm/xc-registration/forum-templates/#xcm-disclosure), where you'll provide some disclosures about the project, the code base, and social network channels - An [XCM Proposal post](/builders/interoperability/xcm/xc-registration/forum-templates/#xcm-proposals), where you'll provide some technical information about the proposal itself 3. Create a batch proposal on Moonbeam/Moonriver to: 1. Accept the incoming HRMP channel 2. Propose the opening of an outgoing HRMP channel from Moonriver/Moonbeam 3. Register the asset as an [XC-20 token](/builders/interoperability/xcm/xc20/overview/){target=\_blank} (if applicable) Proposals should be done in the General Admin Track from [OpenGov](/learn/features/governance/#opengov){target=\_blank}. The normal enactment times are as follows: - **Moonriver** - the Decision Period is approximately {{ networks.moonriver.governance.tracks.general_admin.decision_period.time }} and the enactment time is at least {{ networks.moonriver.governance.tracks.general_admin.min_enactment_period.time }} - **Moonbeam** - the Decision Period is approximately {{ networks.moonbeam.governance.tracks.general_admin.decision_period.time }} and the enactment time is at least {{ networks.moonbeam.governance.tracks.general_admin.min_enactment_period.time }} 4. Accept the HRMP channel from Moonriver/Moonbeam on the connecting parachain 5. Exchange $50 worth of tokens for testing the XCM integration. Please send the tokens to: ```text AccountId (Encoded): 5E6kHM4zFdH5KEJE3YEzX5QuqoETVKUQadeY8LVmeh2HyHGt Decoded (32-Bytes): 0x5a071f642798f89d68b050384132eea7b65db483b00dbb05548d3ce472cfef48 ``` 6. Provide an Ethereum-styled address for MOVR/GLMR 7. Test the XCM integration with the provided tokens An example of this process with a successful proposal on Moonbeam is depicted in the following diagram. ![Moonbeam and Moonriver cross-chain integration process](/images/builders/interoperability/xcm/xc-registration/xc-integration/channels-2.webp) Once these steps are successfully completed, marketing efforts can be coordinated, and the new XC-20 on Moonriver/Moonbeam can be added to the **Cross Chain Assets** section of the [Moonbeam DApp](https://apps.moonbeam.network){target=\_blank}. ### Create Forum Posts {: #create-forum-posts } To create forum posts on the [Moonbeam Community Forum](https://forum.moonbeam.network){target=\_blank}, you'll need to make sure that you're adding the posts to the correct category and adding relevant content. For general guidelines and templates to follow, please refer to the [Moonbeam Community Forum Templates for XCM Integrations](/builders/interoperability/xcm/xc-registration/forum-templates/#){target=\_blank} page. ## Creating HRMP Channels {: #create-an-hrmp-channel } Before any messages can be sent from your parachain to Moonbeam, an HRMP channel must be opened. To create an HRMP channel, you'll need to send an XCM message to the relay chain that will request a channel be opened through the relay chain. The message will need to contain **at least** the following XCM instructions: 1. [WithdrawAsset](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} - takes funds out of the Sovereign account (in the relay chain) of the origin parachain to a holding state 2. [BuyExecution](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} - buys execution time from the relay chain to execute the XCM message 3. [Transact](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} - provides the relay chain call data to be executed. In this case, the call will be an HRMP extrinsic !!! note You can add [DepositAsset](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank} to refund the leftover funds after the execution. If this is not provided, no refunds will be made. In addition, you could also add a [RefundSurplus](/builders/interoperability/xcm/core-concepts/instructions/#refund-surplus){target=\_blank} after [Transact](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} to get any leftover funds not used for the Transact. But you'll have to calculate if it is worth paying the execution cost of the extra XCM instructions. To send these XCM messages to the relay chain, the [Polkadot XCM Pallet](https://github.com/paritytech/polkadot-sdk/tree/{{ polkadot_sdk }}/polkadot/xcm/pallet-xcm){target=\_blank} is typically invoked. Moonbeam also has an [XCM Transactor Pallet](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank} that simplifies the process into a call that abstracts the XCM messaging constructor. You could potentially generate the calldata for an HRMP action by using Polkadot.js Apps, but the [xcm-tools GitHub repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} can build it for you, and it is the recommended tool for this process. ```bash git clone https://github.com/Moonsong-Labs/xcm-tools && \ cd xcm-tools && \ yarn ``` The xcm-tools repository has a specific script for HRMP interactions called [`hrmp-channel-manipulator.ts`](https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/hrmp-channel-manipulator.ts){target=\_blank}. This command generates encoded calldata for a specific HRMP action, as long as it is given the correct details. The script builds the XCM message with the DepositAsset XCM instruction but not with RefundSurplus. The encoded calldata is then used to submit a governance proposal that will execute the HRMP action. All HRMP-related proposals should be assigned to the General Admin Track. The `hrmp-channel-manipulator.ts` script is meant to be generic. It should work for any chain that includes the Polkadot XCM Pallet, although it will try to use the `hrmpManage` extrinsic of the XCM Transactor Pallet first. If the XCM Transactor Pallet doesn't exist on a chain, the `send` extrinsic of the Polkadot XCM Pallet will be used. **Note that it expects the pallet name to be `polkadotXcm`, as the extrinsic will be built as `api.tx.polkadotXcm.send()`**. For Moonbeam, the General Admin Track can't execute `polkadotXcm.send` calls, as such the `xcmTransactor.hrmpManage` extrinsic must be used. The following sections go through the steps of creating and accepting open channel requests in a Moonbeam-based network, but they can also be adapted to your parachain. ### Accept an HRMP Channel on Moonbeam {: #accept-an-hrmp-channel-on-moonbeam } When a parachain receives an incoming HRMP channel open request from another parachain, it must signal to the relay chain that it accepts this channel before the channel can be used. This requires an XCM message to the relay chain with the Transact instruction calling the HRMP Pallet and `hrmpAcceptOpenChannel` extrinsic. Fortunately, the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} GitHub repository's `hrmp-channel-manipulator.ts` script can build the XCM for you! To use the script, you'll need to provide the following required arguments: - `--parachain-ws-provider` or `--w` - specifies the parachain WebSocket provider that will be issuing the requests - `--relay-ws-provider` or `--wr` - specifies the relay chain WebSocket provider that will be issuing the requests - `--hrmp-action` or `--hrmp` - accepts the following action to take, which can be any of the following: `accept`, `cancel`, `close`, and `open` - `--target-para-id` or `-p` - the target parachain ID for the requests Running the following command will provide the encoded calldata to accept an open HRMP channel request on a Moonbeam network. Replace `YOUR_PARACHAIN_ID` with the ID of your parachain: === "Moonbeam" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbeam.network \ --relay-ws-provider wss://rpc.polkadot.io \ --hrmp-action accept ``` === "Moonriver" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonriver.moonbeam.network \ --relay-ws-provider wss://kusama-rpc.polkadot.io \ --hrmp-action accept ``` === "Moonbase Alpha" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbase.moonbeam.network \ --relay-ws-provider wss://relay.api.moonbase.moonbeam.network \ --hrmp-action accept ``` !!! note You can adapt the script for your parachain by changing the `parachain-ws-provider`. After running the script, you'll see output that looks like the following:
yarn hrmp-manipulator --target-para-id 3370 \ --parachain-ws-provider wss://moonbeam.public.blastapi.io \ --relay-ws-provider wss://polkadot-rpc.publicnode.com \ --hrmp-action accept yarn run v1.22.22 warning ../../../package.json: No license field $ ts-node 'scripts/hrmp-channel-manipulator.ts' --target-para-id 3370 --parachain-ws-provider wss://moonbeam.public.blastapi.io --relay-ws-provider wss://polkadot-rpc.publicnode.com --hrmp-action accept Genesis hash is: 0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3 Polkadot FeeAmount is: 10000000000 XCM Version is V4 Encoded Call Data for Tx is 0x6b09012a0d0000010401000100e40b5402000000000000000000000002286bee020004000100 ✨ Done in 4.39s.
Running the script as shown above will return the encoded calldata to accept an HRMP channel. You can also use the script to create and submit a preimage and proposal on chain for the given HRMP action. For Moonbeam and Moonriver, the proposal must be submitted via the General Admin Track. Please refer to the [README](https://github.com/Moonsong-Labs/xcm-tools/tree/main#hrmp-manipulator-script){target=\_blank} for a complete list of the arguments, including optional arguments, and examples on how to use the HRMP-manipulator script. If you plan to batch the transaction with other calls, copy the resultant calldata for later use when using the [batch transactions](#batch-actions-into-one) script. ### Open HRMP Channels from Moonbeam {: #open-an-hrmp-channel-from-moonbeam } Parachains need bidirectional HRMP channels before sending XCM to each other. The first step to establishing an HRMP channel is to create an open channel request. This requires an XCM message to the relay chain with the Transact instruction calling the HRMP Pallet and `hrmpInitOpenChannel` extrinsic. Fortunately, the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} GitHub repository's `hrmp-channel-manipulator.ts` script can build the XCM for you! To use the script, you'll need to provide the following required arguments: - `--parachain-ws-provider` or `--w` - specifies the parachain WebSocket provider that will be issuing the requests - `--relay-ws-provider` or `--wr` - specifies the relay chain WebSocket provider that will be issuing the requests - `--hrmp-action` or `--hrmp` - accepts the following action to take, which can be any of the following: `accept`, `cancel`, `close`, and `open` - `--target-para-id` or `-p` - the target parachain ID for the requests Running the following command will provide the encoded calldata to create the HRMP channel request from a Moonbeam network. The maximum message size and capacity values can be obtained from the relay chain's Configuration Pallet and `activeConfig` extrinsic. Replace `YOUR_PARACHAIN_ID` with the ID of your parachain: === "Moonbeam" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbeam.network \ --relay-ws-provider wss://rpc.polkadot.io \ --max-capacity 1000 --max-message-size 102400 \ --hrmp-action open ``` === "Moonriver" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonriver.moonbeam.network \ --relay-ws-provider wss://kusama-rpc.polkadot.io \ --max-capacity 1000 --max-message-size 102400 \ --hrmp-action open ``` === "Moonbase Alpha" ```bash yarn hrmp-manipulator --target-para-id YOUR_PARACHAIN_ID \ --parachain-ws-provider wss://wss.api.moonbase.moonbeam.network \ --relay-ws-provider wss://relay.api.moonbase.moonbeam.network \ --max-capacity 1000 --max-message-size 102400 \ --hrmp-action open ``` !!! note You can adapt the script for your parachain by changing the `parachain-ws-provider`. After running the script, you'll see output that looks like the following:
yarn hrmp-manipulator --target-para-id 3370 \ --parachain-ws-provider wss://moonbeam.public.blastapi.io \ --relay-ws-provider wss://polkadot-rpc.publicnode.com \ --max-capacity 1000 --max-message-size 102400 \ --hrmp-action open yarn run v1.22.22 warning ../../../package.json: No license field $ ts-node 'scripts/hrmp-channel-manipulator.ts' --target-para-id 3370 --parachain-ws-provider wss://moonbeam.public.blastapi.io --relay-ws-provider wss://polkadot-rpc.publicnode.com --max-capacity 1000 --max-message-size 102400 --hrmp-action open Genesis hash is: 0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3 Polkadot FeeAmount is: 10000000000 XCM Version is V4 Encoded Call Data for Tx is 0x6b09002a0d0000e803000000900100010401000100e40b5402000000000000000000000002286bee020004000100 ✨ Done in 4.25s.
Running the script as shown above will return the encoded calldata to open an HRMP channel. You can also use the script to create and submit a preimage and proposal on-chain for the given HRMP action. For Moonbeam and Moonriver, the proposal must be submitted via the General Admin Track. Please refer to the [README](https://github.com/Moonsong-Labs/xcm-tools/tree/main#hrmp-manipulator-script){target=\_blank} for a complete list of the arguments, including optional arguments, and examples on how to use the HRMP-manipulator script. If you plan to batch the transaction with other calls, copy the resultant calldata for later use when using the [batch transactions](#batch-actions-into-one) script. ## Batch Actions Into One {: #batch-actions-into-one } The most efficient way to complete the XCM process on parachains is to batch all transactions together. The [xcm-tools repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} provides a script to batch extrinsic calls into a single call, thus requiring only a single transaction. This can be helpful if your parachain would like to open an HRMP channel and register an asset simultaneously. This **should be used** when proposing channel registration on a Moonbeam network. If you are registering an asset in addition to establishing a channel, please refer to the [How to Register Cross-Chain Assets](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} guide to learn how to generate the encoded calldata required for asset registration. The process of batching all of the transactions into one is depicted in the following diagram. ![Batch XCM integration process](/images/builders/interoperability/xcm/xc-registration/xc-integration/channels-3.webp) You will now use the encoded calldata outputs for opening a channel, accepting a channel, and registering an asset and insert them into the following command to send the batch proposal to democracy. You can add a `--call "INSERT_CALL"` for each call you want to batch. Replace the following values before running the command: - `OPEN_CHANNEL_CALL` is the SCALE encoded calldata for [opening an HRMP channel](#open-an-hrmp-channel-from-moonbeam) from Moonbeam to your parachain - `ACCEPT_INCOMING_CALL` is the SCALE encoded calldata for [accepting the channel request](#accept-an-hrmp-channel-on-moonbeam) from your parachain - `REGISTER_ASSET_CALL` is the SCALE encoded calldata for [registering a cross-chain asset](/builders/interoperability/xcm/xc-registration/assets/#register-xc-20s){target=\_blank}. If you have more than one asset to be registered on Moonbeam, you can include additional registration SCALE encoded calldata with additional `--call` flags === "Moonbeam" ```bash yarn generic-call-propose -w wss://wss.api.moonbeam.network \ --call "OPEN_CHANNEL_CALL" \ --call "ACCEPT_INCOMING_CALL" \ --call "REGISTER_ASSET_CALL" \ ``` === "Moonriver" ```bash yarn generic-call-propose -w wss://wss.api.moonriver.moonbeam.network \ --call "OPEN_CHANNEL_CALL" \ --call "ACCEPT_INCOMING_CALL" \ --call "REGISTER_ASSET_CALL" \ ``` === "Moonbase Alpha" ```bash yarn generic-call-propose -w wss://wss.api.moonbase.moonbeam.network \ --call "OPEN_CHANNEL_CALL" \ --call "ACCEPT_INCOMING_CALL" \ --call "REGISTER_ASSET_CALL" \ ``` !!! note You can readapt the script for your parachain by changing the `parachain-ws-provider`. With the encoded calldata, you can then submit the governance proposal. For Moonbeam and Moonriver, you must assign the proposal to the General Admin Track. It is recommended to become familiar with the [OpenGov: Governance v2 process on Moonbeam-based networks](/learn/features/governance/#opengov){target=\_blank}. If you want to send the governance proposal directly from the CLI, you'll need to use these additional flags: ```bash --account-priv-key YOUR_PRIVATE_KEY \ --send-preimage-hash true \ --send-proposal-as v2 \ --track '{ "Origins": "GeneralAdmin" }' ``` For Moonbase Alpha, you will not need to provide a private key or go through governance. Instead, you can use the `--sudo` flag and provide the output to the Moonbeam team so that the asset and channel can be added quickly through sudo. Feel free to check out the [additional flags](#additional-flags-xcm-tools) available for this script. ## Additional Flags for XCM-Tools {: #additional-flags-xcm-tools } The [xcm-tools GitHub repository](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} and most of its functions can be called with some additional flags that create some wrappers around the actions being taken. For example, you might want to wrap the send of the XCM message in sudo, or via a democracy proposal. The complete options that can be used with the script are as follows: | Flag | Type | Description | | :------------------: | :---------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | account-priv-key | string | (Required for send-proposal-as, send-preimage-hash) The private key of the account to send a transaction with | | sudo | boolean | Whether to wrap the extrinsic calldata inside of a `sudo.sudo` extrinsic. If `account-priv-key` is present, it will attempt to send the transaction | | send-preimage-hash | boolean | Whether to submit the encoded calldata as a preimage and retrieve its hash | | send-proposal-as | democracy/council-external/v2 | Whether to send the encoded calldata through democracy or Council (Governance v1), or OpenGov (Governance v2) | | collective-threshold | number | (Required for council-external) The threshold for the Council deciding the proposal | | delay | number | (Required for v2) The number of blocks to delay an OpenGovV2 proposal's execution by | | track | string (JSON encoded origin) | (Required for v2) The JSON encoded origin for an OpenGovV2 proposal. For Moonbeam networks: "Root", "WhitelistedCaller", "GeneralAdmin", "ReferendumCanceller", "ReferendumKiller" | | at-block | number | Whether to wrap the extrinsic calldata inside of a `scheduler.schedule` extrinsic. The block in the future that the action should be scheduled to take place | | fee-currency | string (multilocation) | (Required for non-Moonbeam chains that use XCM Transactor) The multilocation of the relay chain's asset | !!! note The track option must be specified like so: `'{ "Origins": "INSERT_ORIGIN" }'`, where you can insert any of the following as the Origin: "Root", "WhitelistedCaller", "GeneralAdmin", "ReferendumCanceller", "ReferendumKiller". --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc20/send-xc20s/eth-api/ --- BEGIN CONTENT --- --- title: XCM Precompile description: Learn about the XCM Precompile and how to use it to transfer assets from Moonbeam networks to other parachains. categories: XCM, Precompiles --- # XCM Precompile ## Introduction {: #introduction } As a Polkadot parachain, Moonbeam has the inherent ability to communicate and exchange data with other connected parachains. This native cross-chain communication allows safe and fast token transfers leveraging the Cross-Consensus Message format (XCM for short), facilitating communication between different consensus systems. The communication protocol enabling token transfers is built on [Substrate](/builders/substrate/){target=\_blank} and runs on a lower level than the EVM, making it harder for EVM developers to access. Nevertheless, Moonbeam networks have an XCM Precompile that fills the gap between execution layers. This precompile exposes a smart contract interface that abstracts away the underlying complexities, making the execution of cross-chain token transfers as easy as any other smart contract call. This guide will show you how to interact with the [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} precompile to execute cross-chain token transfers through the Ethereum API. The XCM Precompile is located at the following address: === "Moonbeam" ```text {{networks.moonbeam.precompiles.xcm_interface }} ``` === "Moonriver" ```text {{networks.moonriver.precompiles.xcm_interface }} ``` === "Moonbase Alpha" ```text {{networks.moonbase.precompiles.xcm_interface }} ``` !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. ## The XCM Solidity Interface {: #the-xcm-solidity-interface } The [`XCMInterface.sol`](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} is a Solidity interface that allows developers to interact with the methods of `pallet-xcm`. ??? code "XCMInterface.sol" ```solidity // SPDX-License-Identifier: GPL-3.0-only pragma solidity >=0.8.3; /// @dev The XCM contract's address. address constant XCM_CONTRACT_ADDRESS = 0x000000000000000000000000000000000000081A; /// @dev The XCM contract's instance. XCM constant XCM_CONTRACT = XCM(XCM_CONTRACT_ADDRESS); /// @author The Moonbeam Team /// @title XCM precompile Interface /// @dev The interface that Solidity contracts use to interact with the substrate pallet-xcm. interface XCM { // A location is defined by its number of parents and the encoded junctions (interior) struct Location { uint8 parents; bytes[] interior; } // Support for Weights V2 struct Weight { uint64 refTime; uint64 proofSize; } // A way to represent fungible assets in XCM using Location format struct AssetLocationInfo { Location location; uint256 amount; } // A way to represent fungible assets in XCM using address format struct AssetAddressInfo { address asset; uint256 amount; } // The values start at `0` and are represented as `uint8` enum TransferType { Teleport, LocalReserve, DestinationReserve } /// @dev Function to send assets via XCM using transfer_assets() pallet-xcm extrinsic. /// @custom:selector 9ea8ada7 /// @param dest The destination chain. /// @param beneficiary The actual account that will receive the tokens on dest. /// @param assets The combination (array) of assets to send in Location format. /// @param feeAssetItem The index of the asset that will be used to pay for fees. function transferAssetsLocation( Location memory dest, Location memory beneficiary, AssetLocationInfo[] memory assets, uint32 feeAssetItem ) external; /// @dev Function to send assets via XCM to a 20 byte-like parachain /// using transfer_assets() pallet-xcm extrinsic. /// @custom:selector a0aeb5fe /// @param paraId The para-id of the destination chain. /// @param beneficiary The actual account that will receive the tokens on paraId destination. /// @param assets The combination (array) of assets to send in Address format. /// @param feeAssetItem The index of the asset that will be used to pay for fees. function transferAssetsToPara20( uint32 paraId, address beneficiary, AssetAddressInfo[] memory assets, uint32 feeAssetItem ) external; /// @dev Function to send assets via XCM to a 32 byte-like parachain /// using transfer_assets() pallet-xcm extrinsic. /// @custom:selector f23032c3 /// @param paraId The para-id of the destination chain. /// @param beneficiary The actual account that will receive the tokens on paraId destination. /// @param assets The combination (array) of assets to send in Address format. /// @param feeAssetItem The index of the asset that will be used to pay for fees. function transferAssetsToPara32( uint32 paraId, bytes32 beneficiary, AssetAddressInfo[] memory assets, uint32 feeAssetItem ) external; /// @dev Function to send assets via XCM to the relay chain /// using transfer_assets() pallet-xcm extrinsic. /// @custom:selector 6521cc2c /// @param beneficiary The actual account that will receive the tokens on the relay chain. /// @param assets The combination (array) of assets to send in Address format. /// @param feeAssetItem The index of the asset that will be used to pay for fees. function transferAssetsToRelay( bytes32 beneficiary, AssetAddressInfo[] memory assets, uint32 feeAssetItem ) external; /// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm /// extrinsic. /// Important: in this selector RemoteReserve type (for either assets or fees) is not allowed. /// If users want to send assets and fees (in Location format) with a remote reserve, /// they must use the selector fc19376c. /// @custom:selector 8425d893 /// @param dest The destination chain. /// @param assets The combination (array) of assets to send in Location format. /// @param assetsTransferType The TransferType corresponding to assets being sent. /// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees. /// @param feesTransferType The TransferType corresponding to the asset used as fees. /// @param customXcmOnDest The XCM message to execute on destination chain. function transferAssetsUsingTypeAndThenLocation( Location memory dest, AssetLocationInfo[] memory assets, TransferType assetsTransferType, uint8 remoteFeesIdIndex, TransferType feesTransferType, bytes memory customXcmOnDest ) external; /// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm /// extrinsic. /// @custom:selector fc19376c /// @param dest The destination chain. /// @param assets The combination (array) of assets to send in Location format. /// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees. /// @param customXcmOnDest The XCM message to execute on destination chain. /// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST /// share the same reserve. function transferAssetsUsingTypeAndThenLocation( Location memory dest, AssetLocationInfo[] memory assets, uint8 remoteFeesIdIndex, bytes memory customXcmOnDest, Location memory remoteReserve ) external; /// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm /// extrinsic. /// Important: in this selector RemoteReserve type (for either assets or fees) is not allowed. /// If users want to send assets and fees (in Address format) with a remote reserve, /// they must use the selector aaecfc62. /// @custom:selector 998093ee /// @param dest The destination chain. /// @param assets The combination (array) of assets to send in Address format. /// @param assetsTransferType The TransferType corresponding to assets being sent. /// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees. /// @param feesTransferType The TransferType corresponding to the asset used as fees. /// @param customXcmOnDest The XCM message to execute on destination chain. function transferAssetsUsingTypeAndThenAddress( Location memory dest, AssetAddressInfo[] memory assets, TransferType assetsTransferType, uint8 remoteFeesIdIndex, TransferType feesTransferType, bytes memory customXcmOnDest ) external; /// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm /// extrinsic. /// @custom:selector aaecfc62 /// @param dest The destination chain. /// @param assets The combination (array) of assets to send in Address format. /// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees. /// @param customXcmOnDest The XCM message to execute on destination chain. /// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST /// share the same reserve. function transferAssetsUsingTypeAndThenAddress( Location memory dest, AssetAddressInfo[] memory assets, uint8 remoteFeesIdIndex, bytes memory customXcmOnDest, Location memory remoteReserve ) external; } ``` The interface includes the necessary data structures along with the following functions: ???+ function "**transferAssetsToPara20**(_paraId, beneficiary, assets, feeAssetItem_) — sends assets via XCM to a 20 byte-like parachain using the underlying `transfer_assets()` transaction included in the XCM pallet module" === "Parameters" - `paraId` *uint32* - the para-id of the destination chain - `beneficiary` *address* - the ECDSA-type account in the destination chain that will receive the tokens - `assets` *AssetAddressInfo[] memory* - an array of assets to send in Address format - `feeAssetItem` *uint32* - the index of the asset that will be used to pay fees === "Example" - `paraId` - 888 - `beneficiary` - 0x3f0Aef9Bd799F1291b80376aD57530D353ab0217 - `assets` - [["0x0000000000000000000000000000000000000802", 1000000000000000000]] - `feeAssetItem` - 0 ??? function "**transferAssetsToPara32**(_paraId, beneficiary, assets, feeAssetItem_) — sends assets via XCM to a 32 byte-like parachain using the underlying `transfer_assets()` transaction included in the XCM pallet module" === "Parameters" - `paraId` *uint32* - the para-id of the destination chain - `beneficiary` *bytes32* - the actual account that will receive the tokens on paraId destination - `assets` *AssetAddressInfo[] memory* - an array of assets to send in Address format - `feeAssetItem` *uint32* - the index of the asset that will be used to pay fees === "Example" - `paraId` - 888 - `beneficiary` - 0xf831d83025f527daeed39a644d64d335a4e627b5f4becc78fb67f05976889a06 - `assets` - [["0x0000000000000000000000000000000000000802", 1000000000000000000]] - `feeAssetItem` - 0 ??? function "**transferAssetsToRelay**(_beneficiary, assets, feeAssetItem_) — sends assets via XCM to the relay chain using the underlying `transfer_assets()` transaction included in the XCM pallet module" === "Parameters" - `beneficiary` *bytes32* - the actual account that will receive the tokens on the relay chain - `assets` *AssetAddressInfo[] memory* - an array of assets to send in Address format - `feeAssetItem` *uint32* - the index of the asset that will be used to pay fees === "Example" - `beneficiary` - 0xf831d83025f527daeed39a644d64d335a4e627b5f4becc78fb67f05976889a06 - `assets` - [["0x0000000000000000000000000000000000000802", 1000000000000000000]] - `feeAssetItem` - 0 ??? function "**transferAssetsLocation**(_dest, beneficiary, assets, feeAssetItem_) — sends assets using the underlying `transfer_assets()` transaction included in the XCM pallet module" === "Parameters" - `dest` *Location memory* - the destination chain - `beneficiary` *Location memory* - the account in the destination chain that will receive the tokens - `assets` *AssetLocationInfo[] memory* - an array of assets to send - `feeAssetItem` *uint32* - the index of the asset that will be used to pay fees === "Example" - `dest` - ["1",[]] - `beneficiary` - [0, ["0x01f831d83025f527daeed39a644d64d335a4e627b5f4becc78fb67f05976889a0600"]] - `assets` - [[[1, ["0x010000000000000000000000000000000000000800"]], 1000000000000000000]] - `feeAssetItem` - 0 ??? function "**transferAssetsUsingTypeAndThenLocation**(_dest, assets, assetsTransferType, remoteFeesIdIndex, feesTransferType, customXcmOnDest_) — sends assets through `transfer_assets_using_type_and_then()` pallet-xcm extrinsic. Important: RemoteReserve type (for either assets or fees) is prohibited. For sending assets and fees (in Location format) with a remote reserve, use the subsequent `transferAssetsUsingTypeAndThenLocation` which shares the same function name as this but takes a different set of parameters" === "Parameters" - `dest` *Location memory* - the destination chain - `assets` *AssetLocationInfo[] memory* - an array of assets to send in Location format - `assetsTransferType` *TransferType* - the TransferType corresponding to assets being sent (Teleport = 0, LocalReserve = 1, DestinationReserve = 2) - `remoteFeesIdIndex` *uint8* - the index of the asset (inside assets array) to use as fees - `feesTransferType` *TransferType* - the TransferType corresponding to the asset used as fees (Teleport = 0, LocalReserve = 1, DestinationReserve = 2) - `customXcmOnDest` *bytes memory* - the XCM message to execute on destination chain === "Example" - `dest` - ["1",[]] - `assets` - [[[1, ["0x010000000000000000000000000000000000000802"]], 1000000000000000000]] - `assetsTransferType` - 0 - `remoteFeesIdIndex` - 0 - `feesTransferType` - 1 - `customXcmOnDest` - 0x0408000400010403001300008a5d784563010d01020400010300f8234bedd9553e7668c4e0d60aced12e22bd2d45 ??? function "**transferAssetsUsingTypeAndThenLocation**(_dest, assets, remoteFeesIdIndex, customXcmOnDest, remoteReserve_) — sends assets through `transfer_assets_using_type_and_then()` pallet-xcm extrinsic. Important: The remote reserve must be shared between assets and fees" === "Parameters" - `dest` *Location memory* - the destination chain - `assets` *AssetLocationInfo[] memory* - an array of assets to send in Location format - `remoteFeesIdIndex` *uint8* - the index of the asset (inside assets array) to use as fees - `customXcmOnDest` *bytes memory* - the XCM message to execute on destination chain - `remoteReserve` *Location memory* - the remote reserve corresponding for assets and fees (must be shared) === "Example" - `dest` - ["1",[]] - `assets` - [[[1, ["0x010000000000000000000000000000000000000800"]], 1000000000000000000]] - `remoteFeesIdIndex` - 0 - `customXcmOnDest` - 0x0408000400010403001300008a5d784563010d01020400010300f8234bedd9553e7668c4e0d60aced12e22bd2d45 - `remoteReserve` - [1,[]] ??? function "**transferAssetsUsingTypeAndThenAddress**(_dest, assets, assetsTransferType, remoteFeesIdIndex, feesTransferType, customXcmOnDest_) — sends assets through `transfer_assets_using_type_and_then()` pallet-xcm extrinsic. Important: RemoteReserve type (for either assets or fees) is not allowed. For sending assets and fees (in Address format) with a remote reserve, use the subsequent `transferAssetsUsingTypeAndThenAddress`, which shares the same name as this function but takes a different set of parameters" === "Parameters" - `dest` *Location memory* - the destination chain - `assets` *AssetAddressInfo[] memory* - an array of assets to send in Address format - `assetsTransferType` *TransferType* - the TransferType corresponding to assets being sent (Teleport = 0, LocalReserve = 1, DestinationReserve = 2) - `remoteFeesIdIndex` *uint8* - the index of the asset (inside assets array) to use as fees - `feesTransferType` *TransferType* - the TransferType corresponding to the asset used as fees (Teleport = 0, LocalReserve = 1, DestinationReserve = 2) - `customXcmOnDest` *bytes memory* - the XCM message to execute on destination chain === "Example" - `dest` - ["1",[]] - `assets` - [["0x0000000000000000000000000000000000000802", 1000000000000000000]] - `assetsTransferType` - 0 - `remoteFeesIdIndex` - 0 - `feesTransferType` - 1 - `customXcmOnDest` - 0x0408000400010403001300008a5d784563010d01020400010300f8234bedd9553e7668c4e0d60aced12e22bd2d45 ??? function "**transferAssetsUsingTypeAndThenAddress**(_dest, assets, remoteFeesIdIndex, customXcmOnDest, remoteReserve_) — sends assets through `transfer_assets_using_type_and_then()` pallet-xcm extrinsic. Important: The remote reserve must be shared between assets and fees" === "Parameters" - `dest` *Location memory* - the destination chain - `assets` *AssetAddressInfo[] memory* - an array of assets to send in Address format - `remoteFeesIdIndex` *uint8* - the index of the asset (inside assets array) to use as fees - `customXcmOnDest` *bytes memory* - the XCM message to execute on destination chain - `remoteReserve` *Location memory* - the remote reserve corresponding for assets and fees (must be shared) === "Example" - `dest` - ["1",[]] - `assets` - [["0x0000000000000000000000000000000000000802", 1000000000000000000]] - `remoteFeesIdIndex` - 0 - `customXcmOnDest` - 0x0408000400010403001300008a5d784563010d01020400010300f8234bedd9553e7668c4e0d60aced12e22bd2d45 - `remoteReserve` - [1,[]] ## Interact with the Solidity Interface {: #interact-with-the-solidity-interface } ### Checking Prerequisites {: #checking-prerequisites } To follow this tutorial, you must have your preferred EVM wallet configured and an account funded with native tokens. You can add Moonbeam to MetaMask wallet following this guide: [Interacting with Moonbeam Using MetaMask](/tokens/connect/metamask/){target=\_blank}. ### Remix Set Up {: #remix-set-up } You can interact with the XCM Precompile using [Remix](https://remix.ethereum.org){target=\_blank}. To add the precompile to Remix, you will need to: 1. Get a copy of [`XCMInterface.sol`](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} 2. Paste the file contents into a Remix file named `XCMInterface.sol` ### Compile the Contract {: #compile-the-contract } Next, you will need to compile the interface in Remix: 1. Click on the **Compile** tab, second from top 2. Compile the interface by clicking on **Compile XcmInterface.sol** ![Compiling XCMInterface.sol](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-1.webp) When the compilation is completed, you will see a green checkmark next to the **Compile** tab. ### Access the Contract {: #access-the-contract } Instead of deploying the precompile, you will access the interface given the address of the precompiled contract: 1. Click on the **Deploy and Run** tab directly below the **Compile** tab in Remix. Please note that the precompiled contracts are already accessible at their respective addresses. Therefore, there is no deployment step 2. Make sure **Injected Provider - Metamask** is selected in the **ENVIRONMENT** dropdown. Once you select **Injected Provider - Metamask**, you may be prompted by MetaMask to connect your account to Remix if it's not already connected 3. Make sure the correct account is displayed under **ACCOUNT** 4. Ensure **XCM - XcmInterface.sol** is selected in the **CONTRACT** dropdown. Given that it is a precompiled contract, there is no deployment step. Instead, you are going to provide the address of the precompile in the **At Address** field 5. Provide the address of the precompile: `{{networks.moonbeam.precompiles.xcm_interface}}` and click **At Address** ![Access the address](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-2.webp) The **XCM Interface** precompile will appear in the list of **Deployed Contracts**. ### Send Tokens Over to Another EVM-Compatible Appchain {: #transfer-to-evm-chains } To send tokens over to an account in another EVM-compatible appchain, please follow these steps: 1. Expand the **transferAssetsToPara20** function 2. Enter the appchain ID (paraId) 3. Enter the 20-byte (Ethereum-like) destination account (beneficiary) 4. Specify the tokens to be transferred. Note that this parameter is an array that contains at least one asset. Each asset is specified by its address and the total amount to transfer 5. Enter the index of the asset that will be used to pay the fees. This index is zero-based, so the first element is `0`, the second is `1`, and so on 6. Click **transact** 7. MetaMask will pop up, and you will be prompted to review the transaction details. Click **Confirm** to send the transaction ![Confirm Approve Transaction](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-3.webp) After the transaction is confirmed, wait a few blocks for the transfer to reach the destination chain and reflect the new balance. ### Send Tokens Over to a Substrate Appchain {: #transfer-to-substrate-chains } To send tokens over to an account in a Substrate appchain, please follow these steps: 1. Expand the **transferAssetsToPara32** function 2. Enter the appchain ID (`paraId`) 3. Enter the sr25519-type destination account (beneficiary) 4. Specify the tokens to be transferred. Note that this parameter is an array that contains at least one asset. Each asset is specified by its address and the total amount to transfer !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. 5. Enter the index of the asset that will be used to pay the fees. This index is zero-based, so the first element is `0`, the second is `1`, and so on 6. Click **transact** 7. MetaMask will pop up, and you will be prompted to review the transaction details. Click **Confirm** to send the transaction ![Confirm Approve Transaction](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-4.webp) After the transaction is confirmed, wait a few blocks for the transfer to reach the destination chain and reflect the new balance. ### Send Tokens Over to the Relay Chain {: #transfer-to-relay-chain } To send tokens over to an account in the relay chain, please follow these steps: 1. Expand the **transferAssetsToRelay** function 2. Enter the sr25519-type destination account (beneficiary) 3. Specify the tokens to be transferred. Note that this parameter is an array that contains at least one asset. Each asset is specified by its address and the total amount to transfer !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. 4. Enter the index of the asset that will be used to pay the fees. This index is zero-based, so the first element is `0`, the second is `1`, and so on 5. Click **transact** 6. MetaMask will pop up, and you will be prompted to review the transaction details. Click **Confirm** to send the transaction ![Confirm Approve Transaction](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-5.webp) After the transaction is confirmed, wait a few blocks for the transfer to reach the destination chain and reflect the new balance. ### Send Tokens Over Specific Locations {: #transfer-locations } There are two methods that share names with closely related methods, `transferAssetsUsingTypeAndThenLocation` and `transferAssetsUsingTypeAndThenAddress`. However, these are not duplicates. For each function, there is one that accepts five parameters and another that accepts six. The function with five parameters can only be used when the remote reserve is shared between assets and fees. If the remote reserve is not shared between assets and fees, you can use the six parameter version of the method to specify the information needed. The following example will demonstrate `transferAssetsUsingTypeAndThenAddress` when the remote reverse is shared between assets and fees. To follow along with the tutorial, take the following steps: 1. Expand the **transferAssetsUsingTypeAndThenAddress** function 2. Enter the multilocation that specifies the destination chain. Note that any chain can be specified, regardless of its configuration or type 3. Enter the combination array of assets to send in Address format 4. Enter the index of the asset that will be used to pay the fees. This index is zero-based, so the first element is `0`, the second is `1`, and so on 5. Enter the XCM message to be executed on destination chain. For more information about creating XCM call data see [Send and Execute XCM Messages](/builders/interoperability/xcm/send-execute-xcm/) 6. Enter the remote reserve, e.g. `[1,[]]` 7. Click **transact** 8. MetaMask will pop up, and you will be prompted to review the transaction details. Click **Confirm** to send the transaction ![Confirm Approve Transaction](/images/builders/interoperability/xcm/xc20/send-xc20s/eth-api/eth-api-6.webp) After the transaction is confirmed, wait a few blocks for the transfer to reach the destination chain and reflect the new balance. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xcm-utils/ --- BEGIN CONTENT --- --- title: XCM Utilities Precompile Contract description: Learn the various XCM related utility functions available to smart contract developers with Moonbeam's precompiled XCM Utilities contract. keywords: solidity, ethereum, xcm, utils, moonbeam, precompiled, contracts categories: XCM --- # Interacting with the XCM Utilities Precompile ## Introduction {: #xcmutils-precompile} The XCM Utilities Precompile contract gives developers XCM-related utility functions directly within the EVM. This allows for easier transactions and interactions with other XCM-related precompiles. Similar to other [precompile contracts](/builders/ethereum/precompiles/){target=\_blank}, the XCM Utilities Precompile is located at the following addresses: === "Moonbeam" ```text {{networks.moonbeam.precompiles.xcm_utils }} ``` === "Moonriver" ```text {{networks.moonriver.precompiles.xcm_utils }} ``` === "Moonbase Alpha" ```text {{networks.moonbase.precompiles.xcm_utils}} ``` !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. ## The XCM Utilities Solidity Interface {: #xcmutils-solidity-interface } [XcmUtils.sol](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} is an interface to interact with the precompile. !!! note The precompile will be updated in the future to include additional features. Feel free to suggest additional utility functions in the [Discord](https://discord.com/invite/PfpUATX){target=\_blank}. The interface includes the following functions: - **multilocationToAddress**(*Multilocation memory* multilocation) — read-only function that returns the Computed Origin account from a given multilocation - **weightMessage**(*bytes memory* message) — read-only function that returns the weight that an XCM message will consume on the chain. The message parameter must be a SCALE encoded XCM versioned XCM message - **getUnitsPerSecond**(*Multilocation memory* multilocation) — read-only function that gets the units per second for a given asset in the form of a `Multilocation`. The multilocation must describe an asset that can be supported as a fee payment, such as an [external XC-20](/builders/interoperability/xcm/xc20/overview/#external-xc20s){target=\_blank}, or else this function will revert. !!! note Note that this function still returns units per second data but units per second has been deprecated and replaced by the calculation of relative price. See [XC asset registration](/builders/interoperability/xcm/xc-registration/assets#generate-encoded-calldata-for-asset-registration){target=\_blank} for more details. - **xcmExecute**(*bytes memory* message, *uint64* maxWeight) - **available on Moonbase Alpha only** - executes a custom XCM message given the SCALE encoded versioned message to be executed and the maximum weight to be consumed. This function *cannot* be called from a smart contract due to the nature of the `Transact` instruction - **xcmSend**(*Multilocation memory* dest, *bytes memory* message) - **available on Moonbase Alpha only** - sends a custom XCM message given the multilocation of the destination chain to send the message to and the SCALE encoded versioned message to be sent The `Multilocation` struct in the XCM Utilities Precompile is built the same as the [XCM Transactor Precompile's](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-precompile/#building-the-precompile-multilocation){target=\_blank} `Multilocation`. ## Using the XCM Utilities Precompile {: #using-the-xcmutils-precompile } The XCM Utilities precompile allows users to read data off of the Ethereum JSON-RPC instead of having to go through a Polkadot library. The functions are more for convenience, and less for smart contract use cases. For `multilocationToAddress`, one example use case is being able to allow transactions that originate from other parachains by whitelisting their Computed Origin addresses. A user can whitelist a multilocation by calculating and storing an address. EVM transactions can originate from other parachains via [remote EVM calls](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank}. ```solidity // SPDX-License-Identifier: GPL-3.0-only pragma solidity >=0.8.3; import "https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol"; contract MultilocationWhitelistExample { XcmUtils xcmutils = XcmUtils(0x000000000000000000000000000000000000080C); mapping(address => bool) public whitelistedAddresses; modifier onlyWhitelisted(address addr) { _; require(whitelistedAddresses[addr], "Address not whitelisted!"); _; } function addWhitelistedMultilocation( XcmUtils.Multilocation calldata externalMultilocation ) external onlyWhitelisted(msg.sender) { address derivedAddress = xcmutils.multilocationToAddress( externalMultilocation ); whitelistedAddresses[derivedAddress] = true; } ... } ``` To check out an example of how to use the `xcmExecute` function to execute a custom XCM message locally, please refer to the [Create and Execute Custom XCM Messages](/builders/interoperability/xcm/send-execute-xcm/#execute-xcm-utils-precompile){target=\_blank} guide. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/tutorials/interoperability/remote-staking-xcm/ --- BEGIN CONTENT --- --- title: Remote Staking on Moonbeam from Polkadot via XCM description: In this guide, we'll be leveraging remote execution to remotely stake GLMR on Moonbeam using a series of XCM instructions. template: main.html categories: Tutorials, XCM, Staking --- # Remote Staking via XCM _by Kevin Neilson_ ## Introduction {: #introduction } In this tutorial, we’ll stake DEV tokens remotely by sending XCM instructions from an account on the Moonbase relay chain (equivalent to the Polkadot relay chain). This tutorial assumes a basic familiarity with [XCM](/builders/interoperability/xcm/overview/){target=\_blank} and [Remote Execution via XCM](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank}. You don’t have to be an expert on these topics but you may find it helpful to have some XCM knowledge as background. There are actually two possible approaches for staking on Moonbeam remotely via XCM. We could send a [remote EVM call](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank} that calls the [staking precompile](/builders/ethereum/precompiles/features/staking/){target=\_blank}, or we could use XCM to call the [parachain staking pallet](/builders/substrate/interfaces/features/staking/){target=\_blank} directly without interacting with the EVM. For this tutorial, we’ll be taking the latter approach and interacting with the parachain staking pallet directly. **Note that there are still limitations in what you can remotely execute through XCM messages.** In addition, **developers must understand that sending incorrect XCM messages can result in the loss of funds.** Consequently, it is essential to test XCM features on a TestNet before moving to a production environment. ## Checking Prerequisites {: #checking-prerequisites } For development purposes this tutorial is written for Moonbase Alpha and Moonbase relay using TestNet funds. For prerequisites: - A Moonbase Alpha relay chain account funded with some UNIT, the native token of the Moonbase relay chain. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha){target=\_blank} - You'll need to [calculate the Computed Origin account](#calculating-your-computed-origin-account) of your Moonbase Alpha relay chain account and fund it with DEV tokens. You can get DEV tokens for testing on Moonbase Alpha once every 24 hours from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} ## Calculating your Computed Origin Account {: #calculating-your-computed-origin-account } Copy the account of your existing or newly created account on the [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/accounts){target=\_blank}. You're going to need it to calculate the corresponding Computed Origin account, which is a special type of account that’s keyless (the private key is unknown). Transactions from a Computed Origin account can be initiated only via valid XCM instructions from the corresponding account on the relay chain. In other words, you are the only one who can initiate transactions on your Computed Origin account, and if you lose access to your Moonbase relay account, you’ll also lose access to your Computed Origin account. To generate the Computed Origin account, first clone the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} repo. Run `yarn` to install the necessary packages, and then run: ```sh yarn calculate-multilocation-derivative-account \ --ws-provider wss://wss.api.moonbase.moonbeam.network \ --address INSERT_MOONBASE_RELAY_ACCOUNT \ --para-id INSERT_ORIGIN_PARACHAIN_ID_IF_APPLIES \ --parents INSERT_PARENTS_VALUE_IF_APPLIES ``` Let's review the parameters passed along with this command: - The `--ws-provider` or `-w` flag corresponds to the endpoint we’re using to fetch this information - The `--address` or `-a` flag corresponds to your Moonbase relay chain address - The `--para-id` or `-p` flag corresponds to the parachain ID of the origin chain (if applicable). If you are sending the XCM from the relay chain, you don't need to provide this parameter - The `-parents` flag corresponds to the parents value of the origin chain in relation to the destination chain. If you're deriving a multi-location derivative account on a parachain destination from a relay chain origin, this value would be `1`. If left out, the parents value defaults to `0` Here, we have specified a parents value of `1` because the relay chain is the origin of the request (and the relay chain is considered a parent to the Moonbase alpha parachain). The relay chain does not have a parachain id so that field is omitted.
yarn calculate-multilocation-derivative-account \ --ws-provider wss://wss.api.moonbase.moonbeam.network \ --address 5DCvkTpkqo5AuvUFSrT76ABnm48iSBHpgsoDFNxFZAtesvWD \ --parents 1
yarn run v1.22.10 warning ../../../package.json: No license field $ ts-node 'scripts/calculate-multilocation-derivative-account.ts' --ws-provider wss://wss.api.moonbase.moonbeam.network --address 5DCvkTpkqo5AuvUFSrT76ABnm48iSBHpgsoDFNxFZAtesvWD --parents 1
Remote Origin calculated as ParentChain Parents 1 AccountId32: 5DCvkTpkqo5AuvUFSrT76ABnm48iSBHpgsoDFNxFZAtesvWD 32 byte address is 0x55738eb7227f27c9d55775f65ad261c5ac2894dcde73d913f77f69bf51e26279 20 byte address is 0x55738eb7227f27c9d55775f65ad261c5ac2894dc ✨ Done in 1.02s.
The script will return 32-byte and 20-byte addresses. We’re interested in the Ethereum-style account - the 20-byte one. Feel free to look up your Computed Origin account on [Moonscan](https://moonbase.moonscan.io){target=\_blank}. You’ll note that this account is empty. You’ll now need to fund this account with at least 1.1 DEV which you can get from [the faucet](https://faucet.moonbeam.network){target=\_blank}. And if you need more, you can always reach out to us on [Discord](https://discord.com/invite/amTRXQ9ZpW){target=\_blank} for additional DEV tokens. ## Preparing to Stake on Moonbase Alpha {: #preparing-to-stake-on-moonbase-alpha } First and foremost, you’ll need the address of the collator you want to delegate to. To locate it, head to the [Moonbase Alpha Staking dApp](https://apps.moonbeam.network/moonbase-alpha/staking){target=\_blank} in a second window. Ensure you’re on the correct network, then press **Select a Collator**. Press the icon next to your desired collator to copy its address. You’ll also need to make a note of the number of delegations your collator has. The [Moonbeam Foundation 01 collator](https://moonbase.subscan.io/account/{{networks.moonbase.precompiles.staking}}){target=\_blank} shown below has `7` delegations at the time of writing. ![Moonbeam Network Apps Dashboard](/images/tutorials/interoperability/remote-staking-via-xcm/xcm-stake-1.webp) ## Remote Staking via XCM with the Polkadot.js API {: #remote-staking-via-xcm-with-the-polkadot-api } This tutorial will cover the two-step process to perform remote staking operations. The first step we'll take is to generate the encoded call data for delegating a collator. Secondly, we'll send the encoded call data via XCM from the relay chain to Moonbase Alpha, which will result in the execution of the delegation. ### Generate the Encoded Call Data {: #generate-encoded-call-data } We'll be using the `delegateWithAutoCompound` function of the [Parachain Staking Pallet](/builders/substrate/interfaces/features/staking/){target=\_blank}, which accepts six parameters: `candidate`, `amount`, `autoCompound`, `candidateDelegationCount`, `candidateAutoCompoundingDelegationCount`, and `delegationCount`. In order to generate the encoded call data, we'll need to assemble the arguments for each of the `delegateWithAutoCompound` parameters and use them to build a transaction which will call the `delegateWithAutoCompound` function. We are not submitting a transaction, but simply preparing one to get the encoded call data. We'll take the following steps to build our script: 1. Create a [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 2. Assemble the arguments for each of the parameters of the `delegateWithAutoCompound` function: - `candidate`- for this example we'll use the [Moonbeam Foundation 01 collator](https://moonbase.subscan.io/account/{{networks.moonbase.staking.candidates.address1}}){target=\_blank}: `{{networks.moonbase.staking.candidates.address1}}`. To retrieve the entire list of candidates, you can refer back to the [Preparing to Stake](#preparing-to-stake-on-moonbase-alpha) section - `amount` - we'll stake the minimum amount, which is 1 DEV or `1000000000000000000` Wei. You can find a [unit converter on Moonscan](https://moonscan.io/unitconverter){target=\_blank} - `autoCompound` - we'll set this to `100` to auto-compound all rewards - `candidateDelegationCount` - we'll retrieve using the `candidateInfo` function of the Parachain Staking Pallet to get the exact count. Alternatively, you can enter the upper bound of `300` because this estimation is only used to determine the weight of the call - `candidateAutoCompoundingDelegationCount` - we'll retrieve using the `autoCompoundingDelegations` function of the Parachain Staking Pallet to get the exact count. Alternatively, you can enter the upper bound of `300` because this estimation is only used to determine the weight of the call - `delegationCount` - we'll retrieve using the `delegatorState` function of the Parachain Staking Pallet to get the exact count. Alternatively, you can specify an upper bound here of `100` 3. Craft the `parachainStaking.delegateWithAutoCompound` extrinsic with each of the required arguments 4. Use the transaction to get the encoded call data for the delegation ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const provider = new WsProvider('wss://wss.api.moonbase.moonbeam.network'); const candidate = '0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5'; const amount = '1000000000000000000'; const autoCompound = 100; const main = async () => { const api = await ApiPromise.create({ provider: provider }); // Fetch your existing number of delegations let delegatorDelegationCount; const delegatorInfo = await api.query.parachainStaking.delegatorState( 'INSERT_ACCOUNT' // Use the account you're delegating with ); if (delegatorInfo.toHuman()) { delegatorDelegationCount = delegatorInfo.toHuman()['delegations'].length; } else { delegatorDelegationCount = 0; } // Fetch the collators existing delegations const collatorInfo = await api.query.parachainStaking.candidateInfo( candidate ); const candidateDelegationCount = collatorInfo.toHuman()['delegationCount']; // Fetch the collators number of existing auto-compounding delegations const autoCompoundingDelegationsInfo = await api.query.parachainStaking.autoCompoundingDelegations(candidate); const candidateAutoCompoundingDelegationCount = autoCompoundingDelegationsInfo.length; // Craft extrinsic const tx = api.tx.parachainStaking.delegateWithAutoCompound( candidate, amount, autoCompound, candidateDelegationCount, candidateAutoCompoundingDelegationCount, delegatorDelegationCount ); // Get SCALE encoded call data const encodedCall = tx.method.toHex(); console.log(`Encoded Call Data: ${encodedCall}`); api.disconnect(); }; main(); ``` !!! note If running this as a TypeScript project, be sure to set the `strict` flag under `compilerOptions` to `false` in your `tsconfig.json`. If you'd prefer not to set up a local environment, you can run a code snippet in the [JavaScript console of Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/js){target=\_blank}. ??? code "Code to run in the Polkadot.js Apps JavaScript console" ```javascript const candidate = '0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5'; const amount = '1000000000000000000'; const autoCompound = 100; // Fetch your existing number of delegations let delegatorDelegationCount; // Use the account you're delegating with const delegatorInfo = await api.query.parachainStaking.delegatorState( 'INSERT_ACCOUNT' ); if (delegatorInfo.toHuman()) { delegatorDelegationCount = delegatorInfo.toHuman()['delegations'].length; } else { delegatorDelegationCount = 0; } // Fetch the collators existing delegations const collatorInfo = await api.query.parachainStaking.candidateInfo(candidate); const candidateDelegationCount = collatorInfo.toHuman()['delegationCount']; // Fetch the collators number of existing auto-compounding delegations const autoCompoundingDelegationsInfo = await api.query.parachainStaking.autoCompoundingDelegations(candidate); const candidateAutoCompoundingDelegationCount = autoCompoundingDelegationsInfo.length; // Craft extrinsic const tx = api.tx.parachainStaking.delegateWithAutoCompound( candidate, amount, autoCompound, candidateDelegationCount, candidateAutoCompoundingDelegationCount, delegatorDelegationCount ); // Get SCALE Encoded Call Data const encodedCall = tx.method.toHex(); console.log(`Encoded Call Data: ${encodedCall}`); ``` ### Assemble and Send XCM Instructions via the Polkadot.js API {: #sending-the-xcm-instructions-via-the-polkadot-api } In this section, we'll be using the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} to construct and send XCM instructions via the `send` extrinsic of the XCM Pallet on the Moonbase relay chain. The XCM message will transport our remote execution instructions to the Moonbase Alpha parachain to ultimately stake our desired amount of DEV tokens to a chosen collator. The `send` function of the XCM Pallet accepts two parameters: `dest` and `message`. You can start assembling these parameters by taking the following steps: 1. Build the multilocation of the DEV token on Moonbase Alpha for the `dest`: ```javascript const dest = { V4: { parents: 0, interior: { X1: [{ Parachain: 1000 }] } } }; ``` 2. Build the `WithdrawAsset` instruction, which will require you to define: - The multilocation of the DEV token on Moonbase Alpha - The amount of DEV tokens to withdraw ```javascript const instr1 = { WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 100000000000000000n }, }, ], }; ``` 3. Build the `BuyExecution` instruction, which will require you to define: - The multilocation of the DEV token on Moonbase Alpha - The amount of DEV tokens to buy for execution - The weight limit ```javascript const instr2 = { BuyExecution: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 100000000000000000n }, }, { Unlimited: null }, ], }; ``` 4. Build the `Transact` instruction, which will require you to define: - The origin type, which will be `SovereignAccount` - The required weight for the transaction. You'll need to define a value for `refTime`, which is the amount of computational time that can be used for execution, and the `proofSize`, which is the amount of storage in bytes that can be used. It is recommended that the weight given to this instruction needs to be around 10% more of `25000` times the gas limit for the call you want to execute via XCM - The encoded call data for delegating a collator, which we generated in the [previous section](#generate-encoded-call-data) ```javascript const instr3 = { Transact: { originKind: 'SovereignAccount', requireWeightAtMost: { refTime: 40000000000n, proofSize: 900000n }, call: { encoded: '0x0c1212e7bcca9b1b15f33585b5fc898b967149bdb9a5000064a7b3b6e00d000000000000000064070000000700000000000000', }, }, }; ``` 5. Combine the XCM instructions into a versioned XCM message: ```javascript const message = { V4: [instr1, instr2, instr3] }; ``` Now that you have the values for each of the parameters, you can write the script to send the XCM message. You'll take the following steps: 1. Provide the values for each of the parameters of the `send` function 2. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider using the WSS endpoint of the Alphanet relay chain 3. Create a Keyring instance using the mnemonic of your relay chain account, which will be used to send the transaction 4. Craft the `xcmPallet.send` extrinsic with the `dest` and `message` 5. Send the transaction using the `signAndSend` extrinsic and the Keyring instance you created in the third step !!! remember This is for demo purposes only. Never store your private key in a JavaScript file. ```javascript import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; import { cryptoWaitReady } from '@polkadot/util-crypto'; const privateKey = 'INSERT_PRIVATE_KEY_OR_MNEMONIC'; // 1. Define the dest and message arguments const dest = { V4: { parents: 0, interior: { X1: [{ Parachain: 1000 }] } } }; const instr1 = { WithdrawAsset: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 100000000000000000n }, }, ], }; const instr2 = { BuyExecution: [ { id: { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }, fun: { Fungible: 100000000000000000n }, }, { Unlimited: null }, ], }; const instr3 = { Transact: { originKind: 'SovereignAccount', requireWeightAtMost: { refTime: 40000000000n, proofSize: 900000n }, call: { encoded: '0x0c1212e7bcca9b1b15f33585b5fc898b967149bdb9a5000064a7b3b6e00d000000000000000064070000000700000000000000', }, }, }; const message = { V4: [instr1, instr2, instr3] }; const performRemoteDelegation = async () => { // 2. Construct API provider const wsProvider = new WsProvider( 'wss://relay.api.moonbase.moonbeam.network' ); const api = await ApiPromise.create({ provider: wsProvider }); // 3. Initialize wallet key pairs await cryptoWaitReady(); const keyring = new Keyring({ type: 'sr25519' }); // For demo purposes only. Never store your private key or mnemonic in a JavaScript file const otherPair = keyring.addFromUri(privateKey); console.log(`Derived Address from Private Key: ${otherPair.address}`); // 4. Define the transaction using the send method of the xcm pallet const tx = api.tx.xcmPallet.send(dest, message); // 5. Sign and send the transaction const txHash = await tx.signAndSend(otherPair); console.log(`Submitted with hash ${txHash}`); api.disconnect(); }; performRemoteDelegation(); ``` !!! note Remember that your Computed Origin account must be funded with at least 1.1 DEV or more to ensure you have enough to cover the stake amount and transaction fees. In the above snippet, besides submitting the remote staking via XCM transaction, we also print out the transaction hash to assist with any debugging. And that’s it! To verify that your delegation was successful, you can visit [Subscan](https://moonbase.subscan.io){target=\_blank} to check your staking balance. Be advised that it may take a few minutes before your staking balance is visible on Subscan. Additionally, be aware that you will not be able to see this staking operation on Moonscan, because we initiated the delegation action directly via the [Parachain Staking Pallet](/builders/substrate/interfaces/features/staking/){target=\_blank} (on the Substrate side) rather than through the [Staking Precompile](/builders/ethereum/precompiles/features/staking/){target=\_blank} (on the EVM).
This tutorial is for educational purposes only. As such, any contracts or code created in this tutorial should not be used in production.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/tutorials/interoperability/uniswapv2-swap-xcm/ --- BEGIN CONTENT --- --- title: Uniswap V2 Swap on Moonbeam from Polkadot via XCM description: In this guide, we'll use remote EVM execution via XCM to perform a Uniswap V2 swap to showcase how Moonbeam can be leveraged in a connected contracts approach. template: main.html categories: Tutorials, XCM --- # Uniswap V2 Swap from Polkadot via XCM _by Alberto Viera_ ## Introduction {: #introduction } In this tutorial, we’ll perform a Uniswap V2-styled swap from a relay chain (what Polkadot is to Moonbeam) using Polkadot's interoperability general message passing protocol called [XCM](/builders/interoperability/xcm/overview/){target=\_blank}. To do so, we'll be using a particular combination of XCM instructions that allow you to [call Moonbeam's EVM through an XCM message](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank}. Consequently, any blockchain that is able to send an XCM message to Moonbeam can tap into its EVM and all the dApps built on top of it. **The content of this tutorial is for educational purposes only!** For this example, you'll be working on top of the Moonbase Alpha (Moonbeam TestNet), which has its own relay chain (similar to Polkadot). The relay chain token is called `UNIT`, while Moonbase Alpha's is called `DEV`. Doing this in TestNet is less fun than doing it in production, but **developers must understand that sending incorrect XCM messages can result in the loss of funds.** Consequently, it is essential to test XCM features on a TestNet before moving to a production environment. Throughout this tutorial, we will refer to the account performing the Uniswap V2 swap via XCM as Alice. The tutorial has a lot of moving parts, so let's summarize them in a list and a flow diagram: 1. Alice has an account on the relay chain, and she wants to swap `DEV` tokens for `MARS` tokens (ERC-20 on Moonbase Alpha) on [Moonbeam-Swap](https://moonbeam-swap.netlify.app){target=\_blank}, a demo Uniswap V2 clone on Moonbase Alpha. Alice needs to send an XCM message to Moonbase Alpha from her relay chain account 2. The XCM message will be received by Moonbase Alpha and its instructions executed. The instructions state Alice's intention to buy some block execution time in Moonbase Alpha and execute a call to Moonbase's EVM, specifically, the Uniswap V2 (Moonbeam-Swap) router contract. The EVM call is dispatched through a special account Alice controls on Moonbase Alpha via XCM messages. This account is known as the [Computed Origin account](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank}. Even though this is a keyless account (private key is unknown), the public address can be [calculated in a deterministic way](/builders/interoperability/xcm/remote-execution/computed-origins/#calculate-computed-origin){target=\_blank} 3. The XCM execution will result in the swap being executed by the EVM, and Alice will receive her `MARS` tokens in her special account 4. The execution of the remote EVM call through XCM will result in some EVM logs that are picked up by explorers. There is an EVM transaction and receipt that anyone can query to verify ![Remote EVM Call Through XCM for Uniswap V2 Swap Diagram](/images/tutorials/interoperability/uniswapv2-swap-xcm/uniswapv2-swap-xcm-1.webp) With the steps outlined, some prerequisites need to be taken into account, let's jump right into it! ## Checking Prerequisites {: #checking-prerequisites } Considering all the steps summarized in the [introduction](#introduction), the following prerequisites need to be accounted for: - You need to have UNITs on the relay chain to pay for transaction fees when sending the XCM. If you have a Moonbase Alpha account funded with DEV tokens, you can swap some DEV for xcUNIT here on [Moonbeam Swap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank}. Then withdraw the xcUNIT from Moonbase Alpha to [your account on the Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/accounts){target=\_blank} using [apps.moonbeam.network](https://apps.moonbeam.network/moonbase-alpha){target=\_blank} - Your [Computed Origin account](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank} must hold `DEV` tokens to fund the Uniswap V2 swap, and also pay for the XCM execution (although this could be paid in UNIT tokens as `xcUNIT`). We will calculate the Computed Origin account address in the next section You can get DEV tokens for testing on Moonbase Alpha once every 24 hours from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} ## Calculating your Computed Origin Account {: #calculating-your-computed-origin-account } Copy the account of your existing or newly created account on the [Moonbase relay chain](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/accounts){target=\_blank}. You're going to need it to calculate the corresponding Computed Origin account, which is a special type of account that’s keyless (the private key is unknown). Transactions from a Computed Origin account can be initiated only via valid XCM instructions from the corresponding account on the relay chain. In other words, you are the only one who can initiate transactions on your Computed Origin account, and if you lose access to your Moonbase relay account, you’ll also lose access to your Computed Origin account. To generate the Computed Origin account, first clone the [xcm-tools](https://github.com/Moonsong-Labs/xcm-tools){target=\_blank} repo. Run `yarn` to install the necessary packages, and then run: ```sh yarn calculate-multilocation-derivative-account \ --ws-provider wss://wss.api.moonbase.moonbeam.network \ --address INSERT_MOONBASE_RELAY_ACCOUNT \ --para-id INSERT_ORIGIN_PARACHAIN_ID_IF_APPLIES \ --parents INSERT_PARENTS_VALUE_IF_APPLIES ``` Let's review the parameters passed along with this command: - The `--ws-provider` or `-w` flag corresponds to the endpoint we’re using to fetch this information - The `--address` or `-a` flag corresponds to your Moonbase relay chain address - The `--para-id` or `-p` flag corresponds to the parachain ID of the origin chain (if applicable). If you are sending the XCM from the relay chain, you don't need to provide this parameter - The `-parents` flag corresponds to the parents value of the origin chain in relation to the destination chain. If you're deriving a multi-location derivative account on a parachain destination from a relay chain origin, this value would be `1`. If left out, the parents value defaults to `0` For our case, we will send the remote EVM call via XCM from Alice's account, which is `5GKh9gMK5dn9SJp6qfMNcJiMMnY7LReYmgug2Fr5fKE64imn`, so the command and response would look like the following image.
yarn calculate-multilocation-derivative-account \ --ws-provider wss://wss.api.moonbase.moonbeam.network \ --address 5GKh9gMK5dn9SJp6qfMNcJiMMnY7LReYmgug2Fr5fKE64imn \ --parents 1
yarn run v1.22.10 warning ../../../package.json: No license field $ ts-node 'scripts/calculate-multilocation-derivative-account.ts' --ws-provider wss://wss.api.moonbase.moonbeam.network --address 5GKh9gMK5dn9SJp6qfMNcJiMMnY7LReYmgug2Fr5fKE64imn --parents 1
Remote Origin calculated as ParentChain Parents 1 AccountId32: 5GKh9gMK5dn9SJp6qfMNcJiMMnY7LReYmgug2Fr5fKE64imn 32 byte address is 0x61cd3e07fe7d7f6d4680e3e322986b7877f108ddb18ec02c2f17e82fe15f9016 20 byte address is 0x61cd3e07fe7d7f6d4680e3e322986b7877f108dd ✨ Done in 1.02s.
The values are all summarized in the following table: | Name | Value | |:-------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------:| | Origin Chain Encoded Address | `5GKh9gMK5dn9SJp6qfMNcJiMMnY7LReYmgug2Fr5fKE64imn` | | Origin Chain Decoded Address | `0xbc5f3c61709f218d983fc773a600958a07fb18047418df7eeb0501d0679e397a` | | Computed Origin Account (32 bytes) | `0x61cd3e07fe7d7f6d4680e3e322986b7877f108ddb18ec02c2f17e82fe15f9016` | | Computed Origin Account (20 bytes) | `0x61cd3e07fe7d7f6d4680e3e322986b7877f108dd` | The script will return 32-byte and 20-byte addresses. We’re interested in the Ethereum-style account - the 20-byte one, which is `0x61cd3e07fe7d7f6d4680e3e322986b7877f108dd`. Feel free to look up your Computed Origin account on [Moonscan](https://moonbase.moonscan.io){target=\_blank}. Next, you can fund this account with DEV tokens. You can get DEV tokens for testing on Moonbase Alpha once every 24 hours from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank}. ## Getting the Uniswap V2 Swap Calldata {: #getting-uniswapv2-swap-calldata } The following section will walk through the steps of getting the calldata for the Uniswap V2 swap, as we need to feed this calldata to the [remote EVM call](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank} that we will build via XCM. The function being targeted here is one from the Uniswap V2 router, more specifically [swapExactETHForTokens](https://github.com/Uniswap/v2-periphery/blob/master/contracts/UniswapV2Router02.sol#L252){target=\_blank}. This function will swap an exact amount of protocol native tokens (in this case `DEV`) for another ERC-20 token. It has the following inputs: - Minimum amount of tokens that you expect out of the swap (accounting for slippage) - Path that the take will trade (if there is no direct pool, the swap might be routed through multiple pair pools) - Address of the recipient of the tokens swapped - The deadline (in Unix time) from which the trade is no longer valid The easiest way to get the calldata is through the [Moonbeam Uniswap V2 Demo](https://moonbeam-swap.netlify.app){target=\_blank} page. Once you go in the website, take the following steps: 1. Set the swap **from** value and token and also set the swap **to** token. For this example, we want to swap 1 `DEV` token for `MARS` 2. Click on the **Swap** button. Metamask should pop up, **do not sign the transaction** 3. In Metamask, click on the **hex** tab, and the encoded calldata should show up 4. Click on the **Copy raw transaction data** button. This will copy the encoded calldata to the clipboard ![Calldata for Uniswap V2 swap](/images/tutorials/interoperability/uniswapv2-swap-xcm/uniswapv2-swap-xcm-2.webp) !!! note Other wallets also offer the same capabilities of checking the encoded calldata before signing the transaction. Once you have the encoded calldata, feel free to reject the transaction in your wallet. The swap calldata that we obtained is encoded as follows (all but the function selector are expressed in 32 bytes or 64 hexadecimal characters blobs): 1. The function selector, which is 4 bytes long (8 hexadecimal characters) that represents the function you are calling 2. The minimum amount out of the swap that we want accounting for slippage, in this case, `10b3e6f66568aaee` is `1.2035` `MARS` tokens 3. The location (pointer) of the data part of the path parameter (which is of type dynamic). `80` in hex is `128` decimal, meaning that information about the path is presented after 128 bytes from the beginning (without counting on the function selector). Consequently, the next bit of information about the path is presented in element 6 4. The address receiving the tokens after the swap, in this case, is the `msg.sender` of the call 5. The deadline limit for the swap 6. The length of the address array representing the path 7. First token involved in the swap, which is wrapped `DEV` 8. Second token involved in the swap, `MARS`, so it is the last ```text 1. 0x7ff36ab5 2. 00000000000000000000000000000000000000000000000010b3e6f66568aaee -> Min Amount Out 3. 0000000000000000000000000000000000000000000000000000000000000080 4. 000000000000000000000000d720165d294224a7d16f22ffc6320eb31f3006e1 -> Receiving Address 5. 0000000000000000000000000000000000000000000000000000000063dbcda5 -> Deadline 6. 0000000000000000000000000000000000000000000000000000000000000002 7. 000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e1 8. 0000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f ``` In the calldata, we need to change three fields to ensure our swap will go through: - The minimum amount out, to account for slippage as the pool may have a different `DEV/MARS` balance when you try this out - The receiving address to our Computed Origin account - The deadline to provide a bit more flexibility for our swap, so you don't have to submit this immediately **This is OK because we are just testing things :), do not use this code in production!** Our encoded calldata should look like this (the line breaks were left for visibility): ```text 0x7ff36ab5 0000000000000000000000000000000000000000000000000de0b6b3a7640000 -> New Min Amount 0000000000000000000000000000000000000000000000000000000000000080 00000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd -> New Address 00000000000000000000000000000000000000000000000000000000A036B1B9 -> New Deadline 0000000000000000000000000000000000000000000000000000000000000002 000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e1 0000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f ``` Which, as one line, is: ```text 0x7ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000A036B1B90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f ``` You can also get the calldata programmatically using the [Uniswap V2 SDK](https://docs.uniswap.org/sdk/v2/overview){target=\_blank}. ## Generating the Moonbeam Encoded Calldata {: #generating-the-moonbeam-encoded-call-data } Now that we have the Uniswap V2 swap encoded calldata, we need to generate the bytes that the `Transact` XCM instruction from the XCM message will execute. Note that these bytes represent the action that will be executed in the remote chain. In this example, we want the XCM message execution to enter the EVM and perform the swap, from which we got the encoded calldata. To get the SCALE (encoding type) encoded calldata for the transaction parameters, we can leverage the following [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} script (note that it requires `@polkadot/api` and `ethers`). ```js import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 10.13.1 import { ethers } from 'ethers'; // Version 6.12.0 import BN from 'bn.js'; // Importing directly from bn.js // 1. Input Data const providerWsURL = 'wss://wss.api.moonbase.moonbeam.network'; const uniswapV2Router = '0x8a1932D6E26433F3037bd6c3A40C816222a6Ccd4'; const contractCall = '0x7ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000A036B1B90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f'; const generateCallData = async () => { // 2. Create Substrate API Provider const substrateProvider = new WsProvider(providerWsURL); const ethProvider = new ethers.WebSocketProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 3. Estimate Gas for EVM Call const gasLimit = await ethProvider.estimateGas({ to: uniswapV2Router, data: contractCall, value: ethers.parseEther('0.01'), }); console.log(`Gas required for call is ${gasLimit.toString()}`); // Convert ethers' BigNumber to Polkadot's BN and add some extra const totalGasLimit = new BN(gasLimit.toString()).add(new BN(10000)); // 4. Call Parameters const callParams = { V2: { gasLimit: totalGasLimit, // Estimated plus some extra gas action: { Call: uniswapV2Router }, // Uniswap V2 router address value: new BN(ethers.parseEther('0.01').toString()), // 0.01 DEV input: contractCall, // Swap encoded calldata }, }; // 5. Create the Extrinsic const tx = api.tx.ethereumXcm.transact(callParams); // 6. Get SCALE Encoded Calldata const encodedCall = tx.method.toHex(); console.log(`Encoded Calldata: ${encodedCall}`); api.disconnect(); }; generateCallData(); ``` !!! note You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/extrinsics){target=\_blank}. Let's go through each of the main components of the snippet shown above: 1. Provide the input data for the call. This includes: - Moonbase Alpha endpoint URL to create the providers - [Uniswap V2 router address](https://moonbase.moonscan.io/address/0x8a1932d6e26433f3037bd6c3a40c816222a6ccd4#code){target=\_blank} which is the one the call interacts with - Encoded calldata for the Uniswap V2 swap that we calculated before 2. Create the necessary providers. One is a [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider, through which we can call [Moonbeam pallets](/builders/substrate/interfaces/){target=\_blank} directly. The other one is an Ethereum API provider through Ethers.js 3. This step is mainly a best practice. Here, we are estimating the gas of the EVM call that will be executed via XCM, as this is needed later on. You can also hardcode the gas limit value, but it is not recommended 4. [Build the remote EVM call](/builders/interoperability/xcm/remote-execution/remote-evm-calls/#build-remote-evm-call-xcm){target=\_blank}. We bumped the gas by `10000` units to provide a bit of room in case conditions change. The inputs are identical to those used for the gas estimation 5. Create the Ethereum XCM pallet call to the `transact` method, providing the call parameters we previously built 6. Get the SCALE calldata of the specific transaction parameter, which we need to provide to the `Transact` XCM instruction later on. Note that in this particular scenario, because we need only the calldata of the transaction parameters, we have to use `tx.method.toHex()` Once you have the code set up, you can execute it with `node`, and you'll get the Moonbase Alpha remote EVM calldata:
node generate-call-data-swap.js
Gas required for call is 596363 Encoded Calldata: 0x2600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f00
The encoded calldata for this example is: ```text 0x2600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f00 ``` And that is it! You have everything you need to start crafting the XCM message itself! It has been a long journey, but we are almost there. ## Building the XCM Message from the Relay Chain {: #building-the-xcm-message-relay-chain } We are almost in the last part of this tutorial! In this section, we'll craft the XCM message using the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank}. We'll also dissect the message instruction per instruction to understand what is happening every step of the way. The XCM message we are about to build is composed of the following instructions: - [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} — takes funds from the account dispatching the XCM in the destination chain and puts them in holding, a special take where funds can be used for later actions - [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} — buy a certain amount of block execution time - [`Transact`](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} — use part of the block execution time bought with the previous instruction to execute some arbitrary bytes - [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank} — takes assets from holding and deposits them to a given account To build the XCM message, which will initiate the remote EVM call through XCM, and get its SCALE encoded calldata, you can use the following snippet: ```js import { ApiPromise, WsProvider } from '@polkadot/api'; // Version 10.13.1 // 1. Input Data const providerWsURL = 'wss://relay.api.moonbase.moonbeam.network'; const amountToWithdraw = BigInt(1 * 10 ** 16); // 0.01 DEV const devMultiLocation = { parents: 0, interior: { X1: [{ PalletInstance: 3 }] }, }; const weightTransact = 40000000000n; // 25000 * Gas limit of EVM call const multiLocAccount = '0x61cd3e07fe7d7f6d4680e3e322986b7877f108dd'; const transactBytes = '0x2600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f00'; // 2. XCM Destination (Moonbase Alpha Parachain ID 1000) const dest = { V4: { parents: 0, interior: { X1: [{ Parachain: 1000 }] } } }; // 3. XCM Instruction 1 const instr1 = { WithdrawAsset: [ { id: devMultiLocation, fun: { Fungible: amountToWithdraw }, }, ], }; // 4. XCM Instruction 2 const instr2 = { BuyExecution: { fees: { id: devMultiLocation, fun: { Fungible: amountToWithdraw }, }, weightLimit: { Unlimited: null }, }, }; // 5. XCM Instruction 3 const instr3 = { Transact: { originKind: 'SovereignAccount', requireWeightAtMost: { refTime: weightTransact, proofSize: 700000n }, call: { encoded: transactBytes, }, }, }; // 6. XCM Instruction 4 const instr4 = { DepositAsset: { assets: { Wild: 'All' }, beneficiary: { parents: 0, interior: { X1: [{ AccountKey20: { key: multiLocAccount } }] }, }, }, }; // 7. Build XCM Message const message = { V4: [instr1, instr2, instr3, instr4] }; const generateCallData = async () => { // 8. Create Substrate API Provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 9. Create the Extrinsic const tx = api.tx.xcmPallet.send(dest, message); // 10. Get SCALE Encoded Calldata const encodedCall = tx.toHex(); console.log(`Encoded Calldata: ${encodedCall}`); api.disconnect(); }; generateCallData(); ``` !!! note You can also get the SCALE encoded calldata by manually building the extrinsic in [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/extrinsics){target=\_blank}. Let's go through each of the main components of the snippet shown above: 1. Provide the input data for the call. This includes: - Moonbase Alpha relay chain endpoint URL to create the provider - Amount of tokens (in Wei) to withdraw from the Computed Origin account. For this example, `0.01` tokens are more than enough. To understand how to get this value, please refer to the [XCM fee page](/builders/interoperability/xcm/core-concepts/weights-fees/#moonbeam-reserve-assets){target=\_blank} - The [multilocation of the `DEV` token](/builders/interoperability/xcm/xc-registration/assets/#register-moonbeam-native-assets){target=\_blank} as seen by Moonbase Alpha - The weight for the `transact` XCM instruction. This can be obtained by multiplying `25000` and the gas limit obtained before. It is recommended to add approximately 10% more of the estimated value. You can read more about this value in the [Remote EVM Calls through XCM](/builders/interoperability/xcm/remote-execution/remote-evm-calls/#build-xcm-remote-evm){target=\_blank} page - The Computed Origin account as it will be needed later for an XCM instruction - The bytes for the `transact` XCM instruction that we calculated in the previous section 2. Define the destination multilocation for the XCM message. In this case, it is the Moonbase Alpha parachain 3. First XCM instruction, `WithdrawAsset`. You need to provide the asset multilocation and the amount you want to withdraw. Both variables were already described before 4. Second XCM instruction, `BuyExecution`. Here, we are paying for Moonbase Alpha block execution time in `DEV` tokens by providing its multilocation and the amount we took out with the previous instruction. Next, we are buying all the execution we can (`Unlimited` weight) with `0.001 DEV` tokens which should be around 20 billion weight units, plenty for our example 5. Third XCM instruction, `Transact`. The instruction will use a portion of the weight bought (defined as `requireWeightAtMost`) and execute the arbitrary bytes that are provided (`transactBytes`) 6. Fourth XCM instruction, `DepositAsset`. Whatever is left in holding after the actions executed before (in this case, it should be only `DEV` tokens) is deposited to the Computed Origin account, set as the `beneficiary`. 7. Build the XCM message by concatenating the instructions inside a `V2` array 8. Create the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} provider 9. Craft the `xcmPallet.send` extrinsic with the destination and XCM message. This method will append the [`DescendOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#descend-origin){target=\_blank} XCM instruction to our XCM message, and it is the instruction that will provide the necessary information to calculate the Computed Origin account 10. Get the SCALE encoded calldata. Note that in this particular scenario, because we need the full SCALE encoded calldata, we have to use `tx.toHex()`. This is because we will submit this transaction using the calldata !!! challenge Try a more straightforward example and perform a balance transfer from the Computed Origin account to any other account you like. You'll have to build the SCALE encoded calldata for a `balance.Transfer` extrinsic or create the Ethereum call as a balance transfer transaction. Once you have the code set up, you can execute it with `node`, and you'll get the relay chain XCM calldata:
node build-xcm-message-swap.js Encoded Calldata: 0x450604630004000100a10f0410000400010403000f0000c16ff286231300010403000f0000c16ff286230006010700902f500982b92a00fd042600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000d01000001030061cd3e07fe7d7f6d4680e3e322986b7877f108dd
The encoded calldata for this example is: ```text 0x450604630004000100a10f0410000400010403000f0000c16ff286231300010403000f0000c16ff286230006010700902f500982b92a00fd042600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000d01000001030061cd3e07fe7d7f6d4680e3e322986b7877f108dd ``` Now that we have the SCALE encoded calldata, the last step is to submit the transaction, which will send our XCM message to Moonbase Alpha, and do the remote EVM call! ## Sending the XCM Message from the Relay Chain {: #send-xcm-message-relay-chain } This section is where everything comes together and where the magic happens! Let's recap what we've done so far: - We've created a relay chain account that is funded with `UNIT` tokens (relay chain native tokens) - We determined its Computed Origin account on Moonbase Alpha and funded this new address with `DEV` tokens (Moonbase Alpha native token) - We obtained the Uniswap V2 swap calldata, in which we'll be swapping `0.01 DEV` token for `MARS`, an ERC-20 that exists in Moonbase Alpha. We had to modify a couple of fields to adapt it to this particular example - We built the SCALE encoded calldata in Moonbase Alpha to access its EVM via XCM - We crafted our transaction to send an XCM message to Moonbase Alpha, in which we will ask it to execute the SCALE encoded calldata that was previously built. This, in turn, will execute an EVM call which will perform the Uniswap V2 swap for the precious `MARS` tokens! To send the XCM message that we built in the previous section, you can use the following code snippet: ```js import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; // Version 10.13.1 import { cryptoWaitReady } from '@polkadot/util-crypto'; // 1. Input Data const providerWsURL = 'wss://relay.api.moonbase.moonbeam.network'; const MNEMONIC = 'INSERT_MNEMONIC'; // Not safe, only for testing const txCall = '0x450604630004000100a10f0410000400010403000f0000c16ff286231300010403000f0000c16ff286230006010700902f500982b92a00fd042600019b40090000000000000000000000000000000000000000000000000000000000008a1932d6e26433f3037bd6c3a40c816222a6ccd40000c16ff286230000000000000000000000000000000000000000000000000091037ff36ab50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000061cd3e07fe7d7f6d4680e3e322986b7877f108dd00000000000000000000000000000000000000000000000000000000a036b1b90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d909178cc99d318e4d46e7e66a972955859670e10000000000000000000000001fc56b105c4f0a1a8038c2b429932b122f6b631f000d01000001030061cd3e07fe7d7f6d4680e3e322986b7877f108dd'; const sendXCM = async () => { // 2. Create Substrate API Provider const substrateProvider = new WsProvider(providerWsURL); const api = await ApiPromise.create({ provider: substrateProvider }); // 3. Create Keyring Instance await cryptoWaitReady(); const keyring = new Keyring({ type: 'sr25519' }); const alice = keyring.addFromUri(MNEMONIC); // 4. Create the Extrinsic const tx = await api.tx(txCall).signAndSend(alice, (result) => { // 5. Check Transaction Status if (result.status.isInBlock) { console.log( `Transaction included in blockHash ${result.status.asInBlock}` ); } }); api.disconnect(); }; sendXCM(); ``` Once you have the code set up, you can execute it with `node`, and the XCM message will be sent to initiate your Uniswap V2 swap in Moonbase Alpha:
node send-xcm-message-swap.js Transaction included in blockHash 0x4260e32a208dde976c704bb8b08eccd6cdd2cdd9796d79a572c40ba38ce48af6
And that is it! You've sent an XCM message, which performed a remote EVM call via XCM and resulted in a Uniswap V2-styled swap in Moonbase Alpha. But let's go into more detail about what happened. This action will emit different events. The first one is the only relevant [in the relay chain](https://polkadot.js.org/apps/?rpc=wss://relay.api.moonbase.moonbeam.network#/explorer/query/0x85cad5f3cef5d578f6acc60c721ece14842be332fa333c9b9eafdfe078bc0290){target=\_blank}, and it is named `xcmPallet.Sent`, which is from the `xcmPallet.send` extrinsic. In [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer/query/0x1f60aeb1f2acbc2cf6e19b7ad969661f21f4847f7b40457c459e7d39f6bc0779){target=\_blank}, the following events emitted by the `parachainSystem.setValidationData` extrinsic (where all the inbound XCM messages are processed) are of interest: - `parachainSystem.DownwardMessagesReceived` — states that there was an XCM message received - `evm.Log` — internal events emitted by the different contract calls. The structure is the same: contract address, the topics, and relevant data - `ethereum.Executed` — contains information on the `from` address, the `to` address, and the transaction hash of an EVM call done - `polkadotXcm.AssetsTrapped` — flags that some assets were in holding and were not deposited to a given address. If the `Transact` XCM instruction does not exhaust the tokens allocated to it, it will execute a [`RefundSurplus`](/builders/interoperability/xcm/core-concepts/instructions/#refund-surplus){target=\_blank} after the XCM is processed. This instruction will take any leftover tokens from the execution bought and put them in holding. We could prevent this by adjusting the fee provided to the `Transact` instruction, or by adding the instruction right after the `Transact` - `dmpQueue.ExecutedDownward` — states the result of executing a message received from the relay chain (a DMP message). In this case, the `outcome` is marked as `Complete` Our XCM was successfully executed! If you visit [Moonbase Alpha Moonscan](https://moonbase.moonscan.io){target=\_blank} and search for [the transaction hash](https://moonbase.moonscan.io/tx/0x3fd96c5c7a82cd0b54c654f64d41879814d94a3ad9b66820f2be2fe7fc2a18eb){target=\_blank}, you'll find the Uniswap V2 swap that was executed via the XCM message. !!! challenge Do a Uniswap V2 swap of `MARS` for any other token you want. Note that in this case, you'll have to remotely execute an ERC-20 `approve` via XCM first to allow the Uniswap V2 Router to spend the tokens on your behalf. Once the approval is done, you can send the XCM message for the swap itself.
This tutorial is for educational purposes only. As such, any contracts or code created in this tutorial should not be used in production.
--- END CONTENT --- ## Basics Concepts [shared: true] The following section contains foundational documentation shared across all Moonbeam products. It describes the architecture and infrastructure that serve as the backbone for all integrations built with Moonbeam. This includes the network development framework, Substrate and EVM development tools, developer tooling, and guidance for node operators. This context is provided to help understand how the system works under the hood, but responses should stay focused on the specific product unless the user explicitly asks about the general architecture. --- ## List of shared concept pages: ## Full content for shared concepts: Doc-Content: https://docs.moonbeam.network/learn/core-concepts/balances/ --- BEGIN CONTENT --- --- title: Account Balances description: A description of the main differences that Ethereum developers need to understand in terms of account balances on Moonbeam and how they differ from Ethereum. categories: Basics --- # Moonbeam Account Balances ## Introduction {: #introduction } While Moonbeam strives to be compatible with Ethereum's Web3 API and EVM, there are some important Moonbeam differences that developers should know and understand in terms of account balances. One of the design goals of Moonbeam is to create an environment that is as close as possible to Ethereum, and to offer a set of Web3 RPC endpoints that are compatible with Ethereum. However, Moonbeam is also a Substrate based chain, which means that it exposes Substrate RPCs, and that it has integral functionality that is powered by Substrate such as Staking, Governance, and other features which are not part of the Ethereum API. Moonbeam [unified accounts](/learn/core-concepts/unified-accounts/){target=\_blank} are one way that Moonbeam achieves Ethereum compatibility, by changing the underlying account type in the protocol to be Ethereum-like (H160 or 20 byte addresses starting with `0x`). Unified accounts are used by both the Substrate and Ethereum APIs, and map to the same underlying data storage on the blockchain. Nevertheless, there are important differences that users coming from Ethereum should understand when using Moonbeam accounts via the Ethereum API. This guide will outline some of these main differences and what to expect when using Moonbeam for the first time. ## Ethereum Account Balances {: #ethereum-account-balances } An account on Ethereum is an entity with a token balance (Ether or ETH in this case). Account-holders can send Ether transactions on Ethereum and accounts can be controlled by either users (with the private key for signing) or smart contracts. Therefore, Ethereum has two main types of accounts: user-owned and contract-owned. No matter the type, an Ethereum account has a single balance field that represents the number of Wei owned by this address, where Wei is a denomination of ETH (1 x 10^18 Wei per ETH). ![Ethereum balances diagram](/images/learn/core-concepts/balances/balances-1.webp) ## Moonbeam Account Balances {: #moonbeam-account-balances } An account on Moonbeam is also an entity with a token balance (the token will depend on the network). Like on Ethereum, account holders can send token transactions on the Moonbeam Network they are connected to. In addition, accounts can be controlled by users (with the private key for signing) or smart contracts. As with Ethereum, there are two main types of accounts: user-owned and contract owned. However, on Moonbeam, within both account types, there are also [proxy accounts](https://wiki.polkadot.com/learn/learn-proxies/){target=\_blank}, which can perform a limited number of actions on behalf of another account. In terms of balances, all of Moonbeam account types have five (5) different [balance types](https://wiki.polkadot.com/learn/learn-accounts/#balance-types#balance-types){target=\_blank}: - **Free** — refers to the balance that can be used (not locked/frozen) from the Substrate API. The concept of `free` balance depends on the action to be executed. For example, voting in democracy will not subtract the allocated balance to the vote from `free` balance, but token holders won't be able to transfer that balance - **Reducible** — refers to the balance that can be used (not locked/frozen) through the Ethereum API on Moonbeam. For example, this is the balance displayed by MetaMask. It is the real spendable balance, accounting for all democracy locks (displayed as transferable in Polkadot.js Apps) - **Reserved** — refers to the balance held due to on-chain requirements, and that can be freed by performing some on-chain action. For example, bonds for creating a proxy account or setting an on-chain identity are shown as `reserved balance`. These funds are **not** transferable or accessible via the Ethereum API until they are freed - **Misc frozen** — represents a balance that the `free` balance may not drop below when withdrawing funds, except for transaction fee payment. For example, funds being used to vote on a governance proposal are shown as `misc frozen`. These funds are **not** transferable or accessible via the Ethereum API until they are freed - **Fee frozen** — represents a balance that the `free` balance may not drop below when specifically paying for transaction fees. These funds are **not** transferable or accessible via the Ethereum API until they are freed ![Moonbeam balances diagram](/images/learn/core-concepts/balances/balances-2.webp) ### Calculating Your Transferable Balance {: #calculating-your-transferable-balance } An account's transferable or spendable balance can be calculated as the free balance minus the maximum of `0` or the difference between frozen and reserved tokens: ```text Transferable = free - max(0, frozen - reserved ) ``` Here are two examples of calculating transferable balances: An account has `1000` free tokens, `200` frozen tokens, and `50` reserved tokens. The transferable balance is calculated as: ```text Transferable = 1000 - max(0, 200 - 50) = 1000 - 150 = 850 ``` If the frozen tokens are less than the reserved tokens, with `1000` free tokens, `100` frozen tokens, and `150` reserved tokens, the transferable balance would be: ```text Transferable = 1000 - max(0, 100 - 150) = 1000 - 0 = 1000 ``` ### Retrieve Your Balance {: #retrieve-your-balance } You can check on your balances, including your free (or transferable) and reserved balances (if exists), using the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank}. !!! note To test out the examples in this guide on Moonbeam or Moonriver, you will need to have your own endpoint and API key, which you can get from one of the supported [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network'); const main = async () => { const polkadotApi = await ApiPromise.create({ provider: wsProvider, }); const balances = await polkadotApi.query.system.account('INSERT_ADDRESS'); console.log(balances.toHuman()); }; main(); ``` You can also retrieve your balance locks using the Polkadot.js API. ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network'); const main = async () => { const polkadotApi = await ApiPromise.create({ provider: wsProvider, }); const locks = await polkadotApi.query.balances.locks('INSERT_ADDRESS'); console.log(locks.toHuman()); }; main(); ``` ## Main Differences {: #main-differences } The main difference between account balances on Ethereum and Moonbeam lies in the concept of locked and reserved balance on Moonbeam. These are tokens that are still owned by that account, but they are not spendable (yet). From the Ethereum's API perspective, an account might show that it has a certain balance (called `reducible` balance). However, after an on-chain action, this value might increase (or decrease) without an actual balance transfer. It is important to note that the account and behavior differences described here apply to account balances with the base asset (GLMR, MOVR) only and the balances of that asset that aren't interacting with smart contracts. As soon as a Moonbeam account balance is interacting with smart contracts, the behavior will be the same as Ethereum behavior. For example, if you wrap MOVR on Moonriver there is no way for the underlying balance to change via staking or governance actions, because that is part of the storage of the contract. In this case the reducible balance of that account has been committed to the wrapped MOVR smart contract and can't be modified by Substrate actions. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/core-concepts/consensus-finality/ --- BEGIN CONTENT --- --- title: Consensus & Finality description: The main differences that Ethereum developers should understand in terms of consensus and finality on Moonbeam and how it differs from Ethereum. categories: Basics --- # Moonbeam Consensus & Finality ## Introduction {: #introduction } While Moonbeam strives to be compatible with Ethereum's Web3 API and EVM, there are some important Moonbeam differences that developers should know and understand in terms of consensus and finality. In short, consensus is a way for different parties to agree on a shared state. As blocks are created, nodes in the network must decide which block will represent the next valid state. Finality defines when that valid state cannot be altered or reversed. Ethereum began by using a consensus protocol based on [Proof-of-Work (PoW)](https://ethereum.org/en/developers/docs/consensus-mechanisms/pow){target=\_blank}, which provides probabilistic finality. However, in 2022, Ethereum switched to [Proof-of-Stake (PoS)](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos){target=\_blank}, which provides deterministic finality, and no longer uses PoW. In contrast, Moonbeam uses a hybrid consensus protocol based on Delegated Proof-of-Stake (DPoS), which also provides deterministic finality. DPoS is an evolution of Polkadot's [Nominated Proof of Stake (NPoS)](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/){target=\_blank} concept, that puts more power into the hands of token holders by allowing delegators to choose which collator candidate they want to support and in what magnitude. This guide will outline some of these main differences around consensus and finality, and what to expect when using Moonbeam for the first time. ## Ethereum Consensus and Finality {: #ethereum-consensus-and-finality } Ethereum currently uses a PoS consensus protocol, in which validators stake ETH in the network and are responsible for producing blocks and checking the validity of new blocks. The timing of block production is fixed and is divided into 12 second slots and 32 slot epochs. One validator per slot is randomly selected to produce a block and broadcast it to the network. There is a randomly selected committee of validators per slot that is responsible for determining the validity of the block. The greater the stake in the network, the greater the chance the validator will be chosen to produce or validate a block. Finality is deterministic in Ethereum's PoS consensus protocol and is achieved through "checkpoint" blocks. Validators agree on the state of a block at particular checkpoint blocks, which are always the first block in an epoch, and if two-thirds of the validators agree, the block is finalized. Block finality can be reverted; however, there are strong economic incentives in place so validators do not attempt to collude to revert a block. You can find out more information in Vitalik's [On Settlement Finality](https://blog.ethereum.org/2016/05/09/on-settlement-finality){target=\_blank} blog, under the Finality in Casper section. ## Moonbeam Consensus and Finality {: #moonbeam-consensus-and-finality } In Polkadot, there are collators and validators. [Collators](https://wiki.polkadot.com/learn/learn-collator/){target=\_blank} maintain parachains (in this case, Moonbeam) by collecting transactions from users and producing state transition proofs for the relay chain [validators](https://wiki.polkadot.com/learn/learn-validator/){target=\_blank}. The collator set (nodes that produce blocks) is selected based on the [stake they have in the network](/learn/features/consensus/){target=\_blank}. For finality, Polkadot and Kusama rely on [GRANDPA](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/#finality-gadget-grandpa){target=\_blank}. GRANDPA provides deterministic finality for any given transaction (block). In other words, when a block or transaction is marked as final, it can't be reverted except via on-chain governance or forking. Moonbeam follows this deterministic finality. ## Main Differences Between PoS and DPoS {: #main-differences } In terms of consensus, Moonbeam is based on Delegated Proof-of-Stake, while Ethereum relies on a standard Proof-of-Stake system, which is slightly different. Although both mechanisms rely on the use of stake to validate and create new blocks, there are some key differences. With PoS on Ethereum, validators are selected to produce and validate blocks based on their own stake in the network. As long as a validator has placed a validator deposit, they can be selected to produce and validate blocks. However, as previously mentioned, the greater the stake in the network, the higher the chances a validator has to be selected to produce and validate blocks. On the other hand, with DPoS on Moonbeam, collators become eligible to produce blocks based on their own stake plus their delegated stake in the network. Any token holder can choose to delegate their stake to a collator candidate. The top collator candidates by stake, including delegations, join the active set. The number of candidates in the active set is subject to [governance](/learn/features/governance/){target=\_blank}. Once in the active set, collators are randomly selected to produce blocks using the [Nimbus Consensus Framework](/learn/features/consensus/){target=\_blank}. It is important to note that once a collator is in the active set, their total stake does not impact their chances of being selected to produce blocks. In terms of finality, blocks on Ethereum can take quite a bit longer to finalize than on Moonbeam due to the checkpoint finality system it uses. In Ethereum, validators determine finality at checkpoint blocks, which are always the first block in an epoch. Since an epoch has 32 slots and each slot is 12 seconds, it'll take at least 384 seconds, or 6.4 minutes for a block to be finalized. Moonbeam does not use checkpoint blocks and instead relies on Polkadot's GRANDPA finality gadget, where the finality process is completed in parallel to block production. In addition, the finality process incorporates the blockchain's structure, which allows the relay chain validators to vote on the highest block that they think is valid. In this scenario, the vote would apply to all of the blocks leading up to the one that is finalized, which speeds up the finalization process. After a block has been included in the relay chain, a block can be finalized within one block on Moonbeam. ## Check Transaction Finality with Ethereum RPC Endpoints {: #check-tx-finality-with-ethereum-rpc-endpoints } Although the finality gadgets differ, you can use the same, fairly simple strategy to check for transaction finality on both Ethereum and Moonbeam: 1. You ask the network for the hash of the latest finalized block 2. You retrieve the block number using the hash 3. You compare it with the block number of your transaction. If your transaction was included in a previous block, it is finalized 4. As a safety check, retrieve the block by number and verify that the given transaction hash is in the block The snippets below follow this strategy to check transaction finality. It uses the `finalized` option for the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block){target=\_blank} to get the latest finalized block. To test out the examples in this guide on Moonbeam or Moonriver, you will need to have your own endpoint and API key, which you can get from one of the supported [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. !!! note The code snippets presented in the following sections are not meant for production environments. Please make sure you adapt it for each use-case. === "Ethers.js" ```js import { ethers } from 'ethers'; // Define the transaction hash to check finality const txHash = 'INSERT_TX_HASH'; // Define the RPC of the provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const providerRPC = { moonbeam: { name: 'moonbeam', rpc: 'INSERT_RPC_API_ENDPOINT', chainId: 1284, } }; // Define the Web3 provider const web3Provider = new ethers.JsonRpcProvider(providerRPC.moonbeam.rpc, { chainId: providerRPC.moonbeam.chainId, name: providerRPC.moonbeam.name, }); const main = async () => { // Get the last finalized block const finalizedBlockHeader = await web3Provider.getBlock('finalized'); const finalizedBlockNumber = finalizedBlockHeader.number; // Get the transaction receipt of the given transaction hash const txReceipt = await web3Provider.getTransactionReceipt(txHash); // If block number of receipt is not null, compare it against finalized head if (txReceipt) { const txBlockNumber = txReceipt.blockNumber; // As a safety check, get given block to check if transaction is included const txBlock = await web3Provider.getBlock(txBlockNumber); console.log(`Current finalized block number is ${finalizedBlockNumber}`); console.log( `Your transaction in block ${txBlockNumber} is finalized? ${ finalizedBlockNumber >= txBlockNumber }` ); console.log( `Your transaction is indeed in block ${txBlockNumber}? ${txBlock.transactions.includes( txHash )}` ); } else { console.log( 'Your transaction has not been included in the canonical chain' ); } }; main(); ``` === "Web3.js" ```js import { Web3 } from 'web3'; // Define the transaction hash to check finality const txHash = 'INSERT_TX_HASH'; // Define the Web3 provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const web3Provider = new Web3('INSERT_RPC_API_ENDPOINT'); const main = async () => { // Get the last finalized block const finalizedBlockHeader = await web3Provider.eth.getBlock('finalized'); const finalizedBlockNumber = finalizedBlockHeader.number; // Get the transaction receipt of the given transaction hash const txReceipt = await web3Provider.eth.getTransactionReceipt(txHash); // If block number of receipt is not null, compare it against finalized head if (txReceipt) { const txBlockNumber = txReceipt.blockNumber; // As a safety check, get given block to check if transaction is included const txBlock = await web3Provider.eth.getBlock(txBlockNumber); console.log(`Current finalized block number is ${finalizedBlockNumber}`); console.log( `Your transaction in block ${txBlockNumber} is finalized? ${ finalizedBlockNumber >= txBlockNumber }` ); console.log( `Your transaction is indeed in block ${txBlockNumber}? ${txBlock.transactions.includes( txHash )}` ); } else { console.log( 'Your transaction has not been included in the canonical chain' ); } }; main(); ``` === "Web3.py" ```py from web3 import Web3 # Define the transaction hash to check finality tx_hash = "INSERT_TX_HASH" # Define the Web3 provider for Moonbeam # This can be adapted for Moonriver or Moonbase Alpha web3_provider = Web3(Web3.HTTPProvider("INSERT_RPC_API_ENDPOINT")) if __name__ == "__main__": # Get the latest finalized block finalized_block_header = web3_provider.eth.get_block("finalized") finalized_block_number = finalized_block_header.number # Get the transaction receipt of the given transaction hash tx_receipt = web3_provider.eth.get_transaction_receipt(tx_hash) # If block number of receipt is not null, compare it against finalized head if tx_receipt is not None: tx_block_number = tx_receipt.blockNumber # As a safety check, get given block to check if transaction is included tx_block = web3_provider.eth.get_block(tx_block_number) is_in_block = False for tx in tx_block.transactions: if tx_hash == web3_provider.to_hex(tx): is_in_block = True print(f"Current finalized block number is { str(finalized_block_number) }") print( f"Your transaction in block { str(tx_block_number) } is finalized? { str(finalized_block_number >= tx_block_number) }" ) print( f"Your transaction is indeed in block { str(tx_block_number) }? { is_in_block }" ) else: print("Your transaction has not been included in the canonical chain") ``` ## Check Transaction Finality with Moonbeam RPC Endpoints {: #check-tx-finality-with-moonbeam-rpc-endpoints } Moonbeam has added support for two custom RPC endpoints, `moon_isBlockFinalized` and `moon_isTxFinalized`, that can be used to check whether an on-chain event is finalized. These methods are a bit more straightforward, as you don't need to compare block numbers to ensure your transaction is finalized. For more information, you can go to the [Finality RPC Endpoints](/builders/ethereum/json-rpc/moonbeam-custom-api/#rpc-methods){target=\_blank} section of the Moonbeam Custom API page. You can modify the scripts from the Ethereum RPC section above to use `moon_isBlockFinalized` and `moon_isTxFinalized`. To do this, you can make custom calls to the Substrate JSON-RPC using the `send` method of both [Web3.js](https://web3js.readthedocs.io){target=\_blank} and [Ethers.js](https://docs.ethers.org/v6){target=\_blank}. Custom RPC requests are also possible using [Web3.py](https://web3py.readthedocs.io){target=\_blank} with the `make_request` method. You'll need to pass in the method name and the parameters to the custom request, which you can find on the [Moonbeam Custom API](/builders/ethereum/json-rpc/moonbeam-custom-api/){target=\_blank} page. ???+ code "moon_isBlockFinalized" === "Ethers.js" ```js import { ethers } from 'ethers'; // Define the block hash to check finality const blockHash = 'INSERT_BLOCK_HASH'; // Define the RPC of the provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const providerRPC = { moonbeam: { name: 'moonbeam', rpc: 'INSERT_RPC_API_ENDPOINT', chainId: 1284, }, }; // Define the Web3 provider const web3Provider = new ethers.JsonRpcProvider(providerRPC.moonbeam.rpc, { chainId: providerRPC.moonbeam.chainId, name: providerRPC.moonbeam.name, }); // Define the function for the custom web3 request const customWeb3Request = async (web3Provider, method, params) => { try { return await web3Provider.send(method, params); } catch (error) { throw new Error(error.body); } }; const main = async () => { // Check if the block has been finalized const isFinalized = await customWeb3Request( web3Provider, 'moon_isBlockFinalized', [blockHash] ); console.log(`Block is finalized? ${isFinalized}`); }; main(); ``` === "Web3.js" ```js import { Web3 } from 'web3'; // Define the block hash to check finality const blockHash = 'INSERT_BLOCK_HASH'; // Define the Web3 provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const web3Provider = new Web3('INSERT_RPC_API_ENDPOINT'); // Define the function for the custom Web3 request const customWeb3Request = async (web3Provider, method, params) => { try { return await requestPromise(web3Provider, method, params); } catch (error) { throw new Error(error); } }; // In Web3.js you need to return a promise const requestPromise = async (web3Provider, method, params) => { return new Promise((resolve, reject) => { web3Provider.send( { jsonrpc: '2.0', id: 1, method, params, }, (error, result) => { if (error) { reject(error.message); } else { if (result.error) { reject(result.error.message); } resolve(result); } } ); }); }; const main = async () => { // Check if the block has been finalized const isFinalized = await customWeb3Request( web3Provider.currentProvider, 'moon_isBlockFinalized', [blockHash] ); console.log(JSON.stringify(isFinalized)); console.log(`Block is finalized? ${isFinalized.result}`); }; main(); ``` === "Web3.py" ```py from web3 import Web3 # Define the block hash to check finality block_hash = 'INSERT_BLOCK_HASH' # Set the RPC_address for Moonbeam # This can also be adapted for Moonriver or Moonbase Alpha RPC_address = 'INSERT_RPC_API_ENDPOINT' # Define the Web3 provider web3_provider = Web3(Web3.HTTPProvider(RPC_address)) # Asynchronous JSON-RPC API request def custom_web3_request(method, params): response = web3_provider.provider.make_request(method, params) return response if __name__ == "__main__": # Check if the block has been finalized is_finalized = custom_web3_request( 'moon_isBlockFinalized', [block_hash]) print( f'Block is finalized? { is_finalized["result"] }') ``` ??? code "moon_isTxFinalized" === "Ethers.js" ```js import { ethers } from 'ethers'; // Define the transaction hash to check finality const txHash = 'INSERT_TRANSACTION_HASH'; // Define the RPC of the provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const providerRPC = { moonbeam: { name: 'moonbeam', rpc: 'INSERT_RPC_API_ENDPOINT', chainId: 1284, }, }; // Define the Web3 provider const web3Provider = new ethers.JsonRpcProvider(providerRPC.moonbeam.rpc, { chainId: providerRPC.moonbeam.chainId, name: providerRPC.moonbeam.name, }); // Define the function for the custom web3 request const customWeb3Request = async (web3Provider, method, params) => { try { return await web3Provider.send(method, params); } catch (error) { throw new Error(error.body); } }; const main = async () => { // Check if the transaction has been finalized const isFinalized = await customWeb3Request( web3Provider, 'moon_isTxFinalized', [txHash] ); console.log(`Transaction is finalized? ${isFinalized}`); }; main(); ``` === "Web3.js" ```js import Web3 from 'web3'; // Define the transaction hash to check finality const txHash = 'INSERT_TRANSACTION_HASH'; // Define the Web3 provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const web3Provider = new Web3('INSERT_RPC_API_ENDPOINT'); // Define the function for the custom Web3 request const customWeb3Request = async (web3Provider, method, params) => { try { return await requestPromise(web3Provider, method, params); } catch (error) { throw new Error(error); } }; // In Web3.js you need to return a promise const requestPromise = async (web3Provider, method, params) => { return new Promise((resolve, reject) => { web3Provider.send( { jsonrpc: '2.0', id: 1, method, params, }, (error, result) => { if (error) { reject(error.message); } else { if (result.error) { reject(result.error.message); } resolve(result); } } ); }); }; const main = async () => { // Check if the transaction has been finalized const isFinalized = await customWeb3Request( web3Provider.currentProvider, 'moon_isTxFinalized', [txHash] ); console.log(JSON.stringify(isFinalized)); console.log(`Transaction is finalized? ${isFinalized}`); }; main(); ``` === "Web3.py" ```py from web3 import Web3 # Define the transaction hash to check finality tx_hash = 'INSERT_BLOCK_HASH' # Set the RPC_address for Moonbeam # This can also be adapted for Moonriver or Moonbase Alpha RPC_address = 'INSERT_RPC_API_ENDPOINT' # Define the Web3 provider web3_provider = Web3(Web3.HTTPProvider(RPC_address)) # Asynchronous JSON-RPC API request def custom_web3_request(method, params): response = web3_provider.provider.make_request(method, params) return response if __name__ == "__main__": # Check if the transaction has been finalized is_finalized = custom_web3_request( 'moon_isTxFinalized', [tx_hash]) print( f'Transaction is finalized? { is_finalized["result"] }') ``` ## Check Transaction Finality with Substrate RPC Endpoints {: #check-tx-finality-with-substrate-rpc-endpoints } Using the following three RPC requests from the Substrate JSON-RPC, you can fetch the current finalized block and compare it with the block number of the transaction you want to check finality for: - `chain_getFinalizedHead` - the first request gets the block hash of the last finalized block - `chain_getHeader` - the second request gets the block header for a given block hash - `eth_getTransactionReceipt` - this retrieves the transaction receipt given the transaction hash The [Polkadot.js API package](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} and [Python Substrate Interface package](/builders/substrate/libraries/py-substrate-interface/){target=\_blank} provide developers with a way to interact with Substrate chains using JavaScript and Python. You can find more information about Polkadot.js and the Substrate JSON-RPC in the [official Polkadot.js documentation site](https://polkadot.js.org/docs/substrate/rpc){target=\_blank}, and more about Python Substrate Interface in the [official PySubstrate documentation site](https://jamdottech.github.io/py-polkadot-sdk/){target=\_blank}. === "Polkadot.js" ```js import { ApiPromise, WsProvider } from '@polkadot/api'; import { types } from 'moonbeam-types-bundle'; // Define the transaction hash to check finality const txHash = 'INSERT_TX_HASH'; // Define the provider for Moonbeam // This can be adapted for Moonriver or Moonbase Alpha const wsProvider = new WsProvider('INSERT_WSS_API_ENDPOINT'); const main = async () => { // Create the provider using Moonbeam types const polkadotApi = await ApiPromise.create({ provider: wsProvider, typesBundle: types, }); await polkadotApi.isReady; // Get the latest finalized block of the Substrate chain const finalizedHeadHash = ( await polkadotApi.rpc.chain.getFinalizedHead() ).toJSON(); // Get finalized block header to retrieve number const finalizedBlockHeader = ( await polkadotApi.rpc.chain.getHeader(finalizedHeadHash) ).toJSON(); // Get the transaction receipt of the given tx hash const txReceipt = ( await polkadotApi.rpc.eth.getTransactionReceipt(txHash) ).toJSON(); // You can not verify if the tx is in the block because polkadotApi.rpc.eth.getBlockByNumber // does not return the list of tx hashes // If block number of receipt is not null, compare it against finalized head if (txReceipt) { console.log( `Current finalized block number is ${finalizedBlockHeader.number}` ); console.log( `Your transaction in block ${txReceipt.blockNumber} is finalized? ${ finalizedBlockHeader.number >= txReceipt.blockNumber }` ); } else { console.log( 'Your transaction has not been included in the canonical chain' ); } polkadotApi.disconnect(); }; main(); ``` === "py-substrate-interface" ```py from substrateinterface import SubstrateInterface # Define the Ethereum transaction hash to check finality tx_hash = "INSERT_TX_HASH" # Point API provider to Moonbeam # This can be adapted for Moonriver or Moonbase Alpha moonbeam_API_provider = SubstrateInterface( url="INSERT_WSS_API_ENDPOINT", ) if __name__ == "__main__": # Get the latest finalized block header of the chain finalized_block_header = moonbeam_API_provider.get_block_header(finalized_only=True) # Get the finalized block number from the block header finalized_block_number = finalized_block_header["header"]["number"] # Get the transaction receipt of the given transaction hash through a # custom RPC request tx_receipt = moonbeam_API_provider.rpc_request( "eth_getTransactionReceipt", [tx_hash] ) # Check if tx_receipt is null if tx_receipt is None: print("The transaction hash cannot be found in the canonical chain.") else: # Get the block number of the transaction tx_block_number = int(tx_receipt["result"]["blockNumber"], 16) # Get the transaction block through a custom RPC request tx_block = moonbeam_API_provider.rpc_request( "eth_getBlockByNumber", [tx_block_number, False] ) print(f"Current finalized block number is { str(finalized_block_number) }") print( f"Your transaction in block { str(tx_block_number) } is finalized? { str(finalized_block_number >= tx_block_number) }" ) print( f'Your transaction is indeed in block { str(tx_block_number) }? { str(tx_hash in tx_block["result"]["transactions"]) }' ) ```
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/core-concepts/security/ --- BEGIN CONTENT --- --- title: Security Considerations description: A description of the main differences that Ethereum developers need to understand in terms of security considerations when developing on Moonbeam. categories: Basics --- # Security Considerations ## Introduction {: #introduction } When developing smart contracts on Moonbeam, there are some security considerations to be aware of that do not apply when developing on Ethereum. Moonbeam has several [precompiled contracts](/builders/ethereum/precompiles/){target=\_blank}, which are Solidity interfaces that enable developers to access Substrate-based functionality through the Ethereum API, but circumventing the EVM. Although the precompiled contracts are designed to improve the developer experience, there can be some unintended consequences that must be considered. This guide will outline and provide examples of some security considerations to be cognizant of when developing on Moonbeam. ## Arbitrary Code Execution {: #arbitrary-code-execution } Arbitrary code execution in Solidity is the ability to execute code and call functions of other contracts using an arbitrary number of arguments of any type. A smart contract allows arbitrary execution of another contract when it allows a user to influence its own `call()` and pass in arbitrary call data and/or the `call()`s target. The [`call()` function](https://solidity-by-example.org/call){target=\_blank} is made available through the [address data type in Solidity](https://docs.soliditylang.org/en/latest/types.html#address){target=\_blank}. When the `call()` function is invoked, the target contract is called using the arbitrary call data. Arbitrary code execution follows the pattern in the diagram below when **Contract A** allows a user to influence its call to **Contract B**. ![Arbitrary code execution](/images/learn/core-concepts/security/security-1.webp) As previously mentioned, one major concern of arbitrarily executing code on Moonbeam is that Moonbeam has precompile contracts that can be called, which can be used to get around some protections that are typically available on Ethereum. To safely use arbitrary code execution on Moonbeam, you should consider the following, which **only applies to contracts that allow arbitrary code execution**: - Moonbeam [precompiled contracts](/builders/ethereum/precompiles/){target=\_blank} such as the Native ERC-20 precompile, XC-20 precompiles, and XCM-related precompiles allow users to manage and transfer assets without requiring access to the EVM. Instead, these actions are done using native Substrate code. So, if your contract holds native tokens or XC-20s and allows arbitrary code execution, these precompiles can be used to drain the balance of the contract, bypassing any security checks that are normally enforced by the EVM - Setting the value attribute of the transaction object to a fixed amount when using the `call()` function (for example, `call{value: 0}(...)`) can be bypassed by calling the native asset precompile and specifying an amount to transfer in the encoded call data - Allowing users that consume your contract to pass in arbitrary call data that will execute any function on the target contract, especially if the contract being targeted is a precompile, is **not** safe. To be safe, you can hard code the function selector for a safe function that you want to allow to be executed - Blacklisting target contracts (including precompiles) in the function that executes arbitrary call data is **not** considered safe, as other precompiles might be added in the future. Providing whitelisted target contracts in the function that executes the arbitrary call data is considered safe, assuming that the contracts being called are not precompiles, or that in the case they are, the contract making the call does not hold the native token or any XC-20 In the following sections, you'll learn about each of these security considerations through examples. ### Precompiles Can Override a Set Value {: #setting-a-value } On Ethereum, a smart contract that allows for arbitrary code execution could force the value of a call to be a specific amount (for example, `{value: 0}`), guaranteeing that only that amount of native currency would be sent with the transaction. Whereas on Moonbeam, the [native ERC-20 precompile contract](/builders/ethereum/precompiles/ux/erc20/){target=\_blank} enables you to interact with the native currency on Moonbeam as an ERC-20 through the Substrate API. As a result, you can transfer the Moonbeam native asset from a smart contract by setting the `value` of a call, as well as through the native ERC-20 precompile. If you set the `value` of an arbitrary call, it can be overridden by targeting the [native ERC-20 precompile contract](/builders/ethereum/precompiles/ux/erc20/){target=\_blank} and passing in call data to transfer the native asset. Since ERC-20s and XC-20s are not native assets, setting the value attribute doesn't provide any protection for these types of assets on Ethereum or Moonbeam. For example, if you have a contract that allows arbitrary code execution and you pass it encoded call data that transfers the balance of a contract to another address, you could essentially drain the given contract of its balance. To get the encoded call data, you can use any of the [ABI encoding functions outlined in the Solidity docs](https://docs.soliditylang.org/en/latest/units-and-global-variables.html#abi-encoding-and-decoding-functions){target=\_blank}, including `abi.encodeWithSelector` as seen in the following function: ```solidity function getBytes(address _erc20Contract, address _arbitraryCallContract, address _to) public view returns (bytes memory) { // Load ERC-20 interface of contract IERC20 erc20 = IERC20(_erc20Contract); // Get amount to transfer uint256 amount = erc20.balanceOf(_arbitraryCallContract); // Build the encoded call data return abi.encodeWithSelector(IERC20.transfer.selector, _to, amount); } ``` Once you have the encoded call data, you could make an arbitrary call to the [native ERC-20 precompile contract](/builders/ethereum/precompiles/ux/erc20/){target=\_blank}, set the value of the call to `0`, and pass in the call data in bytes: ```solidity function makeArbitraryCall(address _target, bytes calldata _bytes) public { // Value: 0 does not protect against native ERC-20 precompile calls or XCM precompiles (bool success,) = _target.call{value: 0}(_bytes); require(success); } ``` The value of `0` will be overridden by the amount to be transferred as specified in the encoded call data, which in this example is the balance of the contract. ### Whitelisting Safe Function Selectors {: #whitelisting-function-selectors } By whitelisting a specific function selector, you can control what functions can be executed and ensure only functions that are considered safe and do not call precompiles are allowed to be called. To get the function selector to whitelist, you can [keccack256 hash](https://emn178.github.io/online-tools/keccak_256.html){target=\_blank} the signature of the function. Once you have the whitelisted function selector, you can use inline assembly to get the function selector from the encoded call data and compare the two selectors using the [require function](https://docs.soliditylang.org/en/v0.8.17/control-structures.html#panic-via-assert-and-error-via-require){target=\_blank}. If the function selector from the encoded call data matches the whitelisted function selector, you can make the call. Otherwise, an exception will be thrown. ```solidity function makeArbitraryCall(address _target, bytes calldata _bytes) public { // Get the function selector from the encoded call data bytes4 selector; assembly { selector := calldataload(_bytes.offset) } // Ensure the call data calls an approved and safe function require(selector == INSERT_WHITELISTED_FUNCTION_SELECTOR); // Arbitrary call (bool success,) = _target.call(_bytes); require(success); } ``` ### Whitelisting Safe Contracts {: #whitelisting-safe-contracts} By whitelisting a specific target contract address in the function that can execute arbitrary call data, you can ensure that the call is considered safe, as the EVM will enforce that only whitelisted contracts can be called. This assumes that the contracts being called are not precompiles. If they are precompiles, you'll want to make sure that the contract making the call does not hold the native token or any XC-20. Blacklisting contracts from arbitrary code execution is not considered safe, as other precompiles might be added in the future. To whitelist a given contract, you can use the [require function](https://docs.soliditylang.org/en/v0.8.17/control-structures.html#panic-via-assert-and-error-via-require){target=\_blank}, which will compare the target contract address to the whitelisted contract address. If the addresses match, the call can be executed. Otherwise, an exception will be thrown. ```solidity function makeArbitraryCall(address _target, bytes calldata _bytes) public { // Ensure the contract address is safe require(_target == INSERT_CONTRACT_ADDRESS); // Arbitrary call (bool success,) = _target.call(_bytes); require(success); } ``` ## Precompiles Can Bypass Sender vs Origin Checks {: #bypass-sender-origin-checks } The transaction origin, or `tx.origin`, is the address of the externally owned account (EOA) the transaction originated from. Whereas the `msg.sender` is the address that has initiated the current call. The `msg.sender` can be an EOA or a contract. The two can be different values if one contract calls another contract, as opposed to directly calling a contract from an EOA. In this case, the `msg.sender` will be the calling contract and the `tx.origin` will be the EOA that initially called the calling contract. For example, if Alice calls a function in contract A that then calls a function in contract B, when looking at the call to contract B, the `tx.origin` is Alice and the `msg.sender` is contract A. !!! note As a [best practice](https://consensysdiligence.github.io/smart-contract-best-practices/development-recommendations/solidity-specific/tx-origin/){target=\_blank}, `tx.origin` should not be used for authorization. Instead, you should use `msg.sender`. You can use the [require function](https://docs.soliditylang.org/en/v0.8.17/control-structures.html#panic-via-assert-and-error-via-require){target=\_blank} to compare the `tx.origin` and `msg.sender`. If they are the same address, you're ensuring that only EOAs can call the function. If the `msg.sender` is a contract address, an exception will be thrown. ```solidity function transferFunds(address payable _target) payable public { require(tx.origin == msg.sender); _target.call{value: msg.value}; } ``` On Ethereum, you can use this check to ensure that a given contract function can only be called once by an EOA. This is because on Ethereum, EOAs can only interact with a contract once per transaction. However, **this is not the case** on Moonbeam, as EOAs can interact with a contract multiple times at once by using precompiled contracts, such as the [batch](/builders/ethereum/precompiles/ux/batch/){target=\_blank} and [call permit](/builders/ethereum/precompiles/ux/call-permit/){target=\_blank} precompiles. With the batch precompile, users can perform multiple calls to a contract atomically. The caller of the batch function will be the `msg.sender` and `tx.origin`, enabling multiple contract interactions at once. With the call permit precompile, if a user wants to interact with a contract multiple times in one transaction, they can do so by signing a permit for each contract interaction and dispatching all of the permits in a single function call. This will only bypass the `tx.origin == msg.sender` check if the dispatcher is the same account as the permit signer. Otherwise, the `msg.sender` will be the permit signer and the `tx.origin` will be the dispatcher, causing an exception to be thrown. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/core-concepts/transfers-api/ --- BEGIN CONTENT --- --- title: Transfer & Monitor Balances on Moonbeam description: A description of the main differences that developers need to understand in terms of the different balance transfers available on Moonbeam compared to Ethereum. categories: Basics --- # Balance Transfers on Moonbeam ## Introduction {: #introduction } While Moonbeam strives to be compatible with Ethereum's Web3 API and EVM, there are some important Moonbeam differences that developers should know and understand in terms of balance transfers of the base network token (for example, GLMR and MOVR). Token holders have two ways of initiating a balance transfer on Moonbeam. On the one hand, users can use the Ethereum API via apps like MetaMask, MathWallet, or any other tools that use the Ethereum JSON-RPC. On the other hand, users can use the Substrate API via the Polkadot.js Apps website or directly using the Substrate RPC. Developers need to be aware that token holders can leverage both APIs to transfer the base-layer network token. Note that these comments do not apply to transfers of other assets, like ERC-20 based assets in the Moonriver or Moonbeam EVMs. Transfers of these assets are only done via the Ethereum APIs since these are smart contract interactions. This guide will outline some of the main differences between both APIs for base-layer network token balance transfers and what to expect when using Moonbeam for the first time. ## Ethereum Transfers {: #ethereum-transfers } A simple balance transfer using the Ethereum API relies on the `eth_sendRawTransaction` JSON-RPC. This can be done directly from one account to another or via a smart contract. There are different strategies to listen for transfers or balance changes on Ethereum, which are not covered in this documentation. But they are all focused on different strategies using the Ethereum JSON-RPC. ## Moonbeam Transfers {: #moonbeam-transfers } As stated before, Moonbeam enables token holders to execute base-layer network token transfers via both the Ethereum and Substrate API. There are multiple scenarios to trigger token transfers on Moonbeam. Consequently, to monitor all transfers, **you should use the Polkadot.js SDK** (Substrate API). Before going over the different scenarios, there are two different elements associated with a block: - **Extrinsic** — refers to state changes that originated outside of the system itself. The most common form of extrinsic is a transaction. They are ordered by execution - **Events** — refers to logs generated from the extrinsic. There can be multiple events per extrinsic. They are ordered by execution The different transfer scenarios are: - **Substrate transfer** — it will create an extrinsic, either `balances.transferAllowDeath` or `balances.transferKeepAlive`. It will trigger **one** `balances.Transfer` event - **Substrate feature** — some native Substrate features can create extrinsic that would send tokens to an address. For example, [Treasury](/learn/features/treasury/){target=\_blank} can create an extrinsic such as `treasury.proposeSend`, which will trigger **one or multiple** `balances.Transfer` events - **Ethereum transfer** — it will create an `ethereum.transact` extrinsic with an empty input. It will trigger **one** `balances.Transfer` event - **Ethereum transfers via smart contracts** — it will create an `ethereum.transact` extrinsic with some data as input. It will trigger **one or multiple** `balances.Transfer` events All the scenarios described above will effectively transfer base-layer network tokens. The easiest way to monitor them all is to rely on the `balances.Transfer` event. ## Monitor Native Token Balance Transfers {: #monitor-transfers } The following code samples will demonstrate how to listen to both types of native token transfers, sent via the Substrate or Ethereum API, using either the [Polkadot.js API library](https://polkadot.js.org/docs/api/start/){target=\_blank} or [Substrate API Sidecar](https://github.com/paritytech/substrate-api-sidecar){target=\_blank}. The following code snippets are for demo purposes only and should not be used without modification and further testing in a production environment. ### Using Polkadot.js API {: #using-polkadotjs-api } The [Polkadot.js API package](https://polkadot.js.org/docs/api/start/){target=\_blank} provides developers a way to interact with Substrate chains using JavaScript. The following code snippet uses [`subscribeFinalizedHeads`](https://polkadot.js.org/docs/substrate/rpc/#subscribefinalizedheads-header){target=\_blank} to subscribe to new finalized block headers, loops through extrinsics fetched from the block, and retrieves the events of each extrinsic. Then, it checks if any event corresponds to a `balances.Transfer` event. If so, it will extract the `from`, `to`, `amount`, and the `tx hash` of the transfer and display it on the console. Note that the `amount` is shown in the smallest unit (Wei). You can find all the available information about Polkadot.js and the Substrate JSON-RPC on their [official documentation site](https://polkadot.js.org/docs/substrate/rpc){target=\_blank}. ```ts import { typesBundlePre900 } from 'moonbeam-types-bundle'; import { ApiPromise, WsProvider } from '@polkadot/api'; // This script will listen to all GLMR transfers (Substrate & Ethereum) and extract the tx hash // It can be adapted for Moonriver or Moonbase Alpha const main = async () => { // Define the provider for Moonbeam const wsProvider = new WsProvider('wss://wss.api.moonbeam.network'); // Create the provider using Moonbeam types const polkadotApi = await ApiPromise.create({ provider: wsProvider, typesBundle: typesBundlePre900 as any, }); // Subscribe to finalized blocks await polkadotApi.rpc.chain.subscribeFinalizedHeads( async (lastFinalizedHeader) => { const [{ block }, records] = await Promise.all([ polkadotApi.rpc.chain.getBlock(lastFinalizedHeader.hash), polkadotApi.query.system.events.at(lastFinalizedHeader.hash), ]); block.extrinsics.forEach((extrinsic, index) => { const { method: { args, method, section }, } = extrinsic; const isEthereum = section == 'ethereum' && method == 'transact'; // Gets the transaction object const tx = args[0] as any; // Convert to the correct Ethereum Transaction format const ethereumTx = isEthereum && ((tx.isLegacy && tx.asLegacy) || (tx.isEip1559 && tx.asEip1559) || (tx.isEip2930 && tx.asEip2930)); // Check if the transaction is a transfer const isEthereumTransfer = ethereumTx && ethereumTx.input.length === 0 && ethereumTx.action.isCall; // Retrieve all events for this extrinsic const events = records.filter( ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(index) ); // This hash will only exist if the transaction was executed through Ethereum. let ethereumHash = ''; if (isEthereum) { // Search for Ethereum execution events.forEach(({ event }) => { if (event.section == 'ethereum' && event.method == 'Executed') { ethereumHash = event.data[2].toString(); } }); } // Search if it is a transfer events.forEach(({ event }) => { if (event.section == 'balances' && event.method == 'Transfer') { const from = event.data[0].toString(); const to = event.data[1].toString(); const balance = (event.data[2] as any).toBigInt(); const substrateHash = extrinsic.hash.toString(); console.log( `Transfer from ${from} to ${to} of ${balance} (block #${lastFinalizedHeader.number})` ); console.log(` - Triggered by extrinsic: ${substrateHash}`); if (isEthereum) { console.log( ` - Ethereum (isTransfer: ${isEthereumTransfer}) hash: ${ethereumHash}` ); } } }); }); } ); }; main(); ``` In addition, you can find more sample code snippets related to more specific cases around balance transfers on this [GitHub page](https://gist.github.com/crystalin/b2ce44a208af60d62b5ecd1bad513bce){target=\_blank}. ### Using Substrate API Sidecar {: #using-substrate-api-sidecar } Developers can also retrieve Moonbeam blocks and monitor transactions sent via both the Substrate and Ethereum APIs using [Substrate API Sidecar](https://github.com/paritytech/substrate-api-sidecar){target=\_blank}, a REST API service for interacting with blockchains built with the Substrate framework. The following code snippet uses the Axios HTTP client to query the [Sidecar endpoint `/blocks/head`](https://paritytech.github.io/substrate-api-sidecar/dist){target=\_blank} for the latest finalized block and then decodes the block for the `from`, `to`, `value`, `tx hash`, and `transaction status` of native token transfers at both the EVM and Substrate API level. ```js import axios from 'axios'; // This script will decode all native token transfers (Substrate & Ethereum) in a given Sidecar block, and extract the tx hash. It can be adapted for any Moonbeam network. // Endpoint to retrieve the latest block const endpoint = 'http://127.0.0.1:8080/blocks/head'; async function main() { try { // Retrieve the block from the Sidecar endpoint const response = await axios.get(endpoint); // Retrieve the block height of the current block console.log('Block Height: ' + response.data.number); // Iterate through all extrinsics in the block response.data.extrinsics.forEach((extrinsic) => { // Retrieve Ethereum Transfers if ( extrinsic.method.pallet === 'ethereum' && extrinsic.method.method === 'transact' ) { // Get the value for any of the three EIP transaction standards supported const value = (extrinsic.args.transaction.legacy && extrinsic.args.transaction.legacy.value) || (extrinsic.args.transaction.eip1559 && extrinsic.args.transaction.eip1559.value) || (extrinsic.args.transaction.eip2930 && extrinsic.args.transaction.eip2930.value); // Iterate through the events to get transaction details extrinsic.events.forEach((event) => { if ( event.method.pallet === 'ethereum' && event.method.method === 'Executed' ) { console.log('From: ' + event.data[0]); console.log('To: ' + event.data[1]); console.log('Tx Hash: ' + event.data[2]); console.log('Value: ' + value); // Check the execution status if (event.data[3].succeed) { console.log('Status: Success'); } else { console.log('Status: Failed'); } } }); } // Retrieve Substrate Transfers if ( extrinsic.method.pallet === 'balances' && (extrinsic.method.method === 'transferKeepAlive' || extrinsic.method.method === 'transferAllowDeath') ) { // Iterate through the events to get transaction details extrinsic.events.forEach((event) => { if ( event.method.pallet === 'balances' && event.method.method === 'Transfer' ) { console.log('From: ' + event.data[0]); console.log('To: ' + event.data[1]); console.log('Tx Hash: ' + extrinsic.hash); console.log('Value: ' + event.data[2]); // Check the execution status if (extrinsic.success) { console.log('Status: Success'); } else { console.log('Status: Failed'); } } }); } }); } catch (err) { console.log(err); } } main(); ``` You can reference the [Substrate API Sidecar page](/builders/substrate/libraries/sidecar/) for information on installing and running your own Sidecar service instance, as well as more details on how to decode Sidecar blocks for Moonbeam transactions. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/core-concepts/tx-fees/ --- BEGIN CONTENT --- --- title: Calculating Transaction Fees description: Learn about the transaction fee model used in Moonbeam and the differences compared to Ethereum that developers should be aware of. categories: Basics --- # Calculating Transaction Fees on Moonbeam ## Introduction {: #introduction } Similar to [the Ethereum and Substrate APIs for sending transfers](/learn/core-concepts/transfers-api/){target=\_blank} on Moonbeam, the Substrate and EVM layers on Moonbeam also have distinct transaction fee models that developers should be aware of when they need to calculate and keep track of transaction fees for their transactions. For starters, Ethereum transactions consume gas units based on their computational complexity and data storage requirements. On the other hand, Substrate transactions use the concept of "weight" to determine fees. In this guide, you'll learn how to calculate the transaction fees for both Substrate and Ethereum transactions. In terms of Ethereum transactions, you'll also learn about the key differences between how transaction fees are calculated on Moonbeam and Ethereum. ### Key Differences with Ethereum {: #key-differences-with-ethereum} There are some key differences between the transaction fee model on Moonbeam and the one on Ethereum that developers should be mindful of when developing on Moonbeam: - The [dynamic fee mechanism](https://forum.moonbeam.network/t/proposal-status-idea-dynamic-fee-mechanism-for-moonbeam-and-moonriver/241){target=\_blank} resembles that of [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559){target=\_blank} but the implementation is different - The amount of gas used in Moonbeam's transaction fee model is mapped from the transaction's Substrate extrinsic `refTime` component of the transaction weight via a fixed factor of `{{ networks.moonbase.tx_weight_to_gas_ratio }}` and `proofSize` component of the transaction weight via a fixed factor of `{{ xcm.generic_weights.proof_size.weight_per_gas }}`. The transaction weight vector is then multiplied with the unit gas price to calculate the transaction fee. This fee model means it can potentially be significantly cheaper to send transactions such as basic balance transfers via the Ethereum API than the Substrate API. - The EVM is designed to solely have capacity for gas and Moonbeam requires additional metrics outside of gas. In particular, Moonbeam needs the ability to record proof size, which is the amount of storage required on Moonbeam for a relay chain validator to verify a state transition. When the capacity limit for proof size has been reached for the current block, which is 25% of the block limit, an "Out of Gas" error will be thrown. This can happen even if there is remaining *legacy* gas in the gasometer. This additional metric also impacts refunds. Refunds are based on the more consumed resource after the execution. In other words, if more proof size has been consumed proportionally than legacy gas, the refund will be calculated using proof size - Moonbeam has implemented a new mechanism defined in [MBIP-5](https://github.com/moonbeam-foundation/moonbeam/blob/master/MBIPS/MBIP-5.md){target=\_blank} that limits block storage and increases gas usage for transactions that result in an increase in storage ## Overview of MBIP-5 {: #overview-of-mbip-5 } MBIP-5 introduced changes to Moonbeam's fee mechanism that account for storage growth on the network, which deviates from the way Ethereum handles fees. By raising the gas needed to execute transactions that increase chain state and by establishing a block storage limit, it controls storage growth. This impacts contract deployments that add to the chain state, transactions that create new storage entries, and precompiled contract calls that result in the creation of new accounts. The block storage limit prevents transactions in a single block from collectively increasing the storage state by more than the limit. The limit for each network is as follows: === "Moonbeam" ```text {{ networks.moonbeam.mbip_5.block_storage_limit }}KB ``` === "Moonriver" ```text {{ networks.moonriver.mbip_5.block_storage_limit }}KB ``` === "Moonbase Alpha" ```text {{ networks.moonbase.mbip_5.block_storage_limit }}KB ``` To determine the amount of gas for storage in bytes, there is a ratio that is defined as: ```text Ratio = Block Gas Limit / (Block Storage Limit * 1024 Bytes) ``` The block gas limit for each network is as follows: === "Moonbeam" ```text {{ networks.moonbeam.gas_block }} ``` === "Moonriver" ```text {{ networks.moonriver.gas_block }} ``` === "Moonbase Alpha" ```text {{ networks.moonbase.gas_block }} ``` Knowing the block gas and storage limits, the ratio of gas to storage is computed as follows: === "Moonbeam" ```text Ratio = {{ networks.moonbeam.gas_block_numbers_only }} / ({{ networks.moonbeam.mbip_5.block_storage_limit }} * 1024) Ratio = {{ networks.moonbeam.mbip_5.gas_storage_ratio }} ``` === "Moonriver" ```text Ratio = {{ networks.moonriver.gas_block_numbers_only }} / ({{ networks.moonriver.mbip_5.block_storage_limit }} * 1024) Ratio = {{ networks.moonriver.mbip_5.gas_storage_ratio }} ``` === "Moonbase Alpha" ```text Ratio = {{ networks.moonbase.gas_block_numbers_only }} / ({{ networks.moonbase.mbip_5.block_storage_limit }} * 1024) Ratio = {{ networks.moonbase.mbip_5.gas_storage_ratio }} ``` Then, you can take the storage growth in bytes for a given transaction and multiply it by the gas-to-storage growth ratio to determine how many units of gas to add to the transaction. For example, if you execute a transaction that increases the storage by {{ networks.moonbase.mbip_5.example_storage }} bytes, the following calculation is used to determine the units of gas to add: === "Moonbeam" ```text Additional Gas = {{ networks.moonbeam.mbip_5.example_storage }} * {{ networks.moonbeam.mbip_5.gas_storage_ratio }} Additional Gas = {{ networks.moonbeam.mbip_5.example_addtl_gas }} ``` === "Moonriver" ```text Additional Gas = {{ networks.moonriver.mbip_5.example_storage }} * {{ networks.moonriver.mbip_5.gas_storage_ratio }} Additional Gas = {{ networks.moonriver.mbip_5.example_addtl_gas }} ``` === "Moonbase Alpha" ```text Additional Gas = {{ networks.moonbase.mbip_5.example_storage }} * {{ networks.moonbase.mbip_5.gas_storage_ratio }} Additional Gas = {{ networks.moonbase.mbip_5.example_addtl_gas }} ``` To see how this MBIP differentiates Moonbeam from Ethereum firsthand, you can estimate the gas for two different contract interactions on both networks: one that modifies an item in the chain state and one that doesn't. For example, you can use a greeting contract that allows you to store a name and then use the name to say "Hello". ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract SayHello { mapping(address => string) public addressToName; constructor(string memory _name) { addressToName[msg.sender] = _name; } // Store a name associated to the address of the sender function setName(string memory _name) public { addressToName[msg.sender] = _name; } // Use the name in storage associated to the sender function sayHello() external view returns (string memory) { return string(abi.encodePacked("Hello ", addressToName[msg.sender])); } } ``` You can deploy this contract on both Moonriver and Ethereum, or on Moonbeam's TestNet, Moonbase Alpha, and Ethereum's TestNet, Sepolia. The above contract has already been deployed to Moonbase Alpha and Sepolia. You can feel free to access these contracts at the following addresses: === "Moonbase Alpha" ```text 0xDFF8E772A9B212dc4FbA19fa650B440C5c7fd7fd ``` === "Sepolia" ```text 0x8D0C059d191011E90b963156569A8299d7fE777d ``` Next, you can use the `eth_estimateGas` method to check the gas estimate for calling the `setName` and `sayHello` functions on each network. To do so, you'll need the bytecode for each transaction, which includes the function selector, and for the `setName` function, the name to be set. This example bytecode sets the name to "Chloe": === "Set Name" ```text 0xc47f00270000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000543686c6f65000000000000000000000000000000000000000000000000000000 ``` === "Say Hello" ```text 0xef5fb05b ``` Now, you can use the following curl commands on Moonbase Alpha to return the gas estimate: === "Set Name" ```sh curl {{ networks.moonbase.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params":[{ "to": "0xDFF8E772A9B212dc4FbA19fa650B440C5c7fd7fd", "data": "0xc47f00270000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000543686c6f65000000000000000000000000000000000000000000000000000000" }] }' ``` === "Say Hello" ```sh curl {{ networks.moonbase.rpc_url }} -H "Content-Type:application/json;charset=utf-8" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params":[{ "to": "0xDFF8E772A9B212dc4FbA19fa650B440C5c7fd7fd", "data": "0xef5fb05b" }] }' ``` Then on Sepolia, you can use the same bytecode for the `data` and modify the RPC URL and contract address to target the contract deployed to Sepolia: === "Set Name" ```sh curl https://sepolia.publicgoods.network -H "Content-Type:application/json;charset=utf-8" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params":[{ "to": "0x8D0C059d191011E90b963156569A8299d7fE777d", "data": "0xc47f00270000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000543686c6f65000000000000000000000000000000000000000000000000000000" }] }' ``` === "Say Hello" ```sh curl https://sepolia.publicgoods.network -H "Content-Type:application/json;charset=utf-8" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params":[{ "to": "0x8D0C059d191011E90b963156569A8299d7fE777d", "data": "0xef5fb05b" }] }' ``` At the time of writing, the gas estimates for both networks are as follows: === "Moonbase Alpha" | Method | Gas Estimate | |:----------:|:------------:| | `setName` | 45977 | | `sayHello` | 25938 | === "Sepolia" | Method | Gas Estimate | |:----------:|:------------:| | `setName` | 21520 | | `sayHello` | 21064 | You'll see that on Sepolia, the gas estimates for both calls are very similar, whereas on Moonbase Alpha, there is a noticeable difference between the calls and that the `setName` call, which modifies the storage, uses more gas than the `sayHello` call. ## Ethereum API Transaction Fees {: #ethereum-api-transaction-fees } To calculate the fee incurred on a Moonbeam transaction sent via the Ethereum API, the following formula can be used: === "EIP-1559" ```text GasPrice = BaseFee + MaxPriorityFeePerGas < MaxFeePerGas ? BaseFee + MaxPriorityFeePerGas : MaxFeePerGas; Transaction Fee = (GasPrice * TransactionWeight) / {{ networks.moonbase.tx_weight_to_gas_ratio }} ``` === "Legacy" ```text Transaction Fee = (GasPrice * TransactionWeight) / {{ networks.moonbase.tx_weight_to_gas_ratio }} ``` === "EIP-2930" ```text Transaction Fee = (GasPrice * TransactionWeight) / {{ networks.moonbase.tx_weight_to_gas_ratio }} ``` !!! note EIP-1559 transaction fees on Moonbeam are calculated using the previous block's base fee. The following sections describe in more detail each of the components needed to calculate the transaction fee. ### Base Fee {: #base-fee} The `BaseFee` is the minimum amount charged to send a transaction and is a value set by the network itself. It was introduced in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559){target=\_blank}. Moonbeam has its own [dynamic fee mechanism](https://forum.moonbeam.network/t/proposal-status-idea-dynamic-fee-mechanism-for-moonbeam-and-moonriver/241){target=\_blank} for calculating the base fee, which is adjusted based on block congestion. As of runtime 2300, the dynamic fee mechanism has been rolled out to all of the Moonbeam-based networks. The minimum gas price for each network is as follows: === "Moonbeam" | Variable | Value | |:-----------------:|:------------------------------------------:| | Minimum Gas Price | {{ networks.moonbeam.min_gas_price }} Gwei | === "Moonriver" | Variable | Value | |:-----------------:|:------------------------------------------:| | Minimum Gas Price | {{ networks.moonriver.min_gas_price }} Gwei | === "Moonbase Alpha" | Variable | Value | |:-----------------:|:------------------------------------------:| | Minimum Gas Price | {{ networks.moonbase.min_gas_price }} Gwei | To calculate the dynamic base fee, the following calculation is used: === "Moonbeam" ```text BaseFee = NextFeeMultiplier * 31250000000 / 10^18 ``` === "Moonriver" ```text BaseFee = NextFeeMultiplier * 312500000 / 10^18 ``` === "Moonbase Alpha" ```text BaseFee = NextFeeMultiplier * 31250000 / 10^18 ``` The value of `NextFeeMultiplier` can be retrieved from the Substrate Sidecar API, via the following endpoint: ```text GET /pallets/transaction-payment/storage/nextFeeMultiplier?at={blockId} ``` The pallets endpoints for Sidecar returns data relevant to a pallet, such as data in a pallet's storage. You can read more about the pallets endpoint in the [official Sidecar documentation](https://paritytech.github.io/substrate-api-sidecar/dist/#operations-tag-pallets){target=\_blank}. The data at hand that's required from storage is the `nextFeeMultiplier`, which can be found in the `transaction-payment` pallet. The stored `nextFeeMultiplier` value can be read directly from the Sidecar storage schema. Read as a JSON object, the relevant nesting structure is as follows: ```text RESPONSE JSON Storage Object: |--at |--hash |--height |--pallet |--palletIndex |--storageItem |--keys |--value ``` The relevant data will be stored in the `value` key of the JSON object. This value is a fixed point data type, hence the real value is found by dividing the `value` by `10^18`. This is why [the calculation of `BaseFee`](#ethereum-api-transaction-fees) includes such an operation. ### GasPrice, MaxFeePerGas, and MaxPriorityFeePerGas {: #gasprice-maxfeepergas-maxpriorityfeepergas } The `GasPrice` is used to specify the gas price of legacy transactions prior to [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559){target=\_blank}. The `MaxFeePerGas` and `MaxPriorityFeePerGas` were both introduced in EIP-1559 alongside the `BaseFee`. The `MaxFeePerGas` defines the maximum fee permitted to be paid per unit of gas and is the sum of the `BaseFee` and the `MaxPriorityFeePerGas`. The `MaxPriorityFeePerGas` is the maximum priority fee configured by the sender of a transaction that is used to incentivize the prioritization of a transaction in a block. Although Moonbeam is Ethereum-compatible, it is also a Substrate-based chain at its core, and priorities work differently in Substrate than in Ethereum. In Substrate, transactions are not prioritized by gas price. To address this, Moonbeam uses a modified prioritization system that reprioritizes Substrate transactions using an Ethereum-first solution. A Substrate transaction still goes through the validity process, where it is assigned transaction tags, longevity, and a priority. The original priority is then overwritten with a new priority based on the transaction's fee per gas, which is derived from the transaction's tip and weight. If the transaction is an Ethereum transaction, the priority is set according to the priority fee. It's important to note that priority is not the sole component responsible for determining the order of transactions in a block. Other components, such as the longevity of a transaction, also play a role in the sorting process. The values of `GasPrice`, `MaxFeePerGas` and `MaxPriorityFeePerGas` for the applicable transaction types can be read from the block JSON object according to the structure described in [the Sidecar API page](/builders/substrate/libraries/sidecar/#evm-fields-mapping-in-block-json-object){target=\_blank}. The data for an Ethereum transaction in a particular block can be extracted from the following block endpoint: ```text GET /blocks/{blockId} ``` The paths to the relevant values have also been truncated and reproduced below: === "EIP1559" | EVM Field | Block JSON Field | |:--------------------:|:----------------------------------------------------------------------------:| | MaxFeePerGas | `extrinsics[extrinsic_number].args.transaction.eip1559.maxFeePerGas` | | MaxPriorityFeePerGas | `extrinsics[extrinsic_number].args.transaction.eip1559.maxPriorityFeePerGas` | === "Legacy" | EVM Field | Block JSON Field | |:---------:|:---------------------------------------------------------------:| | GasPrice | `extrinsics[extrinsic_number].args.transaction.legacy.gasPrice` | === "EIP2930" | EVM Field | Block JSON Field | |:---------:|:----------------------------------------------------------------:| | GasPrice | `extrinsics[extrinsic_number].args.transaction.eip2930.gasPrice` | ### Transaction Weight {: #transaction-weight} `TransactionWeight` is a Substrate mechanism used to measure the execution time a given transaction takes to be executed within a block. A transaction's weight is a vector of two components: `refTime` and `proofSize`. `refTime` refers to the amount of computational time that can be used for execution. `proofSize` refers to the size of the PoV (Proof of Validity) of the Moonbeam block that gets submitted to the Polkadot Relay Chain for validation. Since both `refTime` and `proofSize` are integral components of determining a weight, it is impossible to obtain an accurate weight value with just one of these values. For all transactions types, `TransactionWeight` can be retrieved under the event of the relevant extrinsic where the `method` field is set to: ```text pallet: "system", method: "ExtrinsicSuccess" ``` And then `TransactionWeight` is mapped to the following two fields of the block JSON object. `proofSize` is mapped as follows: ```text extrinsics[extrinsic_number].events[event_number].data[0].weight.proof_size ``` And `refTime` is mapped as follows: ```text extrinsics[extrinsic_number].events[event_number].data[0].weight.ref_time ``` ### Fee History Endpoint {: #eth-feehistory-endpoint } Moonbeam networks implement the [`eth_feeHistory`](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-fee-history){target_blank} JSON-RPC endpoint as a part of the support for EIP-1559. `eth_feeHistory` returns a collection of historical gas information from which you can reference and calculate what to set for the `MaxFeePerGas` and `MaxPriorityFeePerGas` fields when submitting EIP-1559 transactions. The following curl example will return the gas information of the last 10 blocks starting from the latest block on the respective Moonbeam network using `eth_feeHistory`: === "Moonbeam" ```sh curl --location \ --request POST '{{ networks.moonbeam.rpc_url }}' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "id": 1, "method": "eth_feeHistory", "params": ["0xa", "latest"] }' ``` === "Moonriver" ```sh curl --location \ --request POST '{{ networks.moonriver.rpc_url }}' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "id": 1, "method": "eth_feeHistory", "params": ["0xa", "latest"] }' ``` === "Moonbase Alpha" ```sh curl --location \ --request POST '{{ networks.moonbase.rpc_url }}' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "id": 1, "method": "eth_feeHistory", "params": ["0xa", "latest"] }' ``` === "Moonbeam Dev Node" ```sh curl --location \ --request POST '{{ networks.development.rpc_url }}' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "id": 1, "method": "eth_feeHistory", "params": ["0xa", "latest"] }' ``` ### Sample Code for Calculating Transaction Fees {: #sample-code } The following code snippet uses the [Axios HTTP client](https://axios-http.com){target=\_blank} to query the [Sidecar endpoint `/blocks/head`](https://paritytech.github.io/substrate-api-sidecar/dist/#operations-tag-blocks){target=\_blank} for the latest finalized block. It then calculates the transaction fees of all transactions in the block according to the transaction type (for Ethereum API: legacy, EIP-1559 or EIP-2930 standards, and for Substrate API), as well as calculating the total transaction fees in the block. !!! note EIP-1559 transaction fees on Moonbeam are calculated using the previous block's base fee. The following code sample is for demo purposes only and should not be used without modification and further testing in a production environment. You can use the following snippet for any Moonbeam-based network, but you'll need to modify the `baseFee` accordingly. You can refer back to the [Base Fee](#base-fee) section to get the calculation for each network. ```js import axios from 'axios'; // This script calculates the transaction fees of all transactions in a block // according to the transaction type (for Ethereum API: legacy, EIP-1559 or // EIP-2930 standards, and Substrate API) using the dynamic fee mechanism. // It also calculates the total fees in the block // Endpoint to retrieve the latest block const endpointBlock = 'http://127.0.0.1:8080/blocks/head'; // Endpoint to retrieve the latest nextFeeMultiplier const endpointPallet = 'http://127.0.0.1:8080/pallets/transaction-payment/storage/nextFeeMultiplier?at='; // Endpoint to retrieve the node client's information const endpointNodeVersion = 'http://127.0.0.1:8080/node/version'; // Define the minimum base fee for each network const baseFee = { moonbeam: 31250000000n, moonriver: 312500000n, moonbase: 31250000n, }; async function main() { try { // Create a variable to sum the transaction fees in the whole block let totalFees = 0n; // Find which Moonbeam network the Sidecar is pointing to const responseClient = await axios.get(endpointNodeVersion); const network = responseClient.data.clientImplName; // Retrieve the block from the Sidecar endpoint const responseBlock = await axios.get(endpointBlock); // Retrieve the block height of the current block console.log('Block Height: ' + responseBlock.data.number); // Use the previous block's base fee to match the on-chain data // Find the block's nextFeeMultiplier const prevBlock = Number(responseBlock.data.number) - 1; const responsePallet = await axios.get(endpointPallet + prevBlock); // Iterate through all extrinsics in the block responseBlock.data.extrinsics.forEach((extrinsic) => { // Create an object to store transaction information let transactionData = new Object(); // Set the network field transactionData['network'] = network; // Filter for Ethereum Transfers if ( extrinsic.method.pallet === 'ethereum' && extrinsic.method.method === 'transact' ) { // Iterate through the events to get non type specific parameters extrinsic.events.forEach((event) => { if ( event.method.pallet === 'ethereum' && event.method.method === 'Executed' ) { // Get Transaction Hash transactionData['hash'] = event.data[2]; } if ( event.method.pallet === 'system' && event.method.method === 'ExtrinsicSuccess' ) { // Add correction weight if needed to Transaction Weight! transactionData['weight'] = BigInt(event.data[0].weight.refTime); } }); // Get the transaction type and type specific parameters and compute the // transaction fee if (extrinsic.args.transaction.legacy) { transactionData['txType'] = 'legacy'; transactionData['gasPrice'] = BigInt( extrinsic.args.transaction.legacy.gasPrice ); transactionData['txFee'] = (transactionData['gasPrice'] * transactionData['weight']) / 25000n; } else if (extrinsic.args.transaction.eip1559) { transactionData['txType'] = 'eip1599'; transactionData['maxFeePerGas'] = BigInt( extrinsic.args.transaction.eip1559.maxFeePerGas ); transactionData['maxPriorityFeePerGas'] = BigInt( extrinsic.args.transaction.eip1559.maxPriorityFeePerGas ); // Update based on the network you're getting tx fees for transactionData['baseFee'] = (BigInt(responsePallet.data.value) * baseFee.moonbeam) / BigInt('1000000000000000000'); // Gas price dependes on the MaxFeePerGas and MaxPriorityFeePerGas set transactionData['gasPrice'] = transactionData['baseFee'] + transactionData['maxPriorityFeePerGas'] < transactionData['maxFeePerGas'] ? transactionData['baseFee'] + transactionData['maxPriorityFeePerGas'] : transactionData['maxFeePerGas']; transactionData['txFee'] = (transactionData['gasPrice'] * transactionData['weight']) / 25000n; } else if (extrinsic.args.transaction.eip2930) { transactionData['txType'] = 'eip2930'; transactionData['gasPrice'] = BigInt( extrinsic.args.transaction.eip2930.gasPrice ); transactionData['txFee'] = (transactionData['gasPrice'] * transactionData['weight']) / 25000n; } // Increment totalFees totalFees += transactionData['txFee']; // Display the tx information to console console.log(transactionData); } // Filter for Substrate transactions, check if the extrinsic has a // 'TransactionFeePaid' event else { extrinsic.events.forEach((event) => { if ( event.method.pallet === 'transactionPayment' && event.method.method === 'TransactionFeePaid' ) { transactionData['txType'] = 'substrate'; transactionData['txFee'] = event.data[1]; transactionData['tip'] = event.data[1]; } if ( event.method.pallet === 'system' && event.method.method === 'ExtrinsicSuccess' ) { transactionData['weight'] = event.data[0].weight.refTime; } }); } }); // Output the total amount of fees in the block console.log('Total fees in block: ' + totalFees); } catch (err) { console.log(err); } } main(); ``` ## Substrate API Transaction Fees {: #substrate-api-transaction-fees } This section of the guide assumes you are interacting with Moonbeam blocks via [the Substrate API Sidecar](/builders/substrate/libraries/sidecar/){target=\_blank} service. There are other ways of interacting with Moonbeam blocks, such as using [the Polkadot.js API library](/builders/substrate/libraries/polkadot-js-api/){target=\_blank}. The logic is identical once the blocks are retrieved. You can reference the [Substrate API Sidecar page](/builders/substrate/libraries/sidecar/){target=\_blank} for information on installing and running your own Sidecar service instance, as well as more details on how to decode Sidecar blocks for Moonbeam transactions. **Note that the information in this section assumes you are running version {{ networks.moonbase.substrate_api_sidecar.stable_version }} of the Substrate Sidecar REST API.** All the information around fee data for transactions sent via the Substrate API can be extracted from the following block endpoint: ```text GET /blocks/{blockId} ``` The block endpoints will return data relevant to one or more blocks. You can read more about the block endpoints on the [official Sidecar documentation](https://paritytech.github.io/substrate-api-sidecar/dist/#operations-tag-blocks){target=\_blank}. Read as a JSON object, the relevant nesting structure is as follows: ```text RESPONSE JSON Block Object: ... |--number |--extrinsics |--{extrinsic_number} |--method |--signature |--nonce |--args |--tip |--hash |--info |--era |--events |--{event_number} |--method |--pallet: "transactionPayment" |--method: "TransactionFeePaid" |--data |--0 |--1 |--2 ... ``` The object mappings are summarized as follows: | Tx Information | Block JSON Field | |:------------------:|:-----------------------------------------------------------:| | Fee paying account | `extrinsics[extrinsic_number].events[event_number].data[0]` | | Total fees paid | `extrinsics[extrinsic_number].events[event_number].data[1]` | | Tip | `extrinsics[extrinsic_number].events[event_number].data[2]` | The transaction fee related information can be retrieved under the event of the relevant extrinsic where the `method` field is set to: ```text pallet: "transactionPayment", method: "TransactionFeePaid" ``` And then the total transaction fee paid for this extrinsic is mapped to the following field of the block JSON object: ```text extrinsics[extrinsic_number].events[event_number].data[1] ```
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/core-concepts/unified-accounts/ --- BEGIN CONTENT --- --- title: Unified Accounts description: Moonbeam replaced the default Substrate account system with native support for the Ethereum-based H160 accounts and ECDSA keys. Find out more information! categories: Basics --- # Unified Accounts ## Introduction {: #introduction } As Moonbeam is designed to be an Ethereum-compatible parachain on Polkadot, the underlying account system replaces the default Substrate-style accounts and keys with Ethereum-style accounts and keys. As a result, you can interact with your Moonbeam account using [MetaMask](/tokens/connect/metamask/){target=\_blank} and Ethereum tools you may already be familiar with, such as [Remix](/builders/ethereum/dev-env/remix/){target=\_blank} and [Hardhat](/builders/ethereum/dev-env/hardhat/){target=\_blank}. You can also interact with your Moonbeam account using Polkadot.js Apps as it natively supports H160 addresses and ECDSA keys. For more information on this integration, you can check out the [Interacting with Moonbeam Using Polkadot.js Apps](/tokens/connect/polkadotjs/){target=\_blank} guide. ## Substrate EVM Compatible Blockchain {: #substrate-evm-compatible-blockchain } Any parachain in the Polkadot ecosystem can offer a full EVM implementation, which provides the possibility of executing Solidity-based smart contracts with minimal to no changes. Substrate makes this integration possible - just plug the [EVM pallet](https://docs.rs/pallet-evm/2.0.1/pallet_evm){target=\_blank} into your runtime for EVM support, and the [Ethereum Pallet with Frontier](https://github.com/polkadot-evm/frontier){target=\_blank} to have Ethereum RPC compatibility. The availability of these open-source modules that Moonbeam has developed with Parity has led multiple parachains to offer Ethereum compatibility on their chains. But there is an important catch. With the configuration described above, a user, for example, Alice, can have an Ethereum-style address (H160 format), which is 40+2 hex-characters long, in a Substrate based chain. This address matches a private key, which can be used to sign transactions in the Ethereum side of the chain. Furthermore, the address is mapped into a storage slot inside the Substrate Balance pallet to a Substrate-style address (H256 format). However, Alice only knows the private key of the H160 address, and not of the mapped version. Therefore, she is unable to send transactions with her H256 address and is limited only to do read-only operations through Substrate’s API. As a consequence, Alice needs another H256 address matching a different private key to be able to operate in the Substrate side of the chain, which include, among others, staking, balances, and governance. The following diagram illustrates this configuration. ![Old account system diagram](/images/learn/core-concepts/unified-accounts/unified-accounts-1.webp) This can creates friction and a poor user experience for Alice. First, she has to move tokens to her H160 mapped H256 address to be able to make transactions and deploy contracts through the EVM. Second, she also needs to hold a balance in her other H256 address (which she has a different private key for) to use Substrate-based features. So in short, Alice needs a minimum of two private keys to have the best of both worlds. ## Moonbeam Unified Accounts {: #moonbeam-unified-accounts } Moonbeam’s focus is to create a fully Ethereum-compatible environment on Polkadot with the best user experience possible. This extends beyond the base Ethereum feature set, with additional features such as on-chain governance, staking, and cross-chain integrations. With unified accounts, a user, for example, Bob, will only need a single H160 address, with its corresponding private key, to do everything we mentioned above, including both EVM and Substrate functions. The diagram for this new configuration looks as follows. ![New account system diagram](/images/learn/core-concepts/unified-accounts/unified-accounts-2.webp) That is it, Bob only holds one private key that matches one address. He does not need to move balances between 2 different accounts and is able to access all the features with a single account and private key. We have standardized this single account to conform to the Ethereum-style H160 address and ECDSA key standards. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/consensus/ --- BEGIN CONTENT --- --- title: Moonbeam's Nimbus Consensus Framework description: Learn about all the parts of Moonbeam's Nimbus consensus framework and how it works as part of Polkadot's shared security model. categories: Basics --- # Nimbus Parachain Consensus Framework ## Introduction {: #introduction } Polkadot relies on a [hybrid consensus model](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/). In such a scheme, the block finality gadget and the block production mechanism are separate. Consequently, parachains only have to worry about producing blocks and rely on the relay chain to validate the state transitions. At a parachain level, block producers are called [collators](https://wiki.polkadot.com/learn/learn-collator/). They maintain parachains (such as Moonbeam) by collecting transactions from users and offering blocks to the relay chain [validators](https://wiki.polkadot.com/learn/learn-validator/). However, parachains might find the following problems they need to solve in a trustless and decentralized matter (if applicable): - Amongst all of the nodes in the network, which ones are allowed to author blocks? - If multiple nodes are allowed, will they be eligible at the same time? Only one? Maybe a few? Enter Nimbus. Nimbus is a framework for building slot-based consensus algorithms on [Cumulus](https://github.com/paritytech/polkadot-sdk/tree/master/cumulus)-based parachains. It strives to provide standard implementations for the logistical parts of such consensus engines and helpful traits for implementing the elements (filters) that researchers and developers want to customize. These filters can be customizable to define what a block authorship slot is and can be composed, so block authorship is restricted to a subset of collators in multiple steps. For example, Moonbeam uses a two-layer approach. The first layer comprises the parachain staking filter, which helps select an active collator pool among all collator candidates using a staked-based ranking. The second layer adds another filter which narrows down the number of collators to a subset for each slot. Notice that Nimbus can only answer which collator(s) are eligible to produce a parachain block in the next available slot. It is the [Cumulus](https://docs.polkadot.com/develop/parachains/#cumulus) consensus mechanism that marks this parachain block as best, and ultimately the [BABE](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/#babe) and [GRANDPA](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/#grandpa-finality-gadget) hybrid consensus model (of the relay chain) that will include this parachain block in the relay chain and finalize it. Once any relay chain forks are resolved at a relay chain level, that parachain block is deterministically finalized. The following two sections go over the filtering strategy currently used on Moonbeam. ## Parachain Staking Filtering {: #parachain-staking-filtering } Collators can join the candidate pool by simply bonding some tokens via an extrinsic. Once in the pool, token holders can add to the candidate's stake via delegation (also referred to as staking), that is, at a parachain level. Parachain staking is the first of the two Nimbus filters applied to the candidate pool. It selects the top {{ networks.moonbase.staking.max_candidates }} candidates in terms of tokens staked in the network, which includes the candidate's bond and delegations from token holders. This filtered pool is called selected candidates, and selected candidates are renewed every round (which lasts {{ networks.moonbase.staking.round_blocks }} blocks). For a given round, the following diagram describes the parachain staking filtering: ![Nimbus Parachain Staking Filter](/images/learn/features/consensus/consensus-1.webp) From this pool, another filter is applied to retrieve a subset of eligible candidates for the next block authoring slot. If you want to learn more about staking, visit our [staking documentation](/learn/features/staking/). ## Fixed Size Subset Filtering {: #fixed-size-subset-filtering } Once the parachain staking filter is applied and the selected candidates are retrieved, a second filter is applied on a block by block basis and helps narrow down the selected candidates to a smaller number of eligible collators for the next block authoring slot. In broad terms, this second filter picks a pseudo-random subset of the previously selected candidates. The eligibility ratio, a tunable parameter, defines the size of this subset. A high eligibility ratio results in fewer chances for the network to skip a block production slot, as more collators will be eligible to propose a block for a specific slot. However, only a certain number of validators are assigned to a parachain, meaning that most of these blocks will not be backed by a validator. For those that are, a higher number of backed blocks means that it might take longer for the relay chain to solve any possible forks and return a finalized block. Moreover, this might create an unfair advantage for certain collators that might be able to get their proposed block faster to relay chain validators, securing a higher portion of block rewards (if any). A lower eligibility ratio might provide faster block finalization times and a fairer block production distribution amongst collators. However, if the eligible collators are not able to propose a block (for whatever reason), the network will skip a block, affecting its stability. Once the size of the subset is defined, collators are randomly selected using a source of entropy. Currently, an internal coin-flipping algorithm is implemented, but this will later be migrated to use [Verifiable random function](https://docs.polkadot.com/polkadot-protocol/parachain-basics/randomness/){target=\_blank}. Consequently, a new subset of eligible collators is selected for every relay chain block. For a given round and a given block `XYZ`, the following diagram describes the fixed-size subset filtering: ![Nimbus Parachain Staking Filter](/images/learn/features/consensus/consensus-2.webp) ## Why Nimbus? {: #why-nimbus } You might ask yourself: but why Nimbus? Initially, it was not envisioned when Moonbeam was being developed. As Moonbeam progressed, the necessity for a more customizable but straightforward parachain consensus mechanism became clear, as the available methods presented some drawbacks or technical limitations. With Nimbus, writing a parachain consensus engine is as easy as writing a pallet! This simplicity and flexibility is the main value it adds. Some technical benefits of Nimbus are considered in the following sections. ### Weight and Extra Execution {: #weight-and-extra-execution } Nimbus puts the author-checking execution in a [Substrate pallet](https://docs.polkadot.com/develop/parachains/customize-parachain/overview/). At first glance, you might think this adds a higher execution load to a single block compared to doing this check off-chain. But consider this from a validator’s perspective The validators will also have to check the author. By putting the author-checking execution logic in a pallet, the execution time can be benchmarked and quantified with weights. If this execution time is not accounted for, there is the risk of a block exceeding the relay chain Wasm execution limit (currently 0.5 seconds). In practice, this check will be fast and will most likely not push execution time over the limit. But from a theoretical perspective, accounting for its weight is better for implementation purposes. ### Reusability {: #reusability } Another benefit of moving the author-checking execution to a pallet, rather than a custom executor, is that one single executor can be reused for any consensus that can be expressed in the Nimbus framework. That is slot-based, signature-sealed algorithms. For example, the [relay-chain provided consensus](https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/client/consensus/relay-chain/src/lib.rs), [AuRa](https://crates.io/crates/sc-consensus-aura) and [BABE](https://crates.io/crates/sc-consensus-babe) each have their own custom executor. With Nimbus, these consensus mechanisms can reuse the same executor. The power of reusability is evidenced by the Nimbus implementation of AuRa in less than 100 lines of code. ### Hot-Swapping Consensus {: #hot-swapping-consensus } Teams building parachains may want to change, tune, or adjust their consensus algorithm from time to time. Without nimbus, swapping consensus would require a client upgrade and hard fork. With the Nimbus framework, writing a consensus engine is as easy as writing a [Substrate pallet](https://docs.polkadot.com/develop/parachains/customize-parachain/make-custom-pallet/). Consequently, swapping consensus is as easy as upgrading a pallet. Nonetheless, hot swapping is still bounded by consensus engines (filters) that fit within Nimbus, but it might be helpful for teams that are yet confident on what consensus they want to implement in the long run. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/eth-compatibility/ --- BEGIN CONTENT --- --- title: Ethereum Compatibility description: Transitioning from Ethereum to Moonbeam? Here's a brief overview of the key components and key differences of Moonbeam's Ethereum compatibility. categories: Basics --- # Ethereum Compatibility Moonbeam bridges the Ethereum and Polkadot ecosystems, offering developers the familiarity of Ethereum's tooling and infrastructure while leveraging Polkadot's scalability and interoperability. This documentation overviews Moonbeam's Ethereum compatibility features and highlights its key components. It also covers some critical differences between Moonbeam and Ethereum so Ethereum developers know what to expect. ## Key Components {: #key-components } ### EVM Compatibility {: #evm } Moonbeam incorporates a fully compatible EVM to execute smart contracts in Solidity or other EVM-compatible languages. This enables developers to deploy existing Ethereum smart contracts on Moonbeam with minimal modifications. Learn more: - [Moonbeam's Ethereum-compatibility architecture](/learn/platform/technology/#ethereum-compatibility-architecture){target=\_blank} ### Ethereum-style Accounts {: #ethereum-style-accounts } Moonbeam employs H160 Ethereum-style accounts and ECDSA keys, ensuring compatibility with existing Ethereum wallets and facilitating a smooth end-user experience. This is possible due to Moonbeam's unified accounts system, which modifies the underlying Substrate account system to use Ethereum accounts by default. Learn more: - [Moonbeam's unified accounts system](/learn/core-concepts/unified-accounts/){target=\_blank} ### JSON-RPC Support {: #json-rpc-support } Moonbeam offers full JSON-RPC compatibility with Ethereum, allowing developers to interact with Moonbeam nodes using familiar Ethereum tools and libraries. This compatibility extends to methods for account management, transaction submission, smart contract deployment, and event monitoring. In addition to standard Ethereum RPC methods, Moonbeam supports non-standard Debug and Trace modules, providing developers with enhanced debugging and tracing capabilities for smart contract execution. The Debug module allows developers to inspect internal state transitions and execution traces, enabling efficient debugging of complex smart contracts. The Trace module provides detailed transaction traces, including opcode-level execution information and gas consumption, facilitating performance analysis and optimization. Learn more: - [Supported Ethereum RPC methods](/builders/ethereum/json-rpc/eth-rpc/){target=\_blank} - [Subscribe to events with Ethereum JSON-RPC methods](/builders/ethereum/json-rpc/pubsub/){target=\_blank} - [Debug and trace transactions with non-standard RPC methods](/builders/ethereum/json-rpc/debug-trace/){target=\_blank} ### Ethereum Developer Tools and Libraries {: #ethereum-dev-tools } With the underlying support for Ethereum JSON-RPC methods, Moonbeam leverages Ethereum's rich ecosystem of developer libraries and environments. With seamless integration of popular Ethereum libraries and development environments, developers can leverage their existing knowledge and tooling to build and deploy decentralized applications (DApps) on Moonbeam. Learn more: - [Ethereum libraries](/builders/ethereum/libraries/){target=\_blank} - [Ethereum development environments](/builders/ethereum/libraries/){target=\_blank} ### Precompiled Contracts {: #precompiled-contracts } Moonbeam provides precompiled contracts that allow Ethereum smart contracts to seamlessly access Substrate functionality. These precompiled contracts expose Substrate features such as on-chain governance, staking, and identity management to Ethereum-based DApps on Moonbeam. This integration ensures that Ethereum developers can harness the full potential of Moonbeam's features, expanding the possibilities for dApp development on Moonbeam. In addition, developers can leverage Ethereum MainNet precompiles seamlessly within their smart contracts on Moonbeam. These precompiled contracts, widely used on the Ethereum network, offer optimized and efficient execution of common cryptographic operations and complex computations. By supporting Ethereum MainNet precompiles, Moonbeam ensures compatibility with Ethereum-based dApps while enabling developers to utilize familiar tools and libraries to build on its platform. Learn more: - [Overview of the precompiled contracts on Moonbeam](/builders/ethereum/precompiles/overview/){target=\_blank} ### Ethereum Token Standards {: #ethereum-token-standards } Moonbeam supports Ethereum token standards, allowing developers to deploy and interact with tokens that adhere to popular standards such as ERC-20, ERC-721, and ERC-1155. By supporting these standards, Moonbeam enables developers to deploy existing Ethereum tokens without modification. Due to Moonbeam's native interoperability, ERC-20s can be sent cross-chain to other chains within the Polkadot ecosystem via Cross-Consensus Messaging (XCM). Learn more: - [Create common OpenZeppelin contracts such as ERC-20, ERC-721, and ERC-1155 tokens](/builders/ethereum/dev-env/openzeppelin/contracts/){target=\_blank} - [XCM-enabled ERC-20s](/builders/interoperability/xcm/xc20/overview/#local-xc20s){target=\_blank} (also referred to as local XC-20s) ## Key Differences {: #key-differences } ### Consensus Mechanisms {: #consensus-mechanisms } Moonbeam uses a Delegated Proof-of-Stake (DPoS) consensus mechanism, where token holders in the network can delegate candidates to become block producers, known as _collators_. On the other hand, Ethereum uses a Proof-of-Stake (PoS) system in which validators are selected based on their stake in the network to produce and validate blocks. Learn more: - [Differences between PoS and DPoS](/learn/core-concepts/consensus-finality/#main-differences){target=_blank} ### Finality {: #finality } Moonbeam and Ethereum have different finality processes. On Ethereum, there is a checkpoint system where validators determine finality at checkpoint blocks, which takes at least 6.4 minutes for a block to be finalized. Moonbeam relies on Polkadot's [GRANDPA](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/#finality-gadget-grandpa){target=\_blank} finality gadget, which expedites finality by completing the process parallel to block production and allowing relay chain validators to vote on the highest block, finalizing all blocks leading up to that block. Learn more: - [Consensus and finality on Moonbeam](/learn/core-concepts/consensus-finality/){target=_blank} ### Proxy Accounts {: #proxy-accounts } On both Moonbeam and Ethereum, accounts can be controlled by two main types of accounts: Externally Owned Accounts (EOA) or smart contracts. However, on Moonbeam, within both account types, there are also proxy accounts, which can perform a limited number of actions on behalf of another account. Learn more: - [An overview of proxy accounts](https://wiki.polkadot.com/learn/learn-proxies/){target=\_blank} - [How to set up a proxy account](/tokens/manage/proxy-accounts/){target=\_blank} ### Account Balances {: #account-balances } Balances on Ethereum are fairly straightforward; if an account holds tokens, that account has a token balance. On Moonbeam, different balance types exist to support various Substrate functionality. There are five types: free, reducible, reserved, miscellaneous frozen, and fee frozen. When using Ethereum tools, accounts show the reducible balance and don't include locked or frozen balances. Learn more: - [Moonbeam account balances](/learn/core-concepts/balances/){target=_blank} ### Balance Transfers {: #balance-transfers } Since Moonbeam is a Substrate-based chain, balance transfers of the native asset (GLMR, MOVR, and DEV) can occur through the Ethereum and Substrate APIs. Like Ethereum, transfers sent through the Ethereum API rely on the `eth_sendRawTransaction`. Transfers sent through the Substrate API are done using the Balances Pallet, a built-in module in the Substrate framework that provides functionality for managing accounts and balances. Learn more: - [Balance transfers on Moonbeam](/learn/core-concepts/transfers-api/){target=_blank} ### Transaction Fees {: #transaction-fees } Moonbeam and Ethereum calculate transaction fees differently due to variations in their underlying architectures and consensus mechanisms. The fundamental difference in how transaction fees are calculated is that Ethereum uses a gas-based fee system, and Moonbeam uses a weight-based system that maps to the gas used. Moonbeam also implements additional metrics in the underlying gas calculations, including proof size and storage costs. Learn more: - [Calculating transaction fees on Moonbeam](/learn/core-concepts/tx-fees/){target=\_blank} --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/governance/ --- BEGIN CONTENT --- --- title: Governance description: As a Polkadot parachain, Moonbeam uses an on-chain governance system, allowing for a stake-weighted vote on public referenda. categories: Governance, Basics --- # Governance on Moonbeam ## Introduction {: #introduction } The goal of Moonbeam’s governance mechanism is to advance the protocol according to the desires of the community. In that shared mission, the governance process seeks to include all token holders. Any and all changes to the protocol must go through a referendum so that all token holders, weighted by stake, can have input on the decision. Governance forums like the [Moonbeam Community Forum](https://forum.moonbeam.network){target=\_blank} and [Polkassembly](https://moonbeam.polkassembly.io/opengov){target=\_blank} enable open discussion and allow proposals to be refined based on community input. Autonomous enactments and [forkless upgrades](https://docs.polkadot.com/develop/parachains/maintenance/runtime-upgrades/#forkless-upgrades){target=\_blank} unite the community towards a shared mission to advance the protocol. With the rollout of OpenGov (originally referred to as Gov2), the second phase of governance in Polkadot, several modifications have been introduced to the governance process. You can read the [OpenGov: What is Polkadot Gov2](https://moonbeam.network/news/opengov-what-is-polkadot-gov2){target=\_blank} blog post, which provides an overview of all of the changes made in OpenGov. As of runtime 2400, all Moonbeam networks use OpenGov as their governance system. ## Principles {: #principles } Guiding "soft" principles for engagement with Moonbeam's governance process include: - Being inclusive to token holders that want to engage with Moonbeam and that are affected by governance decisions - Favoring token holder engagement, even with views contrary to our own, versus a lack of engagement - A commitment to openness and transparency in the decision-making process - Working to keep the greater good of the network above personal gain - Acting at all times as a moral agent that considers the consequences of action (or inaction) from a moral standpoint - Being patient and generous in our interactions with other token holders, but not tolerating abusive or destructive language, actions, and behavior, and abiding by [Moonbeam’s Code of Conduct](https://github.com/moonbeam-foundation/code-of-conduct){target=\_blank} These points were heavily inspired by Vlad Zamfir’s writings on governance. Refer to his articles, especially the [How to Participate in Blockchain Governance in Good Faith (and with Good Manners)](https://medium.com/@Vlad_Zamfir/how-to-participate-in-blockchain-governance-in-good-faith-and-with-good-manners-bd4e16846434){target=\_blank} Medium article. ## On-Chain Governance Mechanics {: #on-chain-governance-mechanics } The "hard" governance process for Moonbeam will be driven by an on-chain process that allows the majority of tokens on the network to determine the outcomes of key decisions around the network. These decision points come in the form of stake-weighted voting on proposed referenda. Some of the main components of this governance model include: - **Referenda** — a stake-based voting scheme where each referendum is tied to a specific proposal for a change to the Moonbeam system including values for key parameters, code upgrades, or changes to the governance system itself - **Voting** — referenda will be voted on by token holders on a stake-weighted basis. Referenda which pass are subject to delayed enactment so that people who disagree with the direction of the decision have time to exit the network - **Council & Technical Committee Governance V1** — a group of community members who have special voting rights within the system. With the deprecation and removal of Governance v1, both of these committees were dissolved as of the [runtime 2800 release](https://forum.moonbeam.network/t/runtime-rt2801-schedule/1616/4){target=\_blank} - **OpenGov Technical Committee** — a group of community members who can add certain proposals to the Whitelisted Track For more details on how these Substrate frame pallets implement on-chain governance, you can checkout the [Walkthrough of Polkadot’s Governance](https://polkadot.com/blog/a-walkthrough-of-polkadots-governance){target=\_blank} blog post and the [Polkadot Governance Wiki](https://wiki.polkadot.com/learn/learn-polkadot-opengov/){target=\_blank}. ## Governance v2: OpenGov {: #opengov } This section will cover everything you need to know about OpenGov on Moonbeam. ### General Definitions {: #general-definitions-gov2 } - **Proposal** — an action or item, defined by the preimage hash, being proposed by a token holder and open for consideration and discussion by token holders - **Referendum** — a proposal that is up for token-holder voting. Each referendum is tied to a specific proposal for a change to the Moonbeam system including values for key parameters, code upgrades, or changes to the governance system itself - **Preimage hash** — hash of the proposal to be enacted. The first step to make a proposal is to submit a preimage. The hash is just its identifier. The proposer of the preimage can be different than the user that proposes that preimage as a formal proposal - **Preimage deposit** — amount of tokens that the proposer needs to bond when submitting a preimage. It is calculated as the sum of a base deposit per network plus a fee per byte of the preimage being proposed - **Origin** - an authorization-based dispatch source for an operation, which is used to determine the Track that a referendum is posted under - **Track** - an Origin-specific pipeline that outlines the life cycle of proposals. Currently, there are five Tracks: | Origin Track | Description | Referendum Examples | |:-------------------:|:--------------------------------------------------------------------------------:|:--------------------------------------------------------------------:| | Root | Highest privilege | Runtime upgrades, Technical Committee management | | Whitelisted | Proposals to be whitelisted by the Technical Committee before being dispatched | Fast-tracked operations | | General Admin | For general on-chain decisions | Changes to XCM fees, Orbiter program, Staking parameters, Registrars | | Emergency Canceller | For cancellation of a referendum. Decision Deposit is refunded | Wrongly constructed referendum | | Emergency Killer | For killing of bad/malicious referendum. Decision Deposit is slashed | Malicious referendum | | Fast General Admin | For faster general on-chain decisions | HRMP channel management | Tracks have different criteria parameters that are proportional to their level of Origin class. For example, more dangerous and privileged referenda will have more safeguards, higher thresholds, and longer consideration periods for approval. Please refer to the [Governance Parameters](#governance-parameters-v2) section for more information. - **Voting** — a mechanism for token holders to support (Aye), oppose (Nay), or remain neutral (Abstain) on a proposal. For Aye and Nay, the voting weight is determined by both the number of tokens locked and the lock duration (Conviction). Abstain votes do not receive additional weighting - **Conviction** — the time that token holders voluntarily lock their tokens when voting; the longer they are locked, the more weight their vote has - **Lock balance** — the number of tokens that a user commits to a vote (note, this is not the same as a user's total account balance) Moonbeam uses the concept of voluntary locking, which allows token holders to increase their voting power by locking tokens for a longer period of time. Specifying no Lock Period means a user's vote is valued at 10% of their lock balance. Specifying a greater Conviction increases voting power. For each increase in Conviction (vote multiplier), the Lock Periods double - **Approval** — minimum "Aye" votes as a percentage of overall Conviction-weighted votes needed for approval - **Support** — the minimum portion of Aye and Abstain votes (ignoring conviction) needed as a percentage of the total active supply for a proposal to pass. Nay votes do not count toward Support - **Lead-in Period** — the initial proposal voting and discussion period. At this stage, proposals are in an undecided state until they pass some criteria for the given Track. The criteria include: - **Prepare Period** — the minimum time the referendum needs to wait before it can progress to the next phase after submission - **Capacity** — limit for the number of referenda on a given Track that can be decided at once - **Decision Deposit** — the minimum deposit amount required for a referendum to progress to the decision phase after the end of the Lead-in Period. Since each Track has a defined Capacity, this deposit is larger than the submission deposit, and its goal is to mitigate spam - **Decide Period** - token holders continue to vote on the referendum. If a referendum does not pass by the end of the period, it will be rejected, and the Decision Deposit will be refunded - **Confirm Period** - a period of time within the Decide Period where the referendum needs to have maintained enough Approval and Support to be approved and move to the Enactment Period - **Enactment Period** - a specified time, which is defined at the time the proposal was created, that an approved referendum waits before it can be dispatched. There is a minimum amount of time for each Track - **Vote Delegation** — a voter can give their voting power, including Conviction voting, to another token holder (delegate), who may be more knowledgeable and able to make specific decisions - **Multirole Delegation** — the ability to delegate voting power on a Track-by-Track basis, where a token holder can specify different delegates for each Track ### Governance Parameters {: #governance-parameters-v2 } === "Moonbeam" | Variable | Value | |:---------------------------:|:----------------------------------------------------------:| | Preimage base deposit | {{ networks.moonbeam.preimage.base_deposit }} GLMR | | Preimage deposit per byte | {{ networks.moonbeam.preimage.byte_deposit }} GLMR | | Proposal Submission Deposit | {{ networks.moonbeam.governance.submission_deposit }} GLMR | === "Moonriver" | Variable | Value | |:---------------------------:|:-----------------------------------------------------------:| | Preimage base deposit | {{ networks.moonriver.preimage.base_deposit }} MOVR | | Preimage deposit per byte | {{ networks.moonriver.preimage.byte_deposit }} MOVR | | Proposal Submission Deposit | {{ networks.moonriver.governance.submission_deposit }} MOVR | === "Moonbase Alpha" | Variable | Value | |:---------------------------:|:---------------------------------------------------------:| | Preimage base deposit | {{ networks.moonbase.preimage.base_deposit }} DEV | | Preimage deposit per byte | {{ networks.moonbase.preimage.byte_deposit }} DEV | | Proposal Submission Deposit | {{ networks.moonbase.governance.submission_deposit }} DEV | #### General Parameters by Track {: #general-parameters-by-track } === "Moonbeam" | Track | Track ID | Capacity | Decision
Deposit | |:----------------------:|:--------:|:-----------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------:| | Root | 0 | {{ networks.moonbeam.governance.tracks.root.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.root.decision_deposit }} GLMR | | Whitelisted | 1 | {{ networks.moonbeam.governance.tracks.whitelisted.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.whitelisted.decision_deposit }} GLMR | | General Admin | 2 | {{ networks.moonbeam.governance.tracks.general_admin.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.general_admin.decision_deposit }} GLMR | | Emergency
Canceller | 3 | {{ networks.moonbeam.governance.tracks.canceller.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.canceller.decision_deposit }} GLMR | | Emergency
Killer | 4 | {{ networks.moonbeam.governance.tracks.killer.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.killer.decision_deposit }} GLMR | | Fast General Admin | 5 | {{ networks.moonbeam.governance.tracks.fast_general_admin.max_deciding }} proposals | {{ networks.moonbeam.governance.tracks.fast_general_admin.decision_deposit }} GLMR | === "Moonriver" | Track | Track ID | Capacity | Decision
Deposit | |:----------------------:|:--------:|:------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------:| | Root | 0 | {{ networks.moonriver.governance.tracks.root.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.root.decision_deposit }} MOVR | | Whitelisted | 1 | {{ networks.moonriver.governance.tracks.whitelisted.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.whitelisted.decision_deposit }} MOVR | | General Admin | 2 | {{ networks.moonriver.governance.tracks.general_admin.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.general_admin.decision_deposit }} MOVR | | Emergency
Canceller | 3 | {{ networks.moonriver.governance.tracks.canceller.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.canceller.decision_deposit }} MOVR | | Emergency
Killer | 4 | {{ networks.moonriver.governance.tracks.killer.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.killer.decision_deposit }} MOVR | | Fast General Admin | 5 | {{ networks.moonriver.governance.tracks.fast_general_admin.max_deciding }} proposals | {{ networks.moonriver.governance.tracks.fast_general_admin.decision_deposit }} MOVR | === "Moonbase Alpha" | Track | Track ID | Capacity | Decision
Deposit | |:----------------------:|:--------:|:-----------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------:| | Root | 0 | {{ networks.moonbase.governance.tracks.root.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.root.decision_deposit }} DEV | | Whitelisted | 1 | {{ networks.moonbase.governance.tracks.whitelisted.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.whitelisted.decision_deposit }} DEV | | General Admin | 2 | {{ networks.moonbase.governance.tracks.general_admin.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.general_admin.decision_deposit }} DEV | | Emergency
Canceller | 3 | {{ networks.moonbase.governance.tracks.canceller.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.canceller.decision_deposit }} DEV | | Emergency
Killer | 4 | {{ networks.moonbase.governance.tracks.killer.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.killer.decision_deposit }} DEV | | Fast General Admin | 5 | {{ networks.moonbase.governance.tracks.fast_general_admin.max_deciding }} proposals | {{ networks.moonbase.governance.tracks.fast_general_admin.decision_deposit }} DEV | #### Period Parameters by Track {: #period-parameters-by-track } === "Moonbeam" | Track | Prepare
Period | Decide
Period | Confirm
Period | Minimum
Enactment Period | |:----------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | {{ networks.moonbeam.governance.tracks.root.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.root.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.root.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.root.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.root.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.root.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.root.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.root.min_enactment_period.time }}) | | Whitelisted | {{ networks.moonbeam.governance.tracks.whitelisted.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.whitelisted.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.whitelisted.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.whitelisted.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.whitelisted.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.whitelisted.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.whitelisted.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.whitelisted.min_enactment_period.time }}) | | General Admin | {{ networks.moonbeam.governance.tracks.general_admin.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.general_admin.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.general_admin.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.general_admin.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.general_admin.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.general_admin.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.general_admin.min_enactment_period.time }}) | | Emergency
Canceller | {{ networks.moonbeam.governance.tracks.canceller.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.canceller.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.canceller.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.canceller.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.canceller.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.canceller.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.canceller.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.canceller.min_enactment_period.time }}) | | Emergency
Killer | {{ networks.moonbeam.governance.tracks.killer.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.killer.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.killer.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.killer.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.killer.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.killer.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.killer.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.killer.min_enactment_period.time }}) | | Fast General Admin | {{ networks.moonbeam.governance.tracks.fast_general_admin.prepare_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.fast_general_admin.prepare_period.time }}) | {{ networks.moonbeam.governance.tracks.fast_general_admin.decision_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.fast_general_admin.decision_period.time }}) | {{ networks.moonbeam.governance.tracks.fast_general_admin.confirm_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.fast_general_admin.confirm_period.time }}) | {{ networks.moonbeam.governance.tracks.fast_general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonbeam.governance.tracks.fast_general_admin.min_enactment_period.time }}) | === "Moonriver" | Track | Prepare
Period | Decide
Period | Confirm
Period | Minimum
Enactment Period | |:----------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | {{ networks.moonriver.governance.tracks.root.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.root.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.root.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.root.decision_period.time }}) | {{ networks.moonriver.governance.tracks.root.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.root.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.root.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.root.min_enactment_period.time }}) | | Whitelisted | {{ networks.moonriver.governance.tracks.whitelisted.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.whitelisted.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.whitelisted.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.whitelisted.decision_period.time }}) | {{ networks.moonriver.governance.tracks.whitelisted.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.whitelisted.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.whitelisted.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.whitelisted.min_enactment_period.time }}) | | General Admin | {{ networks.moonriver.governance.tracks.general_admin.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.general_admin.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.general_admin.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.general_admin.decision_period.time }}) | {{ networks.moonriver.governance.tracks.general_admin.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.general_admin.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.general_admin.min_enactment_period.time }}) | | Emergency
Canceller | {{ networks.moonriver.governance.tracks.canceller.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.canceller.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.canceller.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.canceller.decision_period.time }}) | {{ networks.moonriver.governance.tracks.canceller.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.canceller.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.canceller.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.canceller.min_enactment_period.time }}) | | Emergency
Killer | {{ networks.moonriver.governance.tracks.killer.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.killer.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.killer.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.killer.decision_period.time }}) | {{ networks.moonriver.governance.tracks.killer.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.killer.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.killer.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.killer.min_enactment_period.time }}) | | Fast General Admin | {{ networks.moonriver.governance.tracks.fast_general_admin.prepare_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.fast_general_admin.prepare_period.time }}) | {{ networks.moonriver.governance.tracks.fast_general_admin.decision_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.fast_general_admin.decision_period.time }}) | {{ networks.moonriver.governance.tracks.fast_general_admin.confirm_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.fast_general_admin.confirm_period.time }}) | {{ networks.moonriver.governance.tracks.fast_general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonriver.governance.tracks.fast_general_admin.min_enactment_period.time }}) | === "Moonbase Alpha" | Track | Prepare
Period | Decide
Period | Confirm
Period | Minimum
Enactment Period | |:----------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | {{ networks.moonbase.governance.tracks.root.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.root.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.root.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.root.decision_period.time }}) | {{ networks.moonbase.governance.tracks.root.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.root.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.root.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.root.min_enactment_period.time }}) | | Whitelisted | {{ networks.moonbase.governance.tracks.whitelisted.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.whitelisted.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.whitelisted.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.whitelisted.decision_period.time }}) | {{ networks.moonbase.governance.tracks.whitelisted.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.whitelisted.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.whitelisted.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.whitelisted.min_enactment_period.time }}) | | General Admin | {{ networks.moonbase.governance.tracks.general_admin.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.general_admin.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.general_admin.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.general_admin.decision_period.time }}) | {{ networks.moonbase.governance.tracks.general_admin.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.general_admin.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.general_admin.min_enactment_period.time }}) | | Emergency
Canceller | {{ networks.moonbase.governance.tracks.canceller.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.canceller.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.canceller.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.canceller.decision_period.time }}) | {{ networks.moonbase.governance.tracks.canceller.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.canceller.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.canceller.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.canceller.min_enactment_period.time }}) | | Emergency
Killer | {{ networks.moonbase.governance.tracks.killer.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.killer.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.killer.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.killer.decision_period.time }}) | {{ networks.moonbase.governance.tracks.killer.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.killer.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.killer.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.killer.min_enactment_period.time }}) | | Fast General Admin | {{ networks.moonbase.governance.tracks.fast_general_admin.prepare_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.fast_general_admin.prepare_period.time }}) | {{ networks.moonbase.governance.tracks.fast_general_admin.decision_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.fast_general_admin.decision_period.time }}) | {{ networks.moonbase.governance.tracks.fast_general_admin.confirm_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.fast_general_admin.confirm_period.time }}) | {{ networks.moonbase.governance.tracks.fast_general_admin.min_enactment_period.blocks }} blocks
({{ networks.moonbase.governance.tracks.fast_general_admin.min_enactment_period.time }}) | !!! note As of runtime 3000, [asynchronous backing](https://wiki.polkadot.com/learn/learn-async-backing/#asynchronous-backing){target=\_blank} has been enabled on all Moonbeam networks. As a result, the target block time was reduced from 12 seconds to 6 seconds, which may break some timing-based assumptions. #### Support and Approval Parameters by Track {: #support-and-approval-parameters-by-track } === "Moonbeam" | Track | Approval Curve | Approval Parameters | Support Curve | Support Parameters | |:----------------------:|:--------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | Reciprocal | {{ networks.moonbeam.governance.tracks.root.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.root.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.root.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.root.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.root.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.root.min_approval.percent2 }}% | Linear | {{ networks.moonbeam.governance.tracks.root.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.root.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.root.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.root.min_support.percent1 }}% | | Whitelisted | Reciprocal | {{ networks.moonbeam.governance.tracks.whitelisted.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.whitelisted.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.whitelisted.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbeam.governance.tracks.whitelisted.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.whitelisted.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_support.percent1 }}%
{{ networks.moonbeam.governance.tracks.whitelisted.min_support.time2 }}: {{ networks.moonbeam.governance.tracks.whitelisted.min_support.percent2 }}% | | General Admin | Reciprocal | {{ networks.moonbeam.governance.tracks.general_admin.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.general_admin.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.general_admin.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbeam.governance.tracks.general_admin.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.general_admin.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_support.percent1 }}%
{{ networks.moonbeam.governance.tracks.general_admin.min_support.time2 }}: {{ networks.moonbeam.governance.tracks.general_admin.min_support.percent2 }}% | | Emergency
Canceller | Reciprocal | {{ networks.moonbeam.governance.tracks.canceller.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.canceller.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.canceller.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.canceller.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.canceller.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.canceller.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbeam.governance.tracks.canceller.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.canceller.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.canceller.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.canceller.min_support.percent1 }}%
{{ networks.moonbeam.governance.tracks.canceller.min_support.time2 }}: {{ networks.moonbeam.governance.tracks.canceller.min_support.percent2 }}% | | Emergency
Killer | Reciprocal | {{ networks.moonbeam.governance.tracks.killer.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.killer.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.killer.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.killer.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.killer.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.killer.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbeam.governance.tracks.killer.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.killer.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.killer.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.killer.min_support.percent1 }}%
{{ networks.moonbeam.governance.tracks.killer.min_support.time2 }}: {{ networks.moonbeam.governance.tracks.killer.min_support.percent2 }}% | | Fast General Admin | Reciprocal | {{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.time0 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.percent0 }}%
{{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.time1 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.percent1 }}%
{{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.time2 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.time0 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.percent0 }}%
{{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.time1 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.percent1 }}%
{{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.time2 }}: {{ networks.moonbeam.governance.tracks.fast_general_admin.min_support.percent2 }}% | === "Moonriver" | Track | Approval Curve | Approval Parameters | Support Curve | Support Parameters | |:----------------------:|:--------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | Reciprocal | {{ networks.moonriver.governance.tracks.root.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.root.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.root.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.root.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.root.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.root.min_approval.percent2 }}% | Linear | {{ networks.moonriver.governance.tracks.root.min_support.time0 }}: {{ networks.moonriver.governance.tracks.root.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.root.min_support.time1 }}: {{ networks.moonriver.governance.tracks.root.min_support.percent1 }}% | | Whitelisted | Reciprocal | {{ networks.moonriver.governance.tracks.whitelisted.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.whitelisted.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.whitelisted.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_approval.percent2 }}% | Reciprocal | {{ networks.moonriver.governance.tracks.whitelisted.min_support.time0 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.whitelisted.min_support.time1 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_support.percent1 }}%
{{ networks.moonriver.governance.tracks.whitelisted.min_support.time2 }}: {{ networks.moonriver.governance.tracks.whitelisted.min_support.percent2 }}% | | General Admin | Reciprocal | {{ networks.moonriver.governance.tracks.general_admin.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.general_admin.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.general_admin.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonriver.governance.tracks.general_admin.min_support.time0 }}: {{ networks.moonriver.governance.tracks.general_admin.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.general_admin.min_support.time1 }}: {{ networks.moonriver.governance.tracks.general_admin.min_support.percent1 }}%
{{ networks.moonriver.governance.tracks.general_admin.min_support.time2 }}: {{ networks.moonriver.governance.tracks.general_admin.min_support.percent2 }}% | | Emergency
Canceller | Reciprocal | {{ networks.moonriver.governance.tracks.canceller.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.canceller.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.canceller.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.canceller.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.canceller.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.canceller.min_approval.percent2 }}% | Reciprocal | {{ networks.moonriver.governance.tracks.canceller.min_support.time0 }}: {{ networks.moonriver.governance.tracks.canceller.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.canceller.min_support.time1 }}: {{ networks.moonriver.governance.tracks.canceller.min_support.percent1 }}%
{{ networks.moonriver.governance.tracks.canceller.min_support.time2 }}: {{ networks.moonriver.governance.tracks.canceller.min_support.percent2 }}% | | Emergency
Killer | Reciprocal | {{ networks.moonriver.governance.tracks.killer.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.killer.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.killer.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.killer.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.killer.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.killer.min_approval.percent2 }}% | Reciprocal | {{ networks.moonriver.governance.tracks.killer.min_support.time0 }}: {{ networks.moonriver.governance.tracks.killer.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.killer.min_support.time1 }}: {{ networks.moonriver.governance.tracks.killer.min_support.percent1 }}%
{{ networks.moonriver.governance.tracks.killer.min_support.time2 }}: {{ networks.moonriver.governance.tracks.killer.min_support.percent2 }}% | | Fast General Admin | Reciprocal | {{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.time0 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.percent0 }}%
{{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.time1 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.percent1 }}%
{{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.time2 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonriver.governance.tracks.fast_general_admin.min_support.time0 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_support.percent0 }}%
{{ networks.moonriver.governance.tracks.fast_general_admin.min_support.time1 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_support.percent1 }}%
{{ networks.moonriver.governance.tracks.fast_general_admin.min_support.time2 }}: {{ networks.moonriver.governance.tracks.fast_general_admin.min_support.percent2 }}% | === "Moonbase Alpha" | Track | Approval Curve | Approval Parameters | Support Curve | Support Parameters | |:----------------------:|:--------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Root | Reciprocal | {{ networks.moonbase.governance.tracks.root.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.root.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.root.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.root.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.root.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.root.min_approval.percent2 }}% | Linear | {{ networks.moonbase.governance.tracks.root.min_support.time0 }}: {{ networks.moonbase.governance.tracks.root.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.root.min_support.time1 }}: {{ networks.moonbase.governance.tracks.root.min_support.percent1 }}% | | Whitelisted | Reciprocal | {{ networks.moonbase.governance.tracks.whitelisted.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.whitelisted.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.whitelisted.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbase.governance.tracks.whitelisted.min_support.time0 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.whitelisted.min_support.time1 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_support.percent1 }}%
{{ networks.moonbase.governance.tracks.whitelisted.min_support.time2 }}: {{ networks.moonbase.governance.tracks.whitelisted.min_support.percent2 }}% | | General Admin | Reciprocal | {{ networks.moonbase.governance.tracks.general_admin.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.general_admin.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.general_admin.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.general_admin.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.general_admin.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbase.governance.tracks.general_admin.min_support.time0 }}: {{ networks.moonbase.governance.tracks.general_admin.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.general_admin.min_support.time1 }}: {{ networks.moonbase.governance.tracks.general_admin.min_support.percent1 }}%
{{ networks.moonbase.governance.tracks.general_admin.min_support.time2 }}: {{ networks.moonbase.governance.tracks.general_admin.min_support.percent2 }}% | | Emergency
Canceller | Reciprocal | {{ networks.moonbase.governance.tracks.canceller.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.canceller.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.canceller.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.canceller.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.canceller.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.canceller.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbase.governance.tracks.canceller.min_support.time0 }}: {{ networks.moonbase.governance.tracks.canceller.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.canceller.min_support.time1 }}: {{ networks.moonbase.governance.tracks.canceller.min_support.percent1 }}%
{{ networks.moonbase.governance.tracks.canceller.min_support.time2 }}: {{ networks.moonbase.governance.tracks.canceller.min_support.percent2 }}% | | Emergency
Killer | Reciprocal | {{ networks.moonbase.governance.tracks.killer.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.killer.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.killer.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.killer.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.killer.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.killer.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbase.governance.tracks.killer.min_support.time0 }}: {{ networks.moonbase.governance.tracks.killer.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.killer.min_support.time1 }}: {{ networks.moonbase.governance.tracks.killer.min_support.percent1 }}%
{{ networks.moonbase.governance.tracks.killer.min_support.time2 }}: {{ networks.moonbase.governance.tracks.killer.min_support.percent2 }}% | | Fast General Admin | Reciprocal | {{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.time0 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.percent0 }}%
{{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.time1 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.percent1 }}%
{{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.time2 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_approval.percent2 }}% | Reciprocal | {{ networks.moonbase.governance.tracks.fast_general_admin.min_support.time0 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_support.percent0 }}%
{{ networks.moonbase.governance.tracks.fast_general_admin.min_support.time1 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_support.percent1 }}%
{{ networks.moonbase.governance.tracks.fast_general_admin.min_support.time2 }}: {{ networks.moonbase.governance.tracks.fast_general_admin.min_support.percent2 }}% | #### Conviction Multiplier {: #conviction-multiplier-v2 } The Conviction multiplier is related to the number of Enactment Periods the tokens will be locked for after the referenda is enacted (if approved). Consequently, the longer you are willing to lock your tokens, the stronger your vote will be weighted. You also have the option of not locking tokens at all, but vote weight is drastically reduced (tokens are still locked during the duration of the referendum). If you were to vote 1000 tokens with a 6x Conviction, your weighted vote would be 6000 units. That is, 1000 locked tokens multiplied by the Conviction, which in this scenario would be 6. On the other hand, if you decided you didn't want to have your tokens locked after enactment, you could vote your 1000 tokens with a 0.1x Conviction. In this case, your weighted vote would only be 100 units. The Conviction multiplier values for each network are: === "Moonbeam" | Lock Periods After Enactment | Conviction Multiplier | Approx. Lock Time | |:----------------------------:|:---------------------:|:--------------------------------------------------------------:| | 0 | 0.1 | None | | 1 | 1 | {{networks.moonbeam.conviction.lock_period.conviction_1}} day | | 2 | 2 | {{networks.moonbeam.conviction.lock_period.conviction_2}} days | | 4 | 3 | {{networks.moonbeam.conviction.lock_period.conviction_3}} days | | 8 | 4 | {{networks.moonbeam.conviction.lock_period.conviction_4}} days | | 16 | 5 | {{networks.moonbeam.conviction.lock_period.conviction_5}} days | | 32 | 6 | {{networks.moonbeam.conviction.lock_period.conviction_6}} days | === "Moonriver" | Lock Periods After Enactment | Conviction Multiplier | Approx. Lock Time | |:----------------------------:|:---------------------:|:---------------------------------------------------------------:| | 0 | 0.1 | None | | 1 | 1 | {{networks.moonriver.conviction.lock_period.conviction_1}} day | | 2 | 2 | {{networks.moonriver.conviction.lock_period.conviction_2}} days | | 4 | 3 | {{networks.moonriver.conviction.lock_period.conviction_3}} days | | 8 | 4 | {{networks.moonriver.conviction.lock_period.conviction_4}} days | | 16 | 5 | {{networks.moonriver.conviction.lock_period.conviction_5}} days | | 32 | 6 | {{networks.moonriver.conviction.lock_period.conviction_6}} days | === "Moonbase Alpha" | Lock Periods After Enactment | Conviction Multiplier | Approx. Lock Time | |:----------------------------:|:---------------------:|:--------------------------------------------------------------:| | 0 | 0.1 | None | | 1 | 1 | {{networks.moonbase.conviction.lock_period.conviction_1}} day | | 2 | 2 | {{networks.moonbase.conviction.lock_period.conviction_2}} days | | 4 | 3 | {{networks.moonbase.conviction.lock_period.conviction_3}} days | | 8 | 4 | {{networks.moonbase.conviction.lock_period.conviction_4}} days | | 16 | 5 | {{networks.moonbase.conviction.lock_period.conviction_5}} days | | 32 | 6 | {{networks.moonbase.conviction.lock_period.conviction_6}} days | !!! note The lock time approximations are based upon regular {{ networks.moonriver.block_time }}-second block times. Block production may vary and thus the displayed lock times should not be deemed exact. ### Roadmap of a Proposal {: #roadmap-of-a-proposal-v2 } Before a proposal is submitted, the author of the proposal can submit their proposal idea to the designated Democracy Proposals section of the [Moonbeam Governance discussion forum](https://forum.moonbeam.network/c/governance/2){target=\_blank} for feedback from the community for at least five days. From there, the author can make adjustments to the proposal based on the feedback they've collected. Once the author is ready, they can submit their proposal on-chain. To do so, first, they need to submit the preimage of the proposal. The submitter needs to bond a fee to store the preimage on-chain. The bond is returned once the submitter unnotes the preimage. Next, they can submit the actual proposal and pay the Submission Deposit, which is enough to cover the on-chain storage cost of the proposal. Then the Lead-in Period begins and the community can begin voting "Aye" or "Nay" on the proposal by locking tokens. In order for the referendum to advance and move out of the Lead-in Period to the Decide period, the following criteria must be met: - The referendum must wait the duration of the Prepare Period, which allows for adequate time to discuss the proposal before it progresses to the next phase - There is enough Capacity in the chosen Track - A Decision Deposit has been made that meets the minimum requirements for the Track If a referendum meets the above criteria, it moves to the Decide Period and takes up one of the spots in its designated Track. In the Decide Period, voting continues and the referendum has a set amount of days to reach the Approval and Support requirements needed for it to progress to the Confirm Period. Once in the Confirm Period, a referendum must continuously meet the Approval and Support requirements for the duration of the period. If a referendum fails to meet the requirements at any point, it is returned to the Decide Period. If the referendum meets the Approval and Support requirements again, it can progress to the Confirm Period again and the Decide Period will be delayed until the end of the Confirm Period. If the Decide Period ends and not enough Approval and Support was received, the referendum will be rejected and the Decision Deposit will be returned. The proposal can be proposed again at any time. If a referendum continuously receives enough Approval and Support during the Confirm Period, it will be approved and move to the Enactment Period. It will wait the duration of the Enactment Period before it gets dispatched. The happy path for a proposal is shown in the following diagram: ![A happy path diagram of the proposal roadmap in OpenGov.](/images/learn/features/governance/proposal-roadmap.webp) ### Proposal Example Walkthrough A proposal (with its preimage) is submitted for the General Admin Track on Moonriver would have the following characteristics: - The Approval curve starts at {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent0 }}% on {{ networks.moonriver.governance.tracks.general_admin.min_approval.time0 }}, goes to {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent1 }}% on {{ networks.moonriver.governance.tracks.general_admin.min_approval.time1 }} - The Support curve starts at {{ networks.moonriver.governance.tracks.general_admin.min_support.percent0 }}% on {{ networks.moonriver.governance.tracks.general_admin.min_support.time0 }}, goes to {{ networks.moonriver.governance.tracks.general_admin.min_support.percent1 }}% on {{ networks.moonriver.governance.tracks.general_admin.min_support.time1 }} - A referendum starts the Decide Period with 0% "Aye" votes (nobody voted in the Lead-in Period) - Token holders begin to vote and the Approval increases to a value above {{ networks.moonriver.governance.tracks.general_admin.min_approval.percent1 }}% by {{ networks.moonriver.governance.tracks.general_admin.min_approval.time1 }} - If the Approval and Support thresholds are met for the duration of the Confirm Period ({{ networks.moonriver.governance.tracks.general_admin.confirm_period.blocks }} blocks, approximately {{ networks.moonriver.governance.tracks.general_admin.confirm_period.time }}), the referendum is approved - If the Approval and Support thresholds are not met during the Decision Period, the proposal is rejected. Note that the thresholds need to be met for the duration of the Confirm Period. Consequently, if they are met but the Decision Period expires before the completion of the Confirm Period, the proposal is rejected The Approval and Support percentages can be calculated using the following: === "Approval" ```text Approval = 100 * ( Total Conviction-weighted "Aye" votes / Total Conviction-weighted votes ) ``` === "Support" ```text Support = 100 * ( Total Aye + Abstain votes, ignoring conviction / Total supply ) ``` ### Proposal Cancellations {: #proposal-cancellations } In the event that a proposal already in the voting stage is found to have an issue, it may be necessary to prevent its approval. These instances may involve malicious activity or technical issues that make the changes impossible to implement due to recent upgrades to the network. Cancellations must be voted on by the network to be executed. Cancellation proposals are faster than a typical proposal because they must be decided before the enactment of the proposal they seek to cancel, but they follow the same process as other referenda. There is a cancellation Origin for use against referenda that contain an unforeseen problem, called the Emergency Canceller. The Emergency Canceller Origin and the Root Origin are allowed to cancel referenda. Regardless of the Origin, if a proposal is cancelled, it gets rejected and the Decision Deposit gets refunded. In addition, there is a Kill Origin, which is for bad referenda intending to harm the network, called Emergency Killer. The Emergency Killer Origin and the Root Origin have the ability to kill referenda. In this case, a proposal is cancelled and the Decision Deposit is slashed, meaning the deposit amount is burned regardless of the Origin. ### Rights of the OpenGov Technical Committee {: #rights-of-the-opengov-technical-committee } On Polkadot, the Technical Committee from Governance v1 was replaced with the Fellowship, which is a "mostly self-governing expert body with a primary goal of representing humans who embody and contain the technical knowledge base of the Kusama and/or Polkadot networks and protocol," according to [Polkadot's wiki](https://wiki.polkadot.com/general/web3-and-polkadot/#fellowship){target=\_blank}. For Moonbeam's implementation of OpenGov, instead of the Fellowship, there is a community OpenGov Technical Committee that has very similar power to that of the Fellowship. Their power in governance resides in their ability to whitelist a proposal. OpenGov Technical Committee members may only vote to whitelist a proposal if whitelisting that proposal would protect against a security vulnerability to the network. The passing threshold of the OpenGov Technical Committee members on whether to whitelist a proposal is determined by governance. As such, the OpenGov Technical Committee has very limited power over the network. Its purpose is to provide technical review of urgent security issues that are proposed by token holders. While still subject to governance, the idea behind the Whitelist track is that it will have different parameters to make it faster for proposals to pass. The Whitelist Track parameters, including approval, support, and voting, are determined by the Moonriver or Moonbeam token holders through governance and cannot be changed by the OpenGov Technical Committee. The OpenGov Technical Committee is made up of members of the community who have technical knowledge and expertise in Moonbeam-based networks. ### Related Guides on OpenGov {: #try-it-out } For related guides on submitting and voting on referenda on Moonbeam with OpenGov, please check the following guides: - [How to Submit a Proposal](/tokens/governance/proposals/){target=\_blank} - [How to Vote on a Proposal](/tokens/governance/voting/){target=\_blank} - [Interact with the Preimages Precompiled Contract (Solidity Interface)](/builders/ethereum/precompiles/features/governance/preimage/){target=\_blank} - [Interact with the Referenda Precompiled Contract (Solidity Interface)](/builders/ethereum/precompiles/features/governance/referenda/){target=\_blank} - [Interact with the Conviction Voting Precompiled Contract (Solidity Interface)](/builders/ethereum/precompiles/features/governance/conviction-voting/){target=\_blank} --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/randomness/ --- BEGIN CONTENT --- --- title: Randomness description: Learn about the sources of VRF randomness on Moonbeam, the request and fulfillment process, and some security considerations when using on-chain randomness. categories: Basics --- # Randomness on Moonbeam ## Introduction {: #introduction } Randomness is necessary for a variety of blockchain applications to create unbiased, unpredictable, and unique outcomes. However, obtaining a reliable source of randomness is a challenge. Computers are deterministic, meaning given the same input, the same output will always be produced. Therefore, random values generated by computers are referred to as pseudo-random as they appear to be statistically random, but given the same input, the output can easily be repeated. Moonbeam utilizes verifiable random functions (VRF) to generate randomness that can be verified on-chain. A VRF is a cryptographic function that takes some input and produces random values, along with a proof of authenticity that they were generated by the submitter. The proof can be verified by anyone to ensure that the random values were generated correctly. There are two available sources of randomness that provide random inputs based on block producers' VRF keys and past randomness results: [local VRF](#local-vrf) and [BABE epoch randomness](#babe-epoch-randomness). Local VRF is determined directly within Moonbeam using the collator of the block's VRF key and the last block's VRF output. On the other hand, [BABE](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/#block-production-babe){target=\_blank} epoch randomness is based on all the VRF produced by the relay chain validators during a complete [epoch](https://wiki.polkadot.com/general/glossary/#epoch){target=\_blank}. You can interact with and request on-chain randomness using the Randomness Precompile contract, a Solidity interface that enables smart contract developers to access the randomness functionality through the Ethereum API. For more information, please check out the [Interacting with the Randomness Precompile](/builders/ethereum/precompiles/features/randomness/){target=\_blank} guide. You can also take a look at the [Randomness Pallet](/builders/substrate/interfaces/features/randomness/){target=\_blank}, which can be used to obtain current randomness requests and results. ## General Definitions {: #general-definitions } - **Epoch** - a time duration in the BABE protocol that is broken into smaller time slots. Slots are discrete units of time six seconds in length. On Polkadot, one epoch lasts approximately 2,400 slots or 4 hours. On Kusama, one epoch lasts approximately 600 slots or 1 hour. - **Deposit** - an amount of funds required to request random words. There is one deposit per request. Once the request has been fulfilled, the deposit will be returned to the account that requested the randomness - **Block expiration delay** - the number of blocks that must pass before a local VRF request expires and can be purged - **Epoch expiration delay** - the number of epochs that must pass before a BABE request expires and can be purged - **Minimum block delay** - the minimum number of blocks before a request can be fulfilled for local VRF requests - **Maximum block delay** - the maximum number of blocks before a request can be fulfilled for local VRF requests - **Maximum random words** - the maximum number of random words being requested - **Epoch fulfillment delay** - the delay in epochs before a request can be fulfilled for a BABE request ## Quick Reference {: #quick-reference } === "Moonbeam" | Variable | Value | |:-----------------------:|:---------------------------------------------------------------------------------------------:| | Deposit | {{ networks.moonbeam.randomness.req_deposit_amount.glmr }} GLMR | | Block expiration delay | {{ networks.moonbeam.randomness.block_expiration }} blocks | | Epoch expiration delay | {{ networks.moonbeam.randomness.epoch_expiration }} epochs | | Minimum block delay | {{ networks.moonbeam.randomness.min_vrf_blocks_delay }} blocks | | Maximum block delay | {{ networks.moonbeam.randomness.max_vrf_blocks_delay }} blocks | | Maximum random words | {{ networks.moonbeam.randomness.max_random_words }} words | | Epoch fulfillment delay | {{ networks.moonbeam.randomness.epoch_fulfillment_delay }} epochs (following the current one) | === "Moonriver" | Variable | Value | |:-----------------------:|:----------------------------------------------------------------------------------------------:| | Deposit | {{ networks.moonriver.randomness.req_deposit_amount.movr }} MOVR | | Block expiration delay | {{ networks.moonriver.randomness.block_expiration }} blocks | | Epoch expiration delay | {{ networks.moonriver.randomness.epoch_expiration }} epochs | | Minimum block delay | {{ networks.moonriver.randomness.min_vrf_blocks_delay }} blocks | | Maximum block delay | {{ networks.moonriver.randomness.max_vrf_blocks_delay }} blocks | | Maximum random words | {{ networks.moonriver.randomness.max_random_words }} words | | Epoch fulfillment delay | {{ networks.moonriver.randomness.epoch_fulfillment_delay }} epochs (following the current one) | === "Moonbase Alpha" | Variable | Value | |:-----------------------:|:---------------------------------------------------------------------------------------------:| | Deposit | {{ networks.moonbase.randomness.req_deposit_amount.dev }} DEV | | Block expiration delay | {{ networks.moonbase.randomness.block_expiration }} blocks | | Epoch expiration delay | {{ networks.moonbase.randomness.epoch_expiration }} epochs | | Minimum block delay | {{ networks.moonbase.randomness.min_vrf_blocks_delay }} blocks | | Maximum block delay | {{ networks.moonbase.randomness.max_vrf_blocks_delay }} blocks | | Maximum random words | {{ networks.moonbase.randomness.max_random_words }} words | | Epoch fulfillment delay | {{ networks.moonbase.randomness.epoch_fulfillment_delay }} epochs (following the current one) | ## Local VRF {: #local-vrf } Local VRF randomness is generated on a block-by-block basis at the beginning of the block using the previous block's VRF output along with the public key of the current block author's VRF key. The generated randomness result is stored and used to fulfill all randomness requests for the current block. You can request local VRF randomness using the [`requestLocalVRFRandomWords` method](/builders/ethereum/precompiles/features/randomness/#:~:text=requestLocalVRFRandomWords){target=\_blank} of the [Randomness Precompile](/builders/ethereum/precompiles/features/randomness/){target=\_blank}. If your contract could have concurrent requests open, you can use the `requestId` returned from the `requestLocalVRFRandomWords` method to track which response is associated with which randomness request. ## BABE Epoch Randomness {: #babe-epoch-randomness } BABE epoch randomness is based on a hash of the VRF values from the blocks produced in the relay chain epoch before last. On Polkadot, an [epoch lasts for roughly 4 hours](https://wiki.polkadot.com/learn/learn-cryptography/#vrf){target=\_blank}, and on Kusama, an [epoch lasts for roughly 1 hour](https://guide.kusama.network/docs/maintain-polkadot-parameters#periods-of-common-actions-and-attributes){target=\_blank}. The hashing is completed on the relay chain, and as such, it is not possible for a collator on Moonbeam to influence the randomness value unless they are also a validator on the relay chain and were responsible for producing the last output included in an epoch. The randomness remains constant during an epoch. If a collator skips block production, the next eligible collator can fulfill the request using the same random value. You can request BABE epoch randomness using the [`requestRelayBabeEpochRandomWords` method](/builders/ethereum/precompiles/features/randomness/#:~:text=requestRelayBabeEpochRandomWords){target=\_blank} of the [Randomness Precompile](/builders/ethereum/precompiles/features/randomness/){target=\_blank}. In order to generate unique randomness, a different salt must be provided to the `requestRelayBabeEpochRandomWords` function. At the beginning of each relay chain epoch change, the randomness from one epoch ago is read from the relay chain state proof and used to fulfill all randomness requests that are due in the current block. ## Request & Fulfill Process {: #request-and-fulfill-process } In general, the request and fulfill process for randomness is as follows: 1. Pay the deposit required to request random words 2. Request the randomness either using the local VRF or BABE epoch source of randomness. When requesting randomness you'll need to specify a few things: - a refund address where any excess fees will be sent to - the amount of fees which will be set aside to pay for fulfillment. If the specified amount is not enough you can always increase the request fees later, or if it's more than enough you'll be refunded the excess fees to the specified address after fulfillment - a unique salt that will be used to generate different random words - the number of random words you would like to request - for local VRF, the delay period in blocks, which is used to increase unpredictability. It must be between the [minimum and maximum number of blocks](#quick-reference) as listed above. For BABE epoch randomness, you do not need to specify a delay but can fulfill the request after the [epoch delay](#quick-reference) has passed 3. Wait for the delay period to pass 4. Fulfill the randomness request, which triggers the random words to be computed using the current block's randomness result and the given salt. This can manually be done by anyone using the fee that was initially set aside for the request 5. For fulfilled requests, the random words are returned and the cost of execution will be refunded from the request fee to the address that initiated the fulfillment. Then any excess fees and the request deposit are transferred to the specified refund address If a request expires it can be purged by anyone. When this happens, the request fee is paid out to the address that initiated the purge and the deposit is returned to the original requester. The happy path for a randomness request is shown in the following diagram: ![Randomness request happy path diagram](/images/learn/features/randomness/randomness-1.webp) ## Security Considerations {: #security-considerations } A method with the ability to call your `fulfillRandomness` method directly could spoof a VRF response with any random value, so it's critical that it can only be directly called by the `RandomnessConsumer.sol` contract's `rawFulfillRandomness` method. For your users to trust that your contract's random behavior is free from malicious interference, it's best if you can write it so that all behaviors implied by a VRF response are executed *during* your `fulfillRandomness` method. If your contract must store the response (or anything derived from it) and use it later, you must ensure that any user-significant behavior which depends on that stored value cannot be manipulated by a subsequent VRF request. Similarly, the collators have some influence over the order in which VRF responses appear on the blockchain, so if your contract could have multiple VRF requests in flight simultaneously, you must ensure that the order in which the VRF responses arrive cannot be used to manipulate your contract's user-significant behavior. Since the output of the random words generated for `requestLocalVRFRandomWords` is dependent on the collator producing the block at fulfillment, the collator could skip its block, forcing the fulfillment to be executed by a different collator and therefore generating a different VRF. However, such an attack would incur the cost of losing the block reward to the collator. It is also possible for a collator to be able to predict some of the possible outcome of the VRF if the delay between the request and the fulfillment is too short. It is for this reason that you can choose to provide a higher delay. Since the output of the random words generated for `requestRelayBabeEpochRandomWords` is dependent on the relay chain validator producing the blocks during an epoch, it is possible for the last validator of an epoch to choose between two possible VRF outputs by skipping the production of a block. However, such an attack would incur the cost of losing the block reward to the validator. It is not possible for a parachain collator to predict or influence the output of the relay chain VRF, not to censor the fulfillment, as long as there is one honest collator. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/staking/ --- BEGIN CONTENT --- --- title: Staking description: Moonbeam provides staking features where token holders delegate collator candidates with their tokens and earn rewards. categories: Basics, Staking --- # Staking on Moonbeam ## Introduction {: #introduction } Moonbeam uses a block production mechanism based on [Polkadot's Proof-of-Stake model](https://docs.polkadot.com/polkadot-protocol/architecture/polkadot-chain/pos-consensus/){target=\_blank}, where there are collators and validators. [Collators](https://wiki.polkadot.com/learn/learn-collator/){target=\_blank} maintain parachains (in this case, Moonbeam) by collecting transactions from users and producing state transition proofs for the relay chain [validators](https://wiki.polkadot.com/learn/learn-validator/){target=\_blank}. The candidates in the active set of collators (nodes that produce blocks) are selected based on their stake in the network. And here is where staking comes in. Collator candidates (and token holders if they delegate) have a stake in the network. The top N candidates by staked amount are chosen to produce blocks with a valid set of transactions, where N is a configurable parameter. Part of each block reward goes to the collators that produced the block, who then share it with the delegators considering their percental contributions towards the collator's stake. In such a way, network members are incentivized to stake tokens to improve the overall security. Since staking is done at a protocol level through the staking interface, if you choose to delegate, the collators you delegate to do not have access to your tokens. To easily manage staking related actions, you can visit the [Moonbeam Network DApp](https://apps.moonbeam.network){target=\_blank} and use the network tabs at the top of the page to easily switch between Moonbeam networks. To learn how to use the DApp, you can check out the [How to Stake MOVR Tokens](https://moonbeam.network/news/how-to-stake-movr-tokens-on-moonriver-and-earn-staking-rewards){target=\_blank} guide or [video tutorial](https://www.youtube.com/watch?v=8GwetYmzEJM){target=\_blank}, both of which can be adapted for the Moonbeam and the Moonbase Alpha TestNet. ## General Definitions {: #general-definitions } Some important parameters to understand in relation to the staking system on Moonbeam include: - **Round** — a specific number of blocks around which staking actions are enforced. For example, new delegations are enacted when the next round starts. When bonding less or revoking delegations, funds are returned after a specified number of rounds - **Candidates** - node operators that are eligible to become block producers if they can acquire enough stake to be in the active set - **Collators** — active set of candidates that are selected to be block producers. They collect transactions from users and produce state transition proofs for the relay chain to validate - **Delegators** — token holders who stake tokens, vouching for specific collator candidates. Any user that holds a minimum amount of tokens as [free balance](https://wiki.polkadot.com/learn/learn-accounts/#balance-types#balance-types) can become a delegator - **Minimum delegation per candidate** — minimum amount of tokens to delegate candidates once a user is in the set of delegators - **Maximum delegators per candidate** — maximum number of delegators, by staked amount, that a candidate can have which are eligible to receive staking rewards - **Maximum delegations** — maximum number of candidates a delegator can delegate - **Exit delay** - an exit delay is the amount of rounds before a candidate or delegator can execute a scheduled request to decrease or revoke a bond, or leave the set of candidates or delegators - **Reward payout delay** - a certain amount of rounds must pass before staking rewards are distributed automatically to the free balance - **Reward pool** - a portion of the annual inflation that is set aside for collators and delegators - **Collator commission** - default fixed percent a collator takes off the top of the due staking rewards. Not related to the reward pool - **Delegator rewards** — the aggregate delegator rewards distributed over all eligible delegators, taking into account the relative size of stakes ([read more](/learn/features/staking/#reward-distribution)) - **Auto-compounding** - a setting that automatically applies a percentage of a delegator's rewards to their total amount delegated - **Slashing** — a mechanism to discourage collator misbehavior, where typically the collator and their delegators get slashed by losing a percentage of their stake. Currently, there is no slashing but this can be changed through governance. Collators who produce blocks that are not finalized by the relay chain won't receive rewards ## Quick Reference {: #quick-reference } === "Moonbeam" | Variable | Value | |:--------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------:| | Round duration | {{ networks.moonbeam.staking.round_blocks }} blocks ({{ networks.moonbeam.staking.round_hours }} hours) | | Minimum delegation per candidate | {{ networks.moonbeam.staking.min_del_stake }} GLMR | | Maximum delegators per candidate | {{ networks.moonbeam.staking.max_del_per_can }} | | Maximum delegations | {{ networks.moonbeam.staking.max_del_per_del }} | | Reward payout delay | {{ networks.moonbeam.delegator_timings.rewards_payouts.rounds }} rounds ({{ networks.moonbeam.delegator_timings.rewards_payouts.hours }} hours) | | Add or increase delegation | takes effect in the next round (funds are withdrawn immediately) | | Decrease delegation delay | {{ networks.moonbeam.delegator_timings.del_bond_less.rounds }} rounds ({{ networks.moonbeam.delegator_timings.del_bond_less.hours }} hours) | | Revoke delegations delay | {{ networks.moonbeam.delegator_timings.revoke_delegations.rounds }} rounds ({{ networks.moonbeam.delegator_timings.revoke_delegations.hours }} hours) | | Leave delegators delay | {{ networks.moonbeam.delegator_timings.leave_delegators.rounds }} rounds ({{ networks.moonbeam.delegator_timings.leave_delegators.hours }} hours) | === "Moonriver" | Variable | Value | |:--------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------:| | Round duration | {{ networks.moonriver.staking.round_blocks }} blocks ({{ networks.moonriver.staking.round_hours }} hours) | | Minimum delegation per candidate | {{ networks.moonriver.staking.min_del_stake }} MOVR | | Maximum delegators per candidate | {{ networks.moonriver.staking.max_del_per_can }} | | Maximum delegations | {{ networks.moonriver.staking.max_del_per_del }} | | Reward payout delay | {{ networks.moonriver.delegator_timings.rewards_payouts.rounds }} rounds ({{ networks.moonriver.delegator_timings.rewards_payouts.hours }} hours) | | Add or increase delegation | takes effect in the next round (funds are withdrawn immediately) | | Decrease delegation delay | {{ networks.moonriver.delegator_timings.del_bond_less.rounds }} rounds ({{ networks.moonriver.delegator_timings.del_bond_less.hours }} hours) | | Revoke delegations delay | {{ networks.moonriver.delegator_timings.revoke_delegations.rounds }} rounds ({{ networks.moonriver.delegator_timings.revoke_delegations.hours }} hours) | | Leave delegators delay | {{ networks.moonriver.delegator_timings.leave_delegators.rounds }} rounds ({{ networks.moonriver.delegator_timings.leave_delegators.hours }} hours) | === "Moonbase Alpha" | Variable | Value | |:--------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------:| | Round duration | {{ networks.moonbase.staking.round_blocks }} blocks ({{ networks.moonbase.staking.round_hours }} hours) | | Minimum delegation per candidate | {{ networks.moonbase.staking.min_del_stake }} DEV | | Maximum delegators per candidate | {{ networks.moonbase.staking.max_del_per_can }} | | Maximum delegations | {{ networks.moonbase.staking.max_del_per_del }} | | Reward payout delay | {{ networks.moonbase.delegator_timings.rewards_payouts.rounds }} rounds ({{ networks.moonbase.delegator_timings.rewards_payouts.hours }} hours) | | Add or increase delegation | takes effect in the next round (funds are withdrawn immediately) | | Decrease delegation delay | {{ networks.moonbase.delegator_timings.del_bond_less.rounds }} rounds ({{ networks.moonbase.delegator_timings.del_bond_less.hours }} hours) | | Revoke delegations delay | {{ networks.moonbase.delegator_timings.revoke_delegations.rounds }} rounds ({{ networks.moonbase.delegator_timings.revoke_delegations.hours }} hours) | | Leave delegators delay | {{ networks.moonbase.delegator_timings.leave_delegators.rounds }} rounds ({{ networks.moonbase.delegator_timings.leave_delegators.hours }} hours) | !!! note As of runtime 3000, [asynchronous backing](https://wiki.polkadot.com/learn/learn-async-backing/#asynchronous-backing){target=\_blank} has been enabled on all Moonbeam networks. As a result, the target block time was reduced from 12 seconds to 6 seconds, which may break some timing-based assumptions. To learn how to get the current value of any of the parameters around staking, check out the [Retrieving Staking Parameters](/tokens/staking/stake/#retrieving-staking-parameters){target=\_blank} section of the [How to Stake your Tokens](/tokens/staking/stake/){target=\_blank} guide. If you're looking for candidate or collator-specific requirements and information, you can take a look at the [Collators](/node-operators/networks/collators/requirements/#bonding-requirements){target=\_blank} guide. ## Resources for Selecting a Collator {: #resources-for-selecting-a-collator} There are a few resources you can check out to help you select a collator to delegate: === "Moonbeam" | Variable | Value | |:----------------------------:|:-------------------------------------------------------------------------------:| | Stake GLMR Dashboard | [Stake GLMR](https://stakeglmr.com){target=\_blank} | | Collators Leaderboard | [Moonscan](https://moonbeam.moonscan.io/collators){target=\_blank} | | Collator Dashboard | [DappLooker](https://dapplooker.com/dashboard/moonbeam-collator-dashboard-91){target=\_blank} | === "Moonriver" | Variable | Value | |:----------------------------:|:--------------------------------------------------------------------------------:| | Stake MOVR Dashboard | [Stake MOVR](https://stakemovr.com){target=\_blank} | | Collators Leaderboard | [Moonscan](https://moonriver.moonscan.io/collators){target=\_blank} | | Collator Dashboard | [DappLooker](https://dapplooker.com/dashboard/moonriver-collator-dashboard-28){target=\_blank} | === "Moonbase Alpha" | Variable | Value | |:------------------:|:--------------------------------------------------------------------------------:| | List of candidates | [Moonbase Alpha Subscan](https://moonbase.subscan.io/validator){target=\_blank} | !!! note The DappLooker Collator dashboard for Moonriver is experimental beta software and may not accurately reflect collator performance. Be sure to do your own research before delegating to a collator. ### General Tips {: #general-tips } - To optimize your staking rewards, you should generally choose a collator with a lower total amount bonded. In that case, your delegation amount will represent a larger portion of the collator’s total stake and you will earn proportionally higher rewards. However, there is a higher risk of the collator being kicked out of the active set and not earning rewards at all - The minimum bond for each collator tends to increase over time, so if your delegation is close to the minimum, there is a higher chance you might fall below the minimum and not receive rewards - Spreading delegations between multiple collators is more efficient in terms of rewards, but only recommended if you have enough to stay above the minimum bond of each collator - You can consider collator performance by reviewing the number of blocks each collator has produced recently - You can set up auto-compounding which will automatically restake a specified percentage of your delegation rewards ## Reward Distribution {: #reward-distribution } Rewards for collators and their delegators are calculated at the start of every round for their work prior to the [reward payout delay](#quick-reference). For example, on Moonriver the rewards are calculated for the collators work from {{ networks.moonriver.delegator_timings.rewards_payouts.rounds }} rounds ago. The calculated rewards are then paid out on a block-by-block basis starting at the second block of the round. For every block, one collator will be chosen to receive their entire reward payout from the prior round, along with their delegators, until all rewards have been paid out for that round. For example, if there are {{ networks.moonriver.staking.max_candidates }} collators who produced blocks in the prior round, all of the collators and their delegators will be paid by block {{ networks.moonriver.staking.paid_out_block }} of the new round. You can choose to auto-compound your delegation rewards so you no longer have to manually delegate rewards. If you choose to set up auto-compounding, you can specify the percentage of rewards to be auto-compounded. These rewards will then be automatically added to your delegation. ### Annual Inflation {: #annual-inflation} The distribution of the annual inflation goes as follows: === "Moonbeam" | Variable | Value | |:-----------------------------------------:|:-------------------------------------------------------------------------------------:| | Annual inflation | {{ networks.moonbeam.inflation.total_annual_inflation }}% | | Rewards pool for collators and delegators | {{ networks.moonbeam.inflation.delegator_reward_inflation }}% of the annual inflation | | Collator commission | {{ networks.moonbeam.inflation.collator_reward_inflation }}% of the annual inflation | | Parachain bond reserve | {{ networks.moonbeam.inflation.parachain_bond_inflation }}% of the annual inflation | === "Moonriver" | Variable | Value | |:-----------------------------------------:|:--------------------------------------------------------------------------------------:| | Annual inflation | {{ networks.moonriver.inflation.total_annual_inflation }}% | | Rewards pool for collators and delegators | {{ networks.moonriver.inflation.delegator_reward_inflation }}% of the annual inflation | | Collator commission | {{ networks.moonriver.inflation.collator_reward_inflation }}% of the annual inflation | | Parachain bond reserve | {{ networks.moonriver.inflation.parachain_bond_inflation }}% of the annual inflation | === "Moonbase Alpha" | Variable | Value | |:-----------------------------------------:|:-------------------------------------------------------------------------------------:| | Annual inflation | {{ networks.moonbase.inflation.total_annual_inflation }}% | | Rewards pool for collators and delegators | {{ networks.moonbase.inflation.delegator_reward_inflation }}% of the annual inflation | | Collator commission | {{ networks.moonbase.inflation.collator_reward_inflation }}% of the annual inflation | | Parachain bond reserve | {{ networks.moonbase.inflation.parachain_bond_inflation }}% of the annual inflation | From the rewards pool, collators get the rewards corresponding to their stake in the network. The rest are distributed among delegators by stake. ### Calculating Rewards {: #calculating-rewards } Mathematically speaking, for collators, the reward distribution per block proposed and finalized would look like this: ![Staking Collator Reward](/images/learn/features/staking/staking-overview-1.webp) Where `amount_due` is the corresponding inflation being distributed in a specific block, the `stake` corresponds to the number of tokens bonded by the collator in respect to the total stake of that collator (accounting delegations). For each delegator, the reward distribution (per block proposed and finalized by the delegated collator) would look like this: ![Staking Delegator Reward](/images/learn/features/staking/staking-overview-2.webp) Where `amount_due` is the corresponding inflation being distributed in a specific block, the `stake` corresponds to the amount of tokens bonded by each delegator in respect to the total stake of that collator. ## Risks {: #risks } *Holders of MOVR/GLMR tokens should perform careful due diligence on collators before delegating. Being listed as a collator is not an endorsement or recommendation from the Moonbeam Network, the Moonriver Network, or Moonbeam Foundation. Neither the Moonbeam Network, Moonriver Network, nor Moonbeam Foundation has vetted the list collators and assumes no responsibility with regard to the selection, performance, security, accuracy, or use of any third-party offerings. You alone are responsible for doing your own diligence to understand the applicable fees and all risks present, including actively monitoring the activity of your collators.* *You agree and understand that neither the Moonbeam Network, the Moonriver Network, nor Moonbeam Foundation guarantees that you will receive staking rewards and any applicable percentage provided (i) is an estimate only and not guaranteed, (ii) may change at any time and (iii) may be more or less than the actual staking rewards you receive. The Moonbeam Foundation makes no representations as to the monetary value of any rewards at any time.* *Staking MOVR/GLMR tokens is not free of risk.* *Staked MOVR/GLMR tokens are locked up, and retrieving them requires a {{ networks.moonriver.delegator_timings.del_bond_less.days }} day/{{ networks.moonbeam.delegator_timings.del_bond_less.days }} day waiting period .* *Additionally, if a collator fails to perform required functions or acts in bad faith, a portion of their total stake can be slashed (i.e. destroyed). This includes the stake of their delegators. If a collators behaves suspiciously or is too often offline, delegators can choose to unbond from them or switch to another collator. Delegators can also mitigate risk by electing to distribute their stake across multiple collators.* --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/treasury/ --- BEGIN CONTENT --- --- title: Treasury description: Moonbeam has an on-chain Treasury controlled by Treasury Council members, enabling stakeholders to submit proposals to further the network. categories: Basics --- # Treasury on Moonbeam ## Introduction {: #introduction } The Moonbeam Treasury is an on-chain collection of funds launched at the network's genesis. Initially pre-funded with 0.5% of the token supply, the Treasury continues to accumulate GLMR as {{ networks.moonbeam.inflation.parachain_bond_treasury }}% of the parachain bond reserve inflation goes to the Treasury. For more information about Moonbeam inflation figures, see [GLMR Tokenomics](https://moonbeam.foundation/glimmer-token-tokenomics/){target=\_blank}. The Moonbeam Treasury funds initiatives that support and grow the network. Stakeholders can propose spending requests for Treasury Council review, focusing on efforts like integrations, collaborations, community events, and outreach. Treasury spend proposers must submit their proposals to the [Moonbeam Forum](https://forum.moonbeam.network/c/governance/treasury-proposals/8){target=\_blank}. For submission details, see [How to Propose a Treasury Spend](/tokens/governance/treasury-spend/){target=\_blank}. The [Treasury Council](https://forum.moonbeam.network/g/TreasuryCouncil){target=\_blank} oversees the spending of the Moonbeam Treasury and votes on funding proposals. It comprises two members from the Moonbeam Foundation and three external community members. The three external members are elected to terms of {{ networks.moonbeam.treasury.months_elected }} months. The same Treasury Council oversees Treasury requests for both Moonbeam and Moonriver. The Council meets monthly to review proposals submitted on the [Moonbeam Forum](https://forum.moonbeam.network/c/governance/treasury-proposals/8){target=\_blank}. Once a proposal is agreed upon, the Council members must complete the on-chain approval process. ## General Definitions {: #general-definitions } Some important terminology to understand regarding treasuries: - **Treasury Council** — a group of Moonbeam Foundation representatives and external community members. The Council reviews funding proposals, ensures alignment with the community, and ultimately authorizes Treasury spending - **Proposal** — a plan or suggestion submitted by stakeholders to further the network to be approved by the Treasury Council ## Treasury Addresses {: #treasury-addresses } The Treasury address for each respective network can be found below: === "Moonbeam" [0x6d6F646c70632f74727372790000000000000000](https://moonbase.subscan.io/account/0x6d6F646c70632f74727372790000000000000000){target=_blank} === "Moonriver" [0x6d6f646C70792f74727372790000000000000000](https://moonriver.subscan.io/account/0x6d6f646C70792f74727372790000000000000000){target=_blank} === "Moonbase Alpha" [0x6d6F646c70632f74727372790000000000000000](https://moonbase.subscan.io/account/0x6d6F646c70632f74727372790000000000000000){target=_blank} ## Roadmap of a Treasury Proposal {: #roadmap-of-a-treasury-proposal } The happy path of a Treasury spend request is as follows: 1. **Proposal submission** - the user submits a proposal to the [Moonbeam Forum](https://forum.moonbeam.network/c/governance/treasury-proposals/8){target=\_blank} 2. **Forum discussion** - the proposal is discussed by the community on the Forum. The ultimate Aye/Nay decision is determined by the Treasury council 3. **Treasury approval and action** - if the Treasury Council agrees, it authorizes the Treasury spending and moves the process forward ## Treasury Council Voting Process {: #treasury-council-voting-process } A member of the Treasury Council will submit a `treasury.spend` call. This call requires specifying the amount, the asset type, and the beneficiary account to receive the funds. The Treasury supports spending various token types beyond GLMR, including native USDT/USDC. Once this extrinsic is submitted, a new Treasury Council collective proposal will be created and made available for council members to vote on. Once approved through the Treasury Council's internal voting process, the funds will be released automatically to the beneficiary account through the `treasury.payout` extrinsic. !!! note There is no on-chain action for the proposer or beneficiary of the Treasury spend request. All Treasury spend actions will be completed by members of the Treasury Council. Note that this process has changed significantly from prior Treasury processes, where tokenholders could submit Treasury proposals with bonds attached. Now, no on-chain action is necessary to submit a Treasury proposal. Rather, all that is needed is to raise a Treasury Council request on the [Moonbeam Forum](https://forum.moonbeam.network/c/governance/treasury-proposals/8){target=\_blank} and the Treasury Council will take care of the on-chain components. For more information, see [How to Propose a Treasury Spend](/tokens/governance/treasury-spend/#next-steps){target=\_blank} --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/features/xchain-plans/ --- BEGIN CONTENT --- --- title: Cross-Chain Communication description: This guide covers the ways you can build cross-chain dApps with Moonbeam, including via XCM, cross consensus messaging, and GMP, general message passing. categories: Basics, XCM --- # Cross-Chain Communication Methods Moonbeam makes it easy for developers to build smart contracts that connect across chains, both within the Polkadot ecosystem and outside the Polkadot ecosystem. This page will provide an overview of the underlying protocols that enable cross-chain communication and how you can leverage them to build connected contracts. For step-by-step guides of how to put these principles into practice, be sure to check out the [interoperability tutorials](/tutorials/interoperability/){target=\_blank}. Two key terms that will come up frequently in this guide are XCM and GMP. [XCM](/builders/interoperability/xcm/){target=\_blank} refers to cross-consensus messaging, and it's Polkadot's native interoperability language that facilitates communication between Polkadot blockchains. You can read more about the [standardized XCM message format](https://docs.polkadot.com/develop/interoperability/intro-to-xcm/){target=\_blank} and [How to Get Started Building with XCM](/builders/interoperability/xcm/){target=\_blank}. [GMP](https://moonbeam.network/news/seamless-blockchain-interoperability-the-power-of-general-message-passing-gmp){target=\_blank}, or general message passing, refers to the sending and receiving of messages within decentralized blockchain networks. While XCM is a type of general message passing, GMP colloquially refers to cross-chain communication between Moonbeam and blockchains outside of Polkadot. Similarly, in this guide, XCM refers to cross-chain messaging within Polkadot, and GMP refers to cross-chain messaging between Moonbeam and other ecosystems outside of Polkadot. ## Quick Reference {: #quick-reference } === "Comparison of XCM vs GMP" | Specification | XCM | GMP | |:---------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | **Scope** | Polkadot and its connected parachains | Any blockchain supported by a GMP provider | | **Provider** | Polkadot | [Axelar](/builders/interoperability/protocols/axelar/){target=\_blank}, [Wormhole](/builders/interoperability/protocols/wormhole/){target=\_blank}, [LayerZero](/builders/interoperability/protocols/layerzero/){target=\_blank}, [Hyperlane](/builders/interoperability/protocols/hyperlane/){target=\_blank}, etc. | | **Implementation** | [XCM Virtual Machine](https://wiki.polkadot.com/learn/learn-xcvm/){target=\_blank} | Smart contracts | | **Security** | Polkadot's shared security | Proprietary consensus determined by GMP provider | | **Fees** | [Purchased with `BuyExecution` XCM instruction with supported asset](/builders/interoperability/xcm/core-concepts/weights-fees/){target=\_blank} | User sends value with transaction to pay for gas on the destination chain | | **Adding New Chains** | Requires creation of XCM channels by both connected chains | Requires GMP provider to add support | ## XCM Transport Methods {: #xcm-transport-methods } XCMP is the protocol that carries messages conforming to the XCM standard. The difference between the two is easy to remember with the added letter "P" for protocol. While XCM is the language that defines the format of the message to send, XCMP can be thought of as the pipes that enable the delivery of said messages. XCMP is comprised of channels that enable communication between connected blockchains. When a parachain launches on Polkadot, two XCM channels are established automatically to allow for communication between the Polkadot relay chain and the parachain itself. XCM channels are omnidirectional, so two channels must be established for bidirectional communication. Polkadot parachains can optionally choose to establish additional XCM channels with other parachains. Establishing XCM channels with other chains is a double opt-in process, so the receiving chain must also agree to have the channel established. Establishing XCM channels with another parachain allows for the exchange of XCM messages, enabling the flow of cross-chain assets and remote contract calls, to name a few examples. There are several different subcategories of XCM transport methods, including: ### VMP {: #vmp } VMP, or [Vertical Message Passing](https://wiki.polkadot.com/learn/learn-xcm-transport/#vmp-vertical-message-passing){target=\_blank}, refers to message passing between the relay chain and a parachain. Given that XCM channels are one-way, there are two types of message passing that comprise VMP, namely: - **UMP** - Upward Message Passing refers to message passing from a parachain to the relay chain - **DMP** - Downward Message Passing refers to message passing from the relay chain to a parachain ### HRMP {: #HRMP } [Horizontal Relay-routed Message Passing](https://wiki.polkadot.com/learn/learn-xcm-transport/#hrmp-xcmp-lite){target=\_blank} (HRMP) is a temporary protocol that is currently being used while XCMP (Cross-Chain Message Passing) is still under development. HRMP serves as a placeholder and provides the same functionality and interface as XCMP. However, HRMP is more resource-intensive because it stores all messages within the Relay Chain's storage. When opening XCM channels with other parachains today, those channels are using HRMP in place of the aforementioned XCMP. Once the implementation of XCMP is complete, the plan is to phase out HRMP and replace it with XCMP gradually. For more information about each one, be sure to check out [Polkadot's Guide to XCM Transport](https://wiki.polkadot.com/learn/learn-xcm-transport/){target=\_blank}. ## General Message Passing {: #general-message-passing } As you know, GMP colloquially refers to cross-chain communication between Moonbeam and other blockchains outside of Polkadot. General message passing is enabled by cross-chain protocols that specialize in cross-chain communication. Each GMP provider takes a slightly different approach, but conceptually, they are quite similar. There are different contracts and functions for each provider, but each GMP provider has the same end goal: to provide secure and reliable cross-chain communication. ### Happy Path of a Cross-Chain Message {: #happy-path-of-a-cross-chain-message } At a high level, the happy path of a message sent via GMP is as follows. A user or developer will call a contract specific to the GMP protocol, sometimes referred to as a mailbox contract or a gateway contract. This call typically includes parameters like the destination chain, the destination contract address, and includes sufficient value to pay for the transaction on the destination chain. A GMP provider listens for specific events on the origin blockchain pertaining to their gateway or mailbox contracts that indicate that a user wants to send a cross-chain message using their protocol. The GMP provider will validate certain parameters, including whether or not sufficient value was provided to pay for gas on the destination chain. In fact, the GMP provider may have a decentralized network of many nodes checking the authenticity of the message and verifying parameters. The GMP provider will not validate the integrity of the contract call to be delivered on the destination chain. E.g., the GMP provider will happily deliver a valid, paid-for message that contains a smart contract call that reverts on arrival. Finally, if everything checks out according to the consensus mechanism of the GMP provider, the message will be delivered to the destination chain, triggering the respective contract call at the destination. ![Happy Path of a cross chain GMP message](/images/learn/features/xchain-plans/xchain-plans-1.webp) ### GMP Providers Integrated with Moonbeam {: #gmp-providers-integrated-with-moonbeam } A large number of GMP providers have integrated with Moonbeam, which is beneficial for several reasons. For one, it enables you to work with whichever GMP provider you prefer. Second, it means that Moonbeam is connected to a rapidly growing number of chains. Whenever a GMP provider integrated with Moonbeam adds support for another chain, Moonbeam is automatically now connected with that chain. GMP providers are constantly adding support for new chains, and it's exciting to see those new integrations benefit the Moonbeam community. Additionally, having a variety of GMP providers allows for redundancy and backup. GMP providers have occasional maintenance windows or downtime; thus, it may make sense to add support for multiple GMP providers to ensure consistent uptime. A significant number of GMP providers have integrated with Moonbeam, offering multiple benefits. Firstly, this integration allows users the flexibility to choose their preferred GMP provider. Secondly, Moonbeam's connectivity is enhanced as it automatically links with any new chains that its GMP providers support. Given that GMP providers frequently expand their support to new chains, the continuous roll out of new chains is a promising ongoing benefit for the Moonbeam community. Additionally, the diversity of GMP providers ensures better reliability and backup options. Since GMP providers can occasionally experience downtime or scheduled maintenance, the ability to integrate with multiple GMP providers is an important benefit. The following GMP providers have integrated with Moonbeam: - [Axelar](/builders/interoperability/protocols/axelar/){target=\_blank} - [Hyperlane](/builders/interoperability/protocols/hyperlane/){target=\_blank} - [LayerZero](/builders/interoperability/protocols/layerzero/){target=\_blank} - [Wormhole](/builders/interoperability/protocols/wormhole/){target=\_blank} ## Implementing Both XCM and GMP {: #implementing-both-xcm-and-gmp } Building with XCM or GMP does not preclude building with the other. As they suit different use cases, a team may seek to utilize XCM to handle interoperability needs within Polkadot, and GMP to deliver cross-chain messages to and from blockchains outside of Polkadot. As an example, several DEXes on Moonbeam support the trading of tokens migrated to Moonbeam via XCM, such as xcDOT, and assets bridged from ecosystems outside of Polkadot, such as USDC via Wormhole. ### Moonbeam Routed Liquidity {: #moonbeam-routed-liquidity } [Moonbeam Routed Liquidity](/builders/interoperability/mrl/) (MRL) enables seamless liquidity between external blockchains connected to Moonbeam via Wormhole to Polkadot parachains connected to Moonbeam via XCM. This combination of GMP and XCM means that any ERC-20 token on a chain that Wormhole has integrated with can be routed through Moonbeam to a destination parachain (and back). A diagram of the happy path of a token transfer to a parachain via MRL is shown below, and you can find more information at the [MRL docs](/builders/interoperability/mrl/). ![Happy Path of an MRL token transfer](/images/learn/features/xchain-plans/xchain-plans-2.webp)
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/code/ --- BEGIN CONTENT --- --- title: Moonbeam Source Code description: Moonbeam is an open source project in the Polkadot ecosystem, with publicly available and auditable source code. categories: Basics --- # Moonbeam Source Code Moonbeam is an open source project. The main Moonbeam repo can be found here: [:fontawesome-brands-github: https://github.com/moonbeam-foundation/moonbeam](https://github.com/moonbeam-foundation/moonbeam){target=\_blank} Moonbeam is implemented using the Substrate framework. The source code for Substrate can be found here: [:fontawesome-brands-github: https://github.com/paritytech/substrate](https://github.com/paritytech/polkadot-sdk/tree/master/substrate){target=\_blank} We also work on Ethereum compatibility features along with engineers from Parity as part of the Frontier project. Source code for Frontier can be found here: [:fontawesome-brands-github: https://github.com/polkadot-evm/frontier](https://github.com/polkadot-evm/frontier){target=\_blank} If you are interested in contributing code to Moonbeam, please raise an issue or PR on the [Moonbeam GitHub repository](https://github.com/moonbeam-foundation/moonbeam){target=\_blank} --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/links/ --- BEGIN CONTENT --- --- title: Important Moonbeam Related Links description: If you're new to Moonbeam or the Polkadot network, here are some important links to review, including compatible Ethereum tools. categories: Basics --- # Links - **[Polkadot Docs](https://docs.polkadot.com/){target=\_blank}** - starting point for learning about the [Polkadot SDK](https://docs.polkadot.com/develop/parachains/intro-polkadot-sdk/){target=\_blank}, a Rust-based framework for developing blockchains. Moonbeam is developed using Substrate and uses many of the modules that come with it - **[Polkadot.com](https://polkadot.com){target=\_blank}** - learn about Polkadot, including the vision behind the network and how the system works, i.e., staking, governance, etc. - **[Polkadot-JS Apps](https://polkadot.js.org/apps){target=\_blank}** - a web-based interface for interacting with Substrate based nodes, including Moonbeam - **[Solidity Docs](https://solidity.readthedocs.io){target=\_blank}** - Solidity is the main smart contract programming language supported by Ethereum and Moonbeam. The Solidity docs site is very comprehensive - **[Remix](https://remix.ethereum.org){target=\_blank}** - web-based IDE for Solidity smart contract development that is compatible with Moonbeam - **[Hardhat](https://hardhat.org){target=\_blank}** - development tools for Solidity, including debugging, testing, and automated deployment that is compatible with Moonbeam --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/networks/moonbase/ --- BEGIN CONTENT --- --- title: Moonbase Alpha TestNet Overview description: An overview of the current configuration of the Moonbeam TestNet, Moonbase Alpha, and information on how to start building on it using Solidity. categories: Basics --- # The Moonbase Alpha TestNet ## Goal {: #goal } The first Moonbeam TestNet, named Moonbase Alpha, aims to provide developers with a place to start experimenting and building on Moonbeam in a shared environment. Since Moonbeam is deployed as a parachain on Kusama and Polkadot, the goal of the TestNet is to reflect the production configurations. For this reason, it was decided that it needed to be a parachain-based configuration rather than a Substrate development setup. In order to collect as much feedback as possible and provide fast issue resolution, please join the [Moonbeam Discord](https://discord.com/invite/PfpUATX){target=\_blank}. ## Initial Configuration {: #initial-configuration } Moonbase Alpha has the following configuration: - Runs as a parachain connected to a relay chain - Has an active set of {{ networks.moonbase.staking.max_candidates }} collator nodes run by the community - The relay chain hosts validators to finalize relay chain blocks. One of them is selected to finalize each block collated by Moonbeam's collators. This setup provides room to expand to a two-parachain configuration in the future - Has infrastructure providers that provide [API endpoints](/builders/get-started/endpoints/){target=\_blank} to connect to the network. Projects can also [run their own node](/node-operators/networks/run-a-node/){target=\_blank} to have access to their own private endpoints ![TestNet Diagram](/images/learn/platform/networks/moonbase-diagram.webp) Some important variables/configurations to note include: === "General" | Variable | Value | |:---------------------:|:------------------------------------------:| | Minimum gas price | {{ networks.moonbase.min_gas_price }} Gwei | | Target block time | {{ networks.moonbase.block_time }} seconds | | Block gas limit | {{ networks.moonbase.gas_block }} | | Transaction gas limit | {{ networks.moonbase.gas_tx }} | === "Staking" | Variable | Value | |:---------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------:| | Minimum delegation stake | {{ networks.moonbase.staking.min_del_stake }} DEV | | Maximum delegators per candidates | {{ networks.moonbase.staking.max_del_per_can }} | | Maximum delegations per account | {{ networks.moonbase.staking.max_del_per_del }} | | Round | {{ networks.moonbase.staking.round_blocks }} blocks ({{ networks.moonbase.staking.round_hours }} hour) | | Bond duration | Delegations take effect in the next round; funds are withdrawn immediately | | Unbond duration | {{ networks.moonbase.delegator_timings.del_bond_less.rounds }} rounds ({{ networks.moonbase.delegator_timings.del_bond_less.hours }} hours) | !!! note As of runtime 3000, [asynchronous backing](https://wiki.polkadot.com/learn/learn-async-backing/#asynchronous-backing){target=\_blank} has been enabled on all Moonbeam networks. As a result, the target block time was reduced from 12 seconds to 6 seconds, which may break some timing-based assumptions. Additionally, as of runtime 2900, the block and transaction gas limits increased by 4x on Moonbase Alpha. ## Network Endpoints {: #network-endpoints } Moonbase Alpha has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints. === "HTTPS" | Provider | RPC URL | Limits | |:-------------------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam-alpha.api.onfinality.io/public```
| 40 req/sec | | Moonbeam Foundation |
```https://rpc.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```https://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbase.public.curie.radiumblock.co/http```
| 200 req/sec | === "WSS" | Provider | RPC URL | Limits | |:-------------------:|:-----------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam-alpha.api.onfinality.io/public-ws```
| 40 req/sec | | Moonbeam Foundation |
```wss://wss.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```wss://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbase.public.curie.radiumblock.co/ws```
| 200 req/sec | #### Relay Chain {: #relay-chain } To connect to the Moonbase Alpha relay chain, you can use the following WS Endpoint: | Provider | RPC URL | |:--------:|:----------------------------------------------------------:| | OpsLayer |
```wss://relay.api.moonbase.moonbeam.network```
| ## Quick Start {: #quick-start } For the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonbase Alpha (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonbase Alpha as provider const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonbase Alpha: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'https://rpc.api.moonbase.moonbeam.network'; // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1287, name: 'moonbase-alphanet' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonbase Alpha TestNet chain ID is: `1287`, which is `0x507` in hex. ## Alphanet Relay Chain {: #relay-chain } The Alphanet relay chain is connected to Moonbase Alpha and is [Westend](https://polkadot.com/blog/westend-introducing-a-new-testnet-for-polkadot-and-kusama){target=\_blank}-based but unique to the Moonbeam ecosystem. It resembles how you would interact with Kusama or Polkadot. The native tokens of the Alphanet relay chain are UNIT tokens, which are for testing purposes only and have no real value. ## Telemetry {: #telemetry } You can see current Moonbase Alpha telemetry information by visiting [Polkadot's Telemetry dashboard](https://telemetry.polkadot.io/#list/0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527){target=\_blank}. ## Tokens {: #tokens } Tokens on Moonbase Alpha, named DEV, will be issued on demand. **DEV tokens hold no value and can be freely acquired**. You can enter your address to automatically request DEV tokens from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} website. The faucet dispenses {{ networks.moonbase.website_faucet_amount }} every 24 hours. For token requests of more than the limited amount allowed by the faucet, contact a moderator directly via the [Moonbeam Discord server](https://discord.com/invite/PfpUATX){target=\_blank}. We are happy to provide the tokens needed to test your applications. ## Proof of Stake {: #proof-of-stake } The Moonbase Alpha TestNet is a fully decentralized Delegated Proof of Stake network where users of the network can delegate collator candidates to produce blocks and "earn rewards" for testing purposes. Please note, that the Moonbase Alpha DEV tokens have no real value. The number of candidates in the active set will be subject to governance. The active set will consist of the top candidates by stake, including delegations. ## Limitations {: #limitations } This is the first TestNet for Moonbeam, so there are some limitations. Some [precompiles](https://www.evm.codes/precompiled){target=\_blank} are yet to be included. You can check out the list of supported precompiles on the [Canonical Contract page](/builders/ethereum/precompiles/){target=\_blank}. However, all built-in functions are available. Since the release of Moonbase Alpha v6, the maximum gas limit per block has been set to {{ networks.moonbase.gas_block }}, with a maximum gas limit per transaction of {{ networks.moonbase.gas_tx }}. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/networks/moonbeam/ --- BEGIN CONTENT --- --- title: Moonbeam Network Overview description: An overview of the current configuration of the Moonbeam deployment on Polkadot, Moonbeam, and information on how to start building on it using Solidity. categories: Basics --- # Moonbeam ## Goal {: #goal } Moonbeam was onboarded as a parachain to Polkadot on December 17th 2021. Moonbeam is the most Ethereum compatible smart-contract parachain in the Polkadot ecosystem. It allows developers to port their projects with minimal to no code changes, enabling them to tap into the Polkadot ecosystem and all its assets. In order to collect as much feedback as possible and provide fast issue resolution, you can check out the dedicated [Moonbeam Network section on Discord](https://discord.com/invite/PfpUATX){target=\_blank}. ## Initial Configurations {: #initial-configurations } Currently, Moonbeam has the following configurations: - Runs as a parachain connected to the Polkadot relay chain - Has an active set of {{ networks.moonbeam.staking.max_candidates }} collators - Has infrastructure providers that provide [API endpoints](/builders/get-started/endpoints/){target=\_blank} to connect to the network. Projects can also [run their own node](/node-operators/networks/run-a-node/){target=\_blank} to have access to their own private endpoints ![Moonbeam Diagram](/images/learn/platform/networks/moonbeam-diagram.webp) Some important variables/configurations to note include (still subject to change): === "General" | Variable | Value | |:---------------------:|:-----------------------------------------------------------------------:| | Minimum gas price | {{ networks.moonbeam.min_gas_price }} Gwei* | | Target block time | {{ networks.moonbeam.block_time }} seconds | | Block gas limit | {{ networks.moonbeam.gas_block }} | | Transaction gas limit | {{ networks.moonbeam.gas_tx }} | === "Staking" | Variable | Value | |:---------------------------------:|:-------------------------------------------------------------------------------------------------------:| | Minimum delegation stake | {{ networks.moonbeam.staking.min_del_stake }} GLMR | | Maximum delegators per candidates | {{ networks.moonbeam.staking.max_del_per_can }} | | Maximum delegations per account | {{ networks.moonbeam.staking.max_del_per_del }} | | Round | {{ networks.moonbeam.staking.round_blocks }} blocks ({{ networks.moonbeam.staking.round_hours }} hours) | | Bond duration | delegation takes effect in the next round (funds are withdrawn immediately) | | Unbond duration | {{ networks.moonbeam.delegator_timings.del_bond_less.rounds }} rounds | _*Read more about [token denominations](#token-denominations)_ ## Network Endpoints {: #network-endpoints } Moonbeam has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints: === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbeam.public.curie.radiumblock.co/http```
| 200 req/sec | | 1RPC |
```https://1rpc.io/glmr```
| 10k req/day | | Grove |
```https://moonbeam.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:--------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbeam.public.curie.radiumblock.co/ws```
| 200 req/sec | | 1RPC |
```wss://1rpc.io/glmr```
| 10k req/day | ## Quick Start {: #quick-start } Before getting started, make sure you've retrieved your own endpoint and API key from one of the custom [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. Then for the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonbeam (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonbeam as provider const web3 = new Web3('INSERT_RPC_API_ENDPOINT'); // Insert your RPC URL here ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonbeam: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'INSERT_RPC_API_ENDPOINT'; // Insert your RPC URL here // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1284, name: 'moonbeam' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonbeam chain ID is: `1284`, or `0x504` in hex. ## Telemetry {: #telemetry } You can see current Moonbeam telemetry information by visiting [Polkadot's Telemetry dashboard](https://telemetry.polkadot.io/#list/0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d){target=\_blank}. ## Tokens {: #tokens } The tokens on Moonbeam are called Glimmer (GLMR). Check out the Moonbeam Foundation site for more information on the [Glimmer](https://moonbeam.foundation/glimmer-token-tokenomics){target=\_blank} token. ### Token Denominations {: #token-denominations } The smallest unit of Glimmer (GMLR), similarly to Ethereum, is a Wei. It takes 10^18 Wei to make one Glimmer. The denominations are as follows: | Unit | Glimmer (GLMR) | Wei | |:---------:|:--------------------:|:-----------------------------:| | Wei | 0.000000000000000001 | 1 | | Kilowei | 0.000000000000001 | 1,000 | | Megawei | 0.000000000001 | 1,000,000 | | Gigawei | 0.000000001 | 1,000,000,000 | | Microglmr | 0.000001 | 1,000,000,000,000 | | Milliglmr | 0.001 | 1,000,000,000,000,000 | | GLMR | 1 | 1,000,000,000,000,000,000 | | Kiloglmr | 1,000 | 1,000,000,000,000,000,000,000 | ## Proof of Stake {: #proof-of-stake } The Moonriver network is a fully decentralized Delegated Proof of Stake network where users of the network can delegate collator candidates to produce blocks and earn rewards. It uses the [Nimbus framework](/learn/features/consensus/){target=\_blank} framework for parachain consensus. The number of candidates in the active set will be subject to governance. The active set will consist of the top candidates by stake, including delegations. ## Limitations {: #limitations } Some [precompiles](https://www.evm.codes/precompiled){target=\_blank} are yet to be included. You can check a list of supported precompiles on the [Solidity Precompiles page](/builders/ethereum/precompiles/overview/){target=\_blank}. However, all built-in functions are available. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/networks/moonriver/ --- BEGIN CONTENT --- --- title: Moonriver Overview description: An overview of the current configuration of the Moonbeam deployment on Kusama, Moonriver, and information on how to start building on it using Solidity. categories: Basics --- # Moonriver ## Goal {: #goal } In June 2021, Moonriver was first launched as a parachain on the Kusama network. Moonriver is a sister network of Moonbeam, and provides an environment to test new code under real economic conditions. Developers now have access to start building on an incentivized canary network connected to Kusama. In order to collect as much feedback as possible and provide fast issue resolution, you can check out the dedicated [Moonriver section on Discord](https://discord.com/invite/5TaUvbRvgM){target=\_blank}. ## Initial Configurations {: #initial-configurations } Currently, Moonriver has the following configurations: - Runs as a parachain connected to the Kusama relay chain - Has an active set of {{ networks.moonriver.staking.max_candidates }} collators - Has infrastructure providers that provide [API endpoints](/builders/get-started/endpoints/){target=\_blank} to connect to the network. Projects can also [run their own node](/node-operators/networks/run-a-node/){target=\_blank} to have access to their own private endpoints ![Moonriver Diagram](/images/learn/platform/networks/moonriver-diagram.webp) Some important variables/configurations to note include: === "General" | Variable | Value | |:---------------------:|:--------------------------------------------:| | Minimum gas price | {{ networks.moonriver.min_gas_price }} Gwei* | | Target block time | {{ networks.moonriver.block_time }} seconds | | Block gas limit | {{ networks.moonriver.gas_block }} | | Transaction gas limit | {{ networks.moonriver.gas_tx }} | === "Staking" | Variable | Value | |:---------------------------------:|:---------------------------------------------------------------------------------------------------------:| | Minimum delegation stake | {{ networks.moonriver.staking.min_del_stake }} MOVR | | Maximum delegators per candidates | {{ networks.moonriver.staking.max_del_per_can }} | | Maximum delegations per account | {{ networks.moonriver.staking.max_del_per_del }} | | Round | {{ networks.moonriver.staking.round_blocks }} blocks ({{ networks.moonriver.staking.round_hours }} hours) | | Bond duration | delegation takes effect in the next round (funds are withdrawn immediately) | | Unbond duration | {{ networks.moonriver.delegator_timings.del_bond_less.rounds }} rounds | _*Read more about [token denominations](#token-denominations)_ !!! note As of runtime 3000, [asynchronous backing](https://wiki.polkadot.com/learn/learn-async-backing/#asynchronous-backing){target=\_blank} has been enabled on all Moonbeam networks. As a result, the target block time was reduced from 12 seconds to 6 seconds, which may break some timing-based assumptions. Additionally, the block and transaction gas limits increased by 4x on Moonriver. ## Network Endpoints {: #network-endpoints } Moonriver has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints: === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:-------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonriver.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonriver.public.curie.radiumblock.co/http```
| 200 req/sec | | Grove |
```https://moonriver.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:---------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonriver.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonriver.public.curie.radiumblock.co/ws```
| 200 req/sec | ## Quick Start {: #quick-start } Before getting started, make sure you've retrieved your own endpoint and API key from one of the custom [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. Then for the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonriver (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonriver as provider const web3 = new Web3('INSERT_RPC_API_ENDPOINT'); // Insert your RPC URL here ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonriver: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'INSERT_RPC_API_ENDPOINT'; // Insert your RPC URL here // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1285, name: 'moonriver' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonriver chain ID is: `1285`, or `0x505` in hex. ## Telemetry {: #telemetry } You can see current Moonriver telemetry information by visiting [Polkadot's Telemetry dashboard](https://telemetry.polkadot.io/#list/0x401a1f9dca3da46f5c4091016c8a2f26dcea05865116b286f60f668207d1474b){target=\_blank}. ## Tokens {: #tokens } The tokens on Moonriver will also be called Moonriver (MOVR). Check out the Moonbeam Foundation site for more information on the [Moonriver token](https://moonbeam.foundation/moonriver-token-tokenomics){target=\_blank}. ### Token Denominations {: #token-denominations } The smallest unit of Moonriver, similarly to Ethereum, is a Wei. It takes 10^18 Wei to make one Moonriver. The denominations are as follows: | Unit | Moonriver (MOVR) | Wei | |:--------------:|:--------------------:|:-----------------------------:| | Wei | 0.000000000000000001 | 1 | | Kilowei | 0.000000000000001 | 1,000 | | Megawei | 0.000000000001 | 1,000,000 | | Gigawei | 0.000000001 | 1,000,000,000 | | Micromoonriver | 0.000001 | 1,000,000,000,000 | | Millimoonriver | 0.001 | 1,000,000,000,000,000 | | Moonriver | 1 | 1,000,000,000,000,000,000 | | Kilomoonriver | 1,000 | 1,000,000,000,000,000,000,000 | ## Proof of Stake {: #proof-of-stake } The Moonriver network is a fully decentralized Delegated Proof of Stake network where users of the network can delegate collator candidates to produce blocks and earn rewards. It uses the [Nimbus framework](/learn/features/consensus/){target=\_blank} framework for parachain consensus. The number of candidates in the active set will be subject to governance. The active set will consist of the top candidates by stake, including delegations. ## Limitations {: #limitations } Some [precompiles](https://www.evm.codes/precompiled){target=\_blank} are yet to be included. You can check a list of supported precompiles on the [Canonical Contract page](/builders/ethereum/precompiles/){target=\_blank}. However, all built-in functions are available. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/networks/overview/ --- BEGIN CONTENT --- --- title: Overview of Networks description: An overview of all of the MainNet and TestNet deployments of Moonbeam, an Ethereum-compatible smart contract parachain on Polkadot and Kusama. categories: Basics --- # Networks There are multiple long-lived Moonbeam-based networks. Most significantly, there is the Moonbeam deployment on Polkadot and Kusama. An overview of our parachain deployments is as follows: - Moonbeam: deployment on Polkadot (_December 2021_) - Moonriver: deployment on Kusama (_June 2021_) - Moonbase Alpha: Parachain TestNet for Moonbeam and Moonriver (_September 2020_) This strategy allows us to de-risk software upgrades to Moonbeam on the Polkadot MainNet while still maintaining a reasonable update velocity. ## Moonbeam {: #moonbeam } The Moonbeam production MainNet is a parachain on Polkadot and has been since December 17th, 2021. Moonbeam features the highest levels of security and availability. Code running on the MainNet has generally been vetted through one or more of the other networks listed above. Moonbeam will offer parachain-related functionalities such as [XCMP](https://wiki.polkadot.com/learn/learn-xcm-transport/#xcmp-cross-chain-message-passing){target=\_blank} and [SPREE](https://wiki.polkadot.com/learn/learn-spree/){target=\_blank} as these features become available. [Learn more about Moonbeam](/learn/platform/networks/moonbeam/). ## Moonriver {: #moonriver } In advance of deploying to the Polkadot MainNet, [Moonbeam launched Moonriver](https://moonbeam.network/news/moonriver-won-a-parachain-slot-and-is-now-producing-blocks-on-the-kusama-network){target=\_blank} as a parachain on the Kusama network. The parachain functionality is live on Kusama. Moonriver will offer parachain-related functionalities such as [XCMP](https://wiki.polkadot.com/learn/learn-xcm-transport/#xcmp-cross-chain-message-passing){target=\_blank} and [SPREE](https://wiki.polkadot.com/learn/learn-spree/){target=\_blank} as these features become available. [Learn more about Moonriver](/learn/platform/networks/moonriver/). ## Moonbase Alpha {: #moonbase-alpha } This TestNet is a network hosted by OpsLayer. It features a parachain/relay chain scheme. The goal is to allow developers to test the Ethereum compatibility features of Moonbeam in a shared parachain environment without needing to run their own nodes or network. [Learn more about Moonbase Alpha](/learn/platform/networks/moonbase/). --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/technology/ --- BEGIN CONTENT --- --- title: Technology & Architecture description: Moonbeam is built using Rust and Polkadot's Substrate framework, enabling rich tools for implementation while allowing for specialization and optimization. categories: Basics --- # Technology & Architecture ## The Moonbeam Development Stack {: #the-moonbeam-development-stack } Moonbeam is a smart contract blockchain platform built in the Rust programming language using the Substrate framework. Substrate, developed by [Parity Technologies](https://www.parity.io/){target=_blank} (the original founding contributors of Polkadot), is an open-source, modular SDK for creating blockchains. Substrate allows developers to customize their blockchains while still benefiting from features such as forkless upgrades, shared security (when connected as a parachain to Polkadot or Kusama), and an extensive library of pre-built runtime modules known as pallets. ### Rust Programming Language {: #rust-programming-language } Rust is a good language for implementing a blockchain. It is highly performant like C and C++ but has built-in memory safety features enforced at compile time, preventing many common bugs and security issues arising from C and C++ implementations. ### Substrate Framework {: #substrate-framework } Substrate provides a rich set of tools for creating blockchains, including a runtime execution environment that enables a generic state transition function and a pluggable set of modules (pallets) that implement various blockchain subsystems. By using Substrate, Moonbeam can leverage several key features offered to parachains launched on the Polkadot relay chain, including: - **Shared security** — Polkadot's validators secure all parachains - **Cross-Consensus Messaging (XCM)** — native interoperability with other parachains - **Flexible upgrades** — Substrate’s forkless upgrade mechanism Pallets are at the heart of Substrate-based chains, providing specific functionality in modular form. Examples include: - **Balances pallet** — manages account balances and transfers - **Assets pallet** — handles the creation and management of on-chain fungible assets - **Consensus pallets** — provide mechanisms like AURA or BABE for block production - **Governance pallets** — facilitate on-chain governance - **Frontier pallets** — the Ethereum compatibility layer pioneered by the Moonbeam team - **Parachain Staking pallet** — enables Delegated Proof of Stake (DPoS) In addition to these pallets provided by Polkadot's Substrate, developers can [create their own pallets](https://docs.polkadot.com/develop/parachains/customize-parachain/make-custom-pallet/){target=_blank} to add custom functionality. Moonbeam leverages multiple existing Substrate frame pallets as well as several custom pallets for features such as cross-chain token integration, the [Orbiter Program](/node-operators/networks/collators/orbiter/){target=_blank}, and more. You can find the Moonbeam runtime (built using Substrate) and related pallets in the [Moonbeam GitHub repository](https://github.com/moonbeam-foundation/moonbeam){target=_blank}. Moonbeam also uses the Cumulus library to facilitate integration with the Polkadot relay chain. ### Frontier: Substrate's Ethereum Compatibility Layer {: #frontier } [Frontier](https://polkadot-evm.github.io/frontier){target=\_blank} serves as Substrate's Ethereum compatibility layer, facilitating the seamless operation of standard Ethereum DApps on Substrate-based chains without requiring modifications. This compatibility is achieved by integrating specialized Substrate pallets into the Substrate runtime. These pallets include: - **EVM pallet** — responsible for executing EVM operations - **Ethereum pallet** — manages block data storage and offers RPC compatibility - **Base Fee pallet and Dynamic Fee pallet** — provide EIP-1559 functionality (not used in Moonbeam) Moonbeam uses the EVM and Ethereum pallets to achieve full Ethereum compatibility. Instead of the Base Fee or Dynamic Fee pallets, Moonbeam has its own [dynamic fee mechanism](https://forum.moonbeam.network/t/proposal-dynamic-fee-mechanism-for-moonbeam-and-moonriver/241){target=\_blank} for base fee calculations. Basing the EVM implementation on the Substrate EVM Pallet provides a Rust-based EVM engine and support from the Parity engineering team. ## Blockchain Runtime {: #blockchain-runtime } The core Moonbeam runtime specifies the state transition function and behavior of the Moonbeam blockchain. The runtime is built using [FRAME](/learn/platform/glossary/#substrate-frame-pallets){target=\_blank}, compiled to a [WebAssembly (Wasm)](/learn/platform/glossary/#webassemblywasm){target=\_blank} binary as well as a native binary. These compiled versions are executed in the Polkadot relay chain and Moonbeam node environments. !!! note Substrate FRAME pallets are a collection of Rust-based modules that provide the functionality required when building a blockchain. WebAssembly is an open standard that defines a portable binary code format. Different programming languages, compilers, and browsers support it. Find more definitions [in our glossary](/learn/platform/glossary/){target=\_blank}. Some of the key Substrate FRAME pallets used in the Moonbeam runtime include: - **Balances** — support for accounts, balances, and transfers - **EVM** — a full Rust-based EVM implementation based on SputnikVM (part of Frontier) - **Ethereum** — provides emulation of Ethereum block processing for the EVM (part of Frontier) - **Executive** — orchestration layer that dispatches calls to other runtime modules - **Identity** — support for setting on-chain identities for account addresses - **System** — provides low-level types, storage, and blockchain functions - **Treasury** — on-chain treasury that can be used to fund public goods such as a parachain slot In addition to these Substrate FRAME Pallets, Moonbeam implements custom pallets to achieve additional functionality, such as: - **Parachain Staking** — enables a Delegated Proof of Stake (DPoS) system - **Moonbeam Orbiters** — supports the [Orbiter Program](/node-operators/networks/collators/orbiter/){target=\_blank}, which diversifies the collator pool - **XCM Transactor** — simplifies remote cross-chain calls via [Cross-Consensus Messaging (XCM)](/builders/interoperability/xcm/overview/){target=\_blank} - **Asset Manager** — registers XCM assets ### Forkless Upgrades {: #forkless-upgrades } One of the best things about developing on Polkadot with Substrate is the ability to introduce [forkless upgrades](https://docs.polkadot.com/develop/parachains/maintenance/runtime-upgrades/){target=_blank} to blockchain runtimes. In traditional blockchain architectures, substantial changes to the blockchain's rules often require a hard fork, which can be disruptive and contentious. Substrate takes a different approach by separating the blockchain's state (data) from its logic (rules). Logic lives in the runtime, which is itself stored on-chain. Whenever a new runtime is uploaded (via FRAME's `set_code` call) and approved through on-chain governance, all nodes automatically switch to the new runtime at a specified block. This process is seamless and does not split the network. Moonbeam regularly uses forkless upgrades to add features or fixes without requiring node operators to upgrade their software manually. You can keep track of and discuss upcoming Moonbeam upgrades on the [Moonbeam forum](https://forum.moonbeam.network){target=_blank}. ## Ethereum Compatibility Architecture {: #ethereum-compatibility-architecture } Smart contracts on Moonbeam can be implemented using Solidity, Vyper, and any other language that compiles smart contracts to EVM-compatible bytecode. Moonbeam aims to provide a low-friction and secure environment for the development, testing, and execution of smart contracts while remaining compatible with the existing Ethereum developer toolchain. The execution behavior and semantics of Moonbeam-based smart contracts strive to be as close as possible to Ethereum Layer 1. Moonbeam is a single shard, so cross-contract calls have the same synchronous execution semantics as on Ethereum Layer 1. ![Diagram showing the interactions made possible through Moonbeam's Ethereum compatibility](/images/learn/platform/technology-diagram.webp) A high-level interaction flow is shown above. A Web3 RPC call from a DApp or existing Ethereum developer tool, such as Hardhat, is received by a Moonbeam node. The node has both Web3 RPCs and Substrate RPCs available, meaning you can use Ethereum or Substrate tools when interacting with a Moonbeam node. Associated Substrate runtime functions handle these RPC calls. The Substrate runtime checks signatures and handles any extrinsics. Smart contract calls are ultimately passed to the EVM to execute the state transitions. ### Ethereum Pallet {: #ethereum-pallet} The [Ethereum pallet](https://polkadot-evm.github.io/frontier/overview){target=\_blank} is responsible for handling blocks and transaction receipts and statuses. It enables sending and receiving Ethereum-formatted data to and from Moonbeam by storing an Ethereum-style block and its associated transaction hashes in the Substrate runtime. When a user submits a raw Ethereum transaction, it converts into a Substrate transaction through the Ethereum pallet's `transact` extrinsic—using the Ethereum pallet as the sole executor of the EVM pallet forces all of the data to be stored and transacted in an Ethereum-compatible way, which is how explorers like [Moonscan](/builders/get-started/explorers/#moonscan){target=\_blank} (built by Etherscan) can index block data. ### EVM Pallet {: #evm-pallet } The [EVM pallet](https://polkadot-evm.github.io/frontier/overview){target=\_blank} implements a sandboxed virtual stack machine and uses the [SputnikVM](https://github.com/rust-ethereum/evm){target=\_blank} as the underlying EVM engine. It executes Ethereum smart contract bytecode in a manner similar to Ethereum mainnet, including gas metering and state changes. Moonbeam uses unified accounts, meaning an H160 (Ethereum-style) address is also a valid Substrate address, so you only need a single account to interact with the Substrate runtime and the EVM. Once a balance exists in the EVM, smart contracts can be created and interacted with through standard Ethereum RPC calls. The EVM pallet should produce nearly identical execution results to Ethereum, such as gas cost and balance changes. However, there are some differences. Although the EVM pallet aims for near-identical behavior to Ethereum, some differences exist, for example, Moonbeam's [dynamic fee mechanism](https://forum.moonbeam.network/t/proposal-dynamic-fee-mechanism-for-moonbeam-and-moonriver/241){target=\_blank}. For more information, refer to the [Frontier EVM Pallet documentation](https://polkadot-evm.github.io/frontier/){target=\_blank}. Moonbeam includes additional EVM precompiles for functionalities like cryptographic operations (ECRecover, SHA256, BLAKE2, BN128) and dispatching Substrate calls directly from within the EVM. Moonbeam uses the following EVM precompiles: - **[pallet-evm-precompile-simple](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple){target=\_blank}** - includes five basic precompiles: ECRecover, ECRecoverPublicKey, Identity, RIPEMD160, SHA256 - **[pallet-evm-precompile-blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank}** - includes the BLAKE2 precompile - **[pallet-evm-precompile-bn128](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_bn128/index.html){target=\_blank}** - includes three BN128 precompiles: BN128Add, BN128Mul, and BN128Pairing - **[pallet-evm-precompile-modexp](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_modexp/struct.Modexp.html){target=\_blank}** - includes the modular exponentiation precompile - **[pallet-evm-precompile-sha3fips](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_sha3fips/struct.Sha3FIPS256.html){target=\_blank}** -includes the standard SHA3 precompile - **[pallet-evm-precompile-dispatch](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_dispatch/struct.Dispatch.html){target=\_blank}** - includes the dispatch precompile You can find an overview of most of these precompiles on the [Ethereum MainNet Precompiled Contracts](/builders/ethereum/precompiles/utility/eth-mainnet/){target=\_blank} page. ## Native Interoperability {: #native-interoperability } While Substrate allows developers to create blockchains, one of its most significant advantages is that it supports integration for native interoperability through relay chains like Polkadot and Kusama. A relay chain is a central chain that connects several blockchains, known as parachains. Each parachain is a distinct blockchain with its runtime and state, but all are connected to and secured by the relay chain. Once connected, parachains can communicate via [Cross-Consensus Messaging (XCM)](/builders/interoperability/xcm/overview/){target=_blank} to exchange information and conduct transactions in the same language, enabling a wide range of interoperable applications. Moonbeam and Moonriver have established XCM connections with a large number of parachains. You can see a visualization of all XCM integrations in this [XCM Channel Viewer](https://dotsama-channels.vercel.app/#/){target=_blank}. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/tokens/ --- BEGIN CONTENT --- --- title: Utility Tokens description: Each of the Moonbeam networks require a utility token to function. Glimmer (GLMR) for Moonbeam on Polkadot and Moonriver (MOVR) for Moonriver on Kusama. categories: Basics --- # Introduction As a decentralized smart contract platform, Moonbeam requires a utility token to function. This token is central to the design of Moonbeam and cannot be removed without sacrificing essential functionality. The Moonbeam token uses include: - Supporting the gas metering of smart contract execution - Incentivizing collators and powering the mechanics around the creation of a decentralized node infrastructure on which the platform can run - Facilitating the on-chain governance mechanism, including proposing referenda, electing council members, voting, etc. - Paying for network transaction fees ## Glimmer Token {: #glimmer-token } In the Moonbeam deployment on Polkadot MainNet, this token is called Glimmer, as in, “that smart contract call will cost 0.3 Glimmer.” The token symbol is GLMR. You can find more information about Glimmer on the [Moonbeam Foundation](https://moonbeam.foundation/glimmer-token-tokenomics) website. ## Moonriver Token {: #moonriver-token } In the Moonbeam deployment on Kusama (called Moonriver), this token is called Moonriver, as in, “that smart contract call will cost 0.003 Moonriver.” The token symbol will be MOVR. You can find more information about Moonriver on the [Moonbeam Foundation](https://moonbeam.foundation/moonriver-token-tokenomics) website. ## DEV Token {: #dev-token } In the Moonbeam TestNet (called Moonbase Alpha), the token is called DEV. This token can be acquired freely, as its only purpose is to drive development and testing on Moonbase Alpha. You can get DEV tokens for testing on Moonbase Alpha once every 24 hours from the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank}. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/vision/ --- BEGIN CONTENT --- --- title: The Moonbeam Vision | Multi-chain description: Moonbeam is designed to enable a multi-chain future, where users and assets can move freely across many specialized and heterogeneous chains. categories: Basics --- # Our Vision for Moonbeam We believe in a multi-chain future with many chains, and many users and assets on those chains. In this context, we have created Moonbeam: a smart contract platform that provides an Ethereum-compatible environment for building decentralized applications. Moonbeam was designed to serve these new kinds of assets and users that exist across two or more chains. Existing smart contract platforms are designed to service the users and assets on a single, specific chain. By providing cross-chain smart contract functionality, Moonbeam allows developers to shift existing workloads and logic to Moonbeam and extend the reach of their applications to new users and assets on other chains. Moonbeam's cross-chain integration is accomplished by becoming a [parachain](/learn/platform/glossary/#parachains) on the Polkadot network. The [Polkadot network](/learn/platform/glossary/#polkadot) provides integration and connectivity between parachains that are connected to the network and to other non-Polkadot-based chains, such as Ethereum and Bitcoin, via bridges. ## Who Benefits From Moonbeam {: #who-benefits-from-moonbeam } There are three main audiences who can most benefit from Moonbeam's cross-chain functionality: ### Existing Ethereum-Based Projects {: #existing-ethereum-based-projects } Projects that are struggling with cost and scalability challenges on Ethereum can use Moonbeam to: - Move portions of their existing workloads and state off of Ethereum Layer 1 with minimal required changes. - Implement a hybrid approach, where applications live on both Ethereum and Moonbeam simultaneously. - Extend their reach to the Polkadot network and other chains that are connected to Polkadot. ### Polkadot Ecosystem Projects {: #polkadot-ecosystem-projects } Ecosystem projects that need smart contract functionality can use Moonbeam to: - Augment their existing parachains and parathreads. - Add new functionality that is needed but not included on the main [Polkadot relay chain](/learn/platform/glossary/#relay-chain). For example, they could create a place where teams can crowdfund their projects, implement lockdrops, and process other, more complex financial transactions than are provided by base [Substrate](/learn/platform/glossary/#substrate) functionality. - Leverage the mature and extensive Ethereum development toolchain. ### Developers of New DApps {: #developers-of-new-dapps } Individuals and teams that want to try building on Polkadot can use Moonbeam to: - Leverage the specialized functionality from Polkadot parachains while reaching users and assets on other chains. - Compose functionality from Polkadot parachains by using Moonbeam as a lightweight integration layer that aggregates network services before presenting them to end users. Implementing a composed service using pre-built integrations on a smart contract platform will be a lot faster and easier (in many cases) than building a full Substrate runtime and performing the integrations yourself in the runtime. ## Key Features and Functionality {: #key-features-and-functionality } Moonbeam achieves these goals with the following key features: - **Decentralized and Permissionless** , providing a base requirement for censorship resistance and support for many existing and future DApp use cases. - **Contains a Full EVM Implementation** , enabling Solidity-based smart contracts to be migrated with minimal change and with expected execution results. - **Implements the Web3 RPC API** so that existing DApp front-ends can be migrated with minimal change required, and so existing Ethereum-based tools, such as Hardhat, Remix, and MetaMask, can be used without modification against Moonbeam. - **Compatible with the Substrate Ecosystem Toolset** , including block explorers, front-end development libraries, and wallets, allowing developers and users to use the right tool for what they are trying to accomplish. - **Native Cross-Chain Integration** via the Polkadot network and via token bridges, which allows for token movement, state visibility, and message passing with Ethereum and other chains. - **On-Chain Governance** to allow stakeholders to quickly and forklessly evolve the base protocol according to developer and community needs. This unique combination of elements fills a strategic market gap, while allowing Moonbeam to address future developer needs as the Polkadot network grows over time. Building your own chain with Substrate is powerful, but also comes with a number of additional responsibilities, such as learning and implementing the chain’s runtime in Rust, creating a token economy, and incentivizing a community of node operators. For many developers and projects, an Ethereum-compatible smart contract approach will be much simpler and faster to implement. And by building these smart contracts on Moonbeam, developers can still integrate with other chains and get value from Polkadot-based network effects. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/why-polkadot/ --- BEGIN CONTENT --- --- title: Why Polkadot description: Moonbeam is built on the Substrate framework and connected to the Polkadot network, adding speed and security to the platform. categories: Basics --- # Why We're Building on Polkadot After extensive research, we decided to build Moonbeam using the [Substrate development framework](/learn/platform/glossary/#substrate) and to deploy Moonbeam as a [parachain](/learn/platform/glossary/#parachains) on the [Polkadot network](/learn/platform/glossary/#polkadot). ## Substrate Blockchain Framework {: #substrate-blockchain-framework } Substrate is a good technical fit for Moonbeam. By building on top of this framework, we can leverage the extensive functionality that Substrate includes out-of-the-box, rather than building it ourselves. This includes peer-to-peer networking, consensus mechanisms, governance functionality, an EVM implementation, and more. Overall, using Substrate will dramatically reduce the time and implementation effort needed to implement Moonbeam. Substrate allows a great degree of customization, which is necessary in order to achieve our Ethereum compatibility goals. And, by using Rust, we benefit from both safety guarantees and performance gains. ## Polkadot Network and Ecosystem {: #polkadot-network-and-ecosystem } The Polkadot network is also a good fit for Moonbeam. As a parachain on Polkadot, Moonbeam will be able to directly integrate with — and move tokens between — any other parachains and parathreads on the network. We can also leverage any of the bridges that are independently built to connect non-Polkadot chains to Polkadot, including bridges to Ethereum. Polkadot’s interoperability model uniquely supports Moonbeam’s cross-chain integration goals and is a key enabling technology to support the Moonbeam vision. But perhaps just as important as the technical criteria above, we are impressed with the people in the Polkadot ecosystem. This includes individuals at Parity, the Web3 Foundation, and other projects in the ecosystem. We have built many valuable relationships and find the people to be both extremely talented and the kind of people we want to be around. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/dev-env/openzeppelin/overview/ --- BEGIN CONTENT --- --- title: An Overview of OpenZeppelin on Moonbeam description: Learn how to use OpenZeppelin products for creating and managing Solidity smart contracts on Moonbeam, thanks to its Ethereum compatibility features. categories: Basics, Ethereum Toolkit --- # OpenZeppelin ## Introduction {: #introduction } [OpenZeppelin](https://www.openzeppelin.com){target=\_blank} is well known in the Ethereum developer community as their set of audited smart contracts and libraries are a standard in the industry. For example, most of the tutorials that show developers how to deploy an ERC-20 token use OpenZeppelin contracts. You can find more information about OpenZeppelin on their [documentation site](https://docs.openzeppelin.com){target=\_blank}. As part of its Ethereum compatibility features, OpenZeppelin products can be seamlessly used on Moonbeam. This page will provide information on different OpenZeppelin solutions that you can test. ## OpenZeppelin on Moonbeam {: #openzeppelin-on-moonbeam } Currently, the following OpenZeppelin products/solutions work on the different networks available on Moonbeam: | **Product** | **Moonbeam** | **Moonriver** | **Moonbase Alpha** | **Moonbase Dev Node** | |:---------------------:|:------------:|:-------------:|:------------------:|:---------------------:| | Contracts & libraries | ✓ | ✓ | ✓ | ✓ | | Contracts Wizard | ✓ | ✓ | ✓ | ✓ | You will find a corresponding tutorial for each product in the following links: - [**Contracts Wizard**](/builders/ethereum/dev-env/openzeppelin/contracts/#openzeppelin-contract-wizard) — where you'll find a guide on how to use OpenZeppelin web-based wizard to create different token contracts with different functionalities - [**Contracts & libraries**](/builders/ethereum/dev-env/openzeppelin/contracts/#deploying-openzeppelin-contracts-on-moonbeam) — where you'll find tutorials to deploy the most common token contracts using OpenZeppelin's templates: ERC-20, ERC-721 and ERC-1155
The information presented herein has been provided by third parties and is made available solely for general information purposes. Moonbeam does not endorse any project listed and described on the Moonbeam Doc Website (https://docs.moonbeam.network/). Moonbeam Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Moonbeam Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Moonbeam Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Moonbeam Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Moonbeam Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/precompiles/overview/ --- BEGIN CONTENT --- --- title: Solidity Precompiles description: An overview of the available Solidity precompiles on Moonbeam. Precompiles enable you to interact with Substrate features using the Ethereum API. categories: Reference, Basics --- # Overview of the Precompiled Contracts on Moonbeam ## Overview {: #introduction } On Moonbeam, a precompiled contract is native Substrate code that has an Ethereum-style address and can be called using the Ethereum API, like any other smart contract. The precompiles allow you to call the Substrate runtime directly which is not normally accessible from the Ethereum side of Moonbeam. The Substrate code responsible for implementing precompiles can be found in the [EVM pallet](/learn/platform/technology/#evm-pallet){target=\_blank}. The EVM pallet includes the [standard precompiles found on Ethereum and some additional precompiles that are not specific to Ethereum](https://github.com/polkadot-evm/frontier/tree/master/frame/evm/precompile){target=\_blank}. It also provides the ability to create and execute custom precompiles through the generic [`Precompiles` trait](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm/trait.Precompile.html){target=\_blank}. There are several custom Moonbeam-specific precompiles that have been created, all of which can be found in the [Moonbeam codebase](https://github.com/moonbeam-foundation/moonbeam/tree/master/precompiles){target=\_blank}. It is important to highlight that the precompiles from this list with the `CallableByContract` check are not callable inside the contract constructor. The Ethereum precompiled contracts contain complex functionality that is computationally intensive, such as hashing and encryption. The custom precompiled contracts on Moonbeam provide access to Substrate-based functionality such as staking, governance, XCM-related functions, and more. The Moonbeam-specific precompiles can be interacted with through familiar and easy-to-use Solidity interfaces using the Ethereum API, which are ultimately used to interact with the underlying Substrate interface. This flow is depicted in the following diagram: ![Precompiled Contracts Diagram](/images/builders/ethereum/precompiles/overview/overview-1.webp) !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. ## Precompiled Contract Addresses {: #precompiled-contract-addresses } The precompiled contracts are categorized by address and based on the origin network. If you were to convert the precompiled addresses to decimal format, and break them into categories by numeric value, the categories are as follows: - **0-1023** - [Ethereum MainNet precompiles](#ethereum-mainnet-precompiles) - **1024-2047** - precompiles that are [not in Ethereum and not Moonbeam specific](#non-moonbeam-specific-nor-ethereum-precomiles) - **2048-4095** - [Moonbeam specific precompiles](#moonbeam-specific-precompiles) ### Ethereum MainNet Precompiles {: #ethereum-mainnet-precompiles } === "Moonbeam" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonriver" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonbase Alpha" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | ### Non-Moonbeam Specific nor Ethereum Precompiles {: #non-moonbeam-specific-nor-ethereum-precompiles } === "Moonbeam" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonriver" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonbase Alpha" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | ### Moonbeam Specific Precompiles {: #moonbeam-specific-precompiles } === "Moonbeam" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbeam.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbeam.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbeam.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbeam.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbeam.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbeam.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbeam.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbeam.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbeam.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbeam.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbeam.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbeam.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbeam.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v3}} | | [XCM interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbeam.precompiles.identity}} | === "Moonriver" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonriver.precompiles.erc20}} | | Democracy [Disabled] | {{networks.moonriver.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonriver.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonriver.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonriver.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonriver.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonriver.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonriver.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonriver.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonriver.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonriver.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonriver.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonriver.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v3}} | | [XCM interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonriver.precompiles.identity}} | === "Moonbase Alpha" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbase.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | | [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/create-account/ --- BEGIN CONTENT --- --- title: Create an Account description: To begin developing on Moonbeam, you must create an account. This guide will provide you with the information needed to create one to use on Moonbeam. categories: Basics --- # Create an Account ## Introduction {: #introduction } To get started developing on Moonbeam, developers must create an account. The most prevalent approach involves leveraging a wallet application, which facilitates generating and managing cryptographic keys essential for interacting with Moonbeam. Moonbeam uses H160 Ethereum-style accounts and ECDSA keys, represented in 20-byte addresses. If you already have an Ethereum account and its private key or mnemonic, you can use your account on Moonbeam. This guide will walk you through the step-by-step process of creating an account on Moonbeam. Whether you're new to blockchain technology or an experienced Ethereum user, this guide will provide all the information you need to get started. !!! note This guide does not pertain to a local Moonbeam development node. If you are using a development node, you don't need to worry about creating an account, as the node comes with ten pre-funded accounts for testing purposes. Please refer to the [Getting Started with a Local Moonbeam Development Node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} guide for more information. ## Choose a Wallet {: #choose-a-wallet } A wallet is a software or hardware tool that allows you to securely store, manage, and interact with your digital assets, such as tokens or coins. Wallets store your private keys, which are essential for authorizing transactions on the network. You can review a list of wallets on the [Moonbeam DApp Directory](https://apps.moonbeam.network/moonbeam/app-dir?cat=wallets){target=\_blank}. ![View list of wallets on the Moonbeam DApp](/images/builders/get-started/create-account/create-account-1.webp) The list of wallets on the dApp is not exhaustive and may only cover some of the available options. You should be able to use any Ethereum-compatible wallet to generate an address and its associated private key. You can also check out any of the wallets in the [Connect to Moonbeam](/tokens/connect/){target=\_blank} section of the docs. ## Use Your Wallet to Create an Account {: #use-your-wallet-to-create-an-account } After you've selected a wallet and downloaded it, you'll most likely be prompted to create a new account or import an existing one the first time you open it. You'll want to create a new account. Depending on the wallet, when creating an account, you may be prompted to backup and restore a seed phrase, also referred to as a mnemonic or recovery phrase. This phrase is a sequence of generated words that serve as a backup mechanism for private keys. They typically consist of 12 to 24 words randomly selected from a predefined list. Seed phrases are used to derive private keys deterministically, meaning that the same sequence of words will always generate the same set of private keys. They are crucial for recovering access to a cryptocurrency wallet in case of loss or device failure. **Make sure you save the phrase in a safe place; if you lose access to this phrase, you'll lose access to any funds you hold in your account.** After saving your seed phrase, you can start developing on Moonbeam. Many wallets offer the option to export the private key linked to your account. By doing so, you can utilize your private key instead of the seed phrase during development. However, taking adequate precautions to securely store your private key or seed phrase while developing is essential. And that's it! Before sending your first transaction on a Moonbeam-based network, ensure you have the necessary [network configurations for your chosen network](/builders/get-started/networks/){target=\_blank} and an [RPC endpoint](/builders/get-started/endpoints/){target=\_blank} for the network. Once you have these items, you'll be able to follow along with tutorials like the [How to use Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank} or the [How to use Web3.js](/builders/ethereum/libraries/web3js/){target=\_blank} to send a transaction. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/explorers/ --- BEGIN CONTENT --- --- title: Block Explorers description: An overview of the currently available block explorers that may be used to navigate the Substrate and Ethereum layers of Moonbeam. categories: Basics --- # Block Explorers ## Introduction {: #introduction } Block explorers can be thought of as search engines for the blockchain. They allow users to search for information such as balances, contracts, and transactions. More advanced block explorers even offer indexing capabilities, which enable them to provide a complete set of information, such as ERC-20 tokens in the network. They might even offer API services to access it via external services. Moonbeam provides two different kinds of explorers: ones to query the Ethereum API and others dedicated to the Substrate API. All EVM-based transactions are accessible via the Ethereum API, while the Substrate API can be relied upon for Substrate-native functions such as governance and staking. The Substrate API also includes information about the EVM-based transactions, but only limited information is shown. ## Quick Links {: #quick-links } === "Moonbeam" | Block Explorer | Type | URL | |:--------------:|:---------:|:-------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonbeam.moonscan.io/](https://moonbeam.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=Moonbeam](https://moonbeam-explorer.netlify.app/?network=Moonbeam){target=\_blank} | | Subscan | Substrate | [https://moonbeam.subscan.io/](https://moonbeam.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/explorer){target=\_blank} | === "Moonriver" | Block Explorer | Type | URL | |:--------------:|:---------:|:-----------------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonriver.moonscan.io/](https://moonriver.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=Moonriver](https://moonbeam-explorer.netlify.app/?network=Moonriver){target=\_blank} | | Subscan | Substrate | [https://moonriver.subscan.io/](https://moonriver.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonrvier.moonbeam.network#/explorer){target=\_blank} | === "Moonbase Alpha" | Block Explorer | Type | URL | |:--------------:|:---------:|:----------------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonbase.moonscan.io/](https://moonbase.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=MoonbaseAlpha](https://moonbeam-explorer.netlify.app/?network=MoonbaseAlpha){target=\_blank} | | Subscan | Substrate | [https://moonbase.subscan.io/](https://moonbase.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer){target=\_blank} | === "Moonbeam Dev Node" | Block Explorer | Type | URL | |:--------------:|:---------:|:-------------------------------------------------------------------------------------------------------------------------------------------------:| | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=MoonbeamDevNode](https://moonbeam-explorer.netlify.app/?network=MoonbeamDevNode){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://ws%3A%2F%2F127.0.0.1%3A9944#/explorer){target=\_blank} | ## Ethereum API {: #ethereum-api } ### Moonscan {: #Moonscan } [Moonscan](https://moonscan.io){target=\_blank} is the primary Ethereum API block explorer for Moonbeam-based networks. Built by the Etherscan team, Moonscan provides a powerful, intuitive, and feature-rich experience. In addition to its comprehensive transaction and block data, Moonscan provides a number of [statistics and charts](https://moonbeam.moonscan.io/charts){target=\_blank}, such as average gas price, daily transactions, and block size charts. Other Moonscan features include: - [Collator leaderboard](https://moonbeam.moonscan.io/collators){target=\_blank} ranking collators by performance - [Contract source code verification](/builders/ethereum/verify-contracts/block-explorers/){target=\_blank}, accessible both via a web interface and an API - Ability to read and write state data of verified smart contracts - [Token approvals](https://moonscan.io/tokenapprovalchecker){target=\_blank} where you can view and revoke any of your prior token approvals - [Adding token information](/builders/get-started/token-profile/){target=\_blank} and creating a profile for ERC-20s, ERC-721s, and ERC-1155s deployed to Moonbeam-based networks. The profile can include links to your project, social media, price data, and other information pertaining to your token ![Moonbeam Moonscan](/images/builders/get-started/explorers/explorers-1.webp) ### Expedition {: #expedition } A Moonbeam-themed version of the [Expedition](https://github.com/xops/expedition){target=\_blank} explorer can be found in [this link](https://moonbeam-explorer.netlify.app){target=\_blank}. It is a basic JSON-RPC based explorer. By default, the explorer is connected to Moonbeam. However, you can switch to Moonriver or Moonbase Alpha, or connect it to a local dev node by following the next steps: 1. Click on the network text, where you'll be able to select between all different networks, including a **Moonbeam Development Node** running on `{{ networks.development.rpc_url }}` 2. In the case you want to connect to a specific RPC URL, select **Add Custom Chain** and enter the URL. For example, `http://localhost:9937` ![Expedition Explorer](/images/builders/get-started/explorers/explorers-2.webp) ## Substrate API {: #substrate-api } ### Subscan {: #subscan } [Subscan](https://moonbeam.subscan.io){target=\_blank} is the primary Substrate API block explorer for Moonbeam-based networks. Subscan is capable of parsing standard or custom modules. For example, this is useful to display information regarding the Staking, Governance, and EVM pallets (or modules). The code is all open-source and can be found in the [Subscan Essentials GitHub repo](https://github.com/subscan-explorer/subscan-essentials){target=\_blank}. ![Subscan Moonbeam](/images/builders/get-started/explorers/explorers-3.webp) ### Polkadot.js {: #polkadotjs } While not a full-featured block explorer, Polkadot.js Apps is a convenient option especially for users running local development nodes to view events and query transaction hashes. Polkadot.js Apps uses the WebSocket endpoint to interact with the Network. You can easily connect to [Moonbeam](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/explorer){target=\_blank}, [Moonriver](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonriver.moonbase.moonbeam.network#/explorer){target=\_blank}, or [Moonbase Alpha](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer){target=\_blank}. ![Polkadot.js Moonbeam](/images/builders/get-started/explorers/explorers-4.webp) To connect it to a Moonbeam development node, you can follow the steps in the [Connecting Polkadot.js Apps to a Local Moonbeam Node](/builders/get-started/networks/moonbeam-dev/#connecting-polkadot-js-apps-to-a-local-moonbeam-node){target=\_blank} section of the [Getting Started with a Moonbeam Development Node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} guide. The default port for this is `9944`. ![Polkadot.js Local Node](/images/builders/get-started/explorers/explorers-5.webp) --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/networks/moonbase/ --- BEGIN CONTENT --- --- title: Moonbase Alpha Get Started Guide description: The Moonbeam TestNet, named Moonbase Alpha, is the easiest way to get started with a Polkadot environment. Follow this tutorial to connect to the TestNet. categories: Basics --- # Get Started with Moonbase Alpha ## Network Endpoints {: #network-endpoints } Moonbase Alpha has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints. === "HTTPS" | Provider | RPC URL | Limits | |:-------------------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam-alpha.api.onfinality.io/public```
| 40 req/sec | | Moonbeam Foundation |
```https://rpc.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```https://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbase.public.curie.radiumblock.co/http```
| 200 req/sec | === "WSS" | Provider | RPC URL | Limits | |:-------------------:|:-----------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam-alpha.api.onfinality.io/public-ws```
| 40 req/sec | | Moonbeam Foundation |
```wss://wss.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```wss://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbase.public.curie.radiumblock.co/ws```
| 200 req/sec | #### Relay Chain {: #relay-chain } To connect to the Moonbase Alpha relay chain, you can use the following WS Endpoint: | Provider | RPC URL | |:--------:|:----------------------------------------------------------:| | OpsLayer |
```wss://relay.api.moonbase.moonbeam.network```
| ## Quick Start {: #quick-start } For the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonbase Alpha (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonbase Alpha as provider const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonbase Alpha: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'https://rpc.api.moonbase.moonbeam.network'; // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1287, name: 'moonbase-alphanet' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonbase Alpha TestNet chain ID is: `1287`, which is `0x507` in hex. ## Block Explorers For Moonbase Alpha, you can use any of the following block explorers: - **Ethereum API (Etherscan Equivalent)** — [Moonscan](https://moonbase.moonscan.io){target=\_blank} - **Ethereum API JSON-RPC based** — [Moonbeam Basic Explorer](https://moonbeam-explorer.netlify.app/?network=MoonbaseAlpha){target=\_blank} - **Substrate API** — [Subscan](https://moonbase.subscan.io){target=\_blank} or [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer){target=\_blank} For more information on each of the available block explorers, please head to the [Block Explorers](/builders/get-started/explorers/){target=\_blank} section of the documentation. ## Connect MetaMask If you already have MetaMask installed, you can easily connect MetaMask to the Moonbase Alpha TestNet: !!! note MetaMask will popup asking for permission to add Moonbase Alpha as a custom network. Once you approve permissions, MetaMask will switch your current network to Moonbase Alpha. If you do not have MetaMask installed, or would like to follow a tutorial to get started, please check out the [Interacting with Moonbeam using MetaMask](/tokens/connect/metamask/){target=\_blank} guide. ## Configuration {: #configuration } Please note the following gas configuration parameters. These values are subject to change in future runtime upgrades. | Variable | Value | |:---------------------:|:------------------------------------------:| | Minimum gas price | {{ networks.moonbase.min_gas_price }} Gwei | | Target block time | {{ networks.moonbase.block_time }} seconds | | Block gas limit | {{ networks.moonbase.gas_block }} | | Transaction gas limit | {{ networks.moonbase.gas_tx }} | ## Get Tokens {: #get-tokens } To start building on Moonbase Alpha, you can get DEV tokens from the Moonbase Alpha Faucet. For specific amounts, you can always reach out directly to us via our community channels. To request DEV tokens from the faucet, you can enter your address on the [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} website. The faucet dispenses {{ networks.moonbase.website_faucet_amount }} every 24 hours. ![Moonbase Alpha Faucet Website.](/images/builders/get-started/networks/moonbase/moonbase-1.webp) !!! note Moonbase Alpha DEV tokens have no value. Please don't spam the faucet with unnecessary requests. ## Demo DApps {: #Demo-DApps } There are a variety of DApps deployed to Moonbase Alpha enabling you to experiment with various apps and integrations. You can also acquire a variety of test tokens through the [Moonbase ERC20 Minter](https://moonbase-minterc20.netlify.app){target=\_blank} or [Moonbeam Uniswap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank} DApps. For example, [Moonbeam Uniswap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank} can help you acquire cross-chain assets such as xcUNIT or xcKarura for testing XCM related functions. In the below table, you'll find each sample DApp, its associated URL, and GitHub repository. ### Quick Links {: #quick-links } | DApp | Description | Repository | |:------------------------------------------------------------------------------------------:|:------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [Moonbase ERC-20 Minter](https://moonbase-minterc20.netlify.app){target=\_blank} | ERC-20 Faucet | [https://github.com/papermoonio/moonbase-mintableERC20](https://github.com/papermoonio/moonbase-mintableERC20){target=\_blank} | | [Moonbeam Uniswap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank} | Uniswap V2 Fork | [https://github.com/papermoonio/moonbeam-uniswap](https://github.com/papermoonio/moonbeam-uniswap){target=\_blank} | | [MoonLotto Lottery](https://moonbase-moonlotto.netlify.app){target=\_blank} | TheGraph Demo | [Interface](https://github.com/papermoonio/moonlotto-interface){target=\_blank}, [Subgraph](https://github.com/papermoonio/moonlotto-subgraph){target=\_blank} | | [Moonbeam WalletConnect](https://moonbeam-walletconnect-demo.netlify.app){target=\_blank} | WalletConnect Demo | [https://github.com/papermoonio/moonbeam-walletconnect-demo](https://github.com/papermoonio/moonbeam-walletconnect-demo){target=\_blank} | | [MoonGas](https://moonbeam-gasinfo.netlify.app){target=\_blank} | Gas Price Tracker | [https://github.com/albertov19/moonbeam-gas-station](https://github.com/albertov19/moonbeam-gas-station){target=\_blank} | !!! note These DApps are intended for demonstration purposes only and may be incomplete or unsuitable for production deployments. ### Moonbase ERC20 Minter {: #moonbase-erc20-minter } The [Moonbase ERC-20 Minter](https://moonbase-minterc20.netlify.app){target=\_blank} enables you to mint a variety of ERC-20 test tokens corresponding to the 8 planets of the solar system, and Pluto. To mint tokens, first press **Connect MetaMask** in the upper right hand corner. Then scroll to the **Mint Tokens** section and the choose desired ERC-20 contract. Press **Submit Tx** and confirm the transaction in MetaMask. Each mint will grant you 100 tokens, and you can mint tokens for each contract once per hour. ![ERC20 Minter](/images/builders/get-started/networks/moonbase/moonbase-2.webp) ### Moonbeam Uniswap {: #moonbeam-uniswap } [Moonbeam Uniswap](https://moonbeam-swap.netlify.app/#/swap){target=\_blank} is a fork of [Uniswap-V2](https://blog.uniswap.org/uniswap-v2){target=\_blank} deployed to Moonbase Alpha. Notably, Moonbeam Uniswap allows developers to easily make a swap to acquire [cross-chain assets](/builders/interoperability/xcm/xc20/){target=\_blank} such as xcKarura or xcUNIT for XCM testing purposes. To perform your first swap, take the following steps: 1. Press **Select a token** 2. Connect your MetaMask wallet and ensure you're on the Moonbase Alpha network 3. Press **Choose a List** on the prompt 4. Select **Moon Menu** 5. Search for or select your desired asset from the list then continue with the swap ![Moonbeam Swap](/images/builders/get-started/networks/moonbase/moonbase-3.webp) !!! note If you see only a partial list of assets under **Moon Menu**, your browser may have cached an older version of **Moon Menu**. Clearing the cache and re-adding **Moon Menu** will resolve this. ### MoonLotto Lottery {: #moonlotto-lottery } [MoonLotto](https://moonbase-moonlotto.netlify.app){target=\_blank} is a simple lottery game on Moonbase Alpha derived from [The Graph's Example Subgraph](https://github.com/graphprotocol/example-subgraph){target=\_blank}. Purchasing a ticket costs 1 DEV and a winner is chosen each half hour if there are at least 10 participants. [MoonLotto.sol](https://github.com/papermoonio/moonlotto-subgraph/blob/main/contracts/MoonLotto.sol){target=\_blank} holds the contract logic for the lottery. To participate, take the following steps: 1. Connect your MetaMask wallet and ensure you're on the Moonbase Alpha network 2. Enter the address of the recipient of lotto ticket or check **I want to buy a ticket for my address** 3. Press **Submit on MetaMask** and confirm the transaction in MetaMask ![MoonLotto Lottery](/images/builders/get-started/networks/moonbase/moonbase-5.webp) ### Moonbeam WalletConnect {: #moonbeam-walletconnect } [Moonbeam WalletConnect](https://moonbeam-walletconnect-demo.netlify.app){target=\_blank} shows how easy it is to integrate [WalletConnect](https://walletconnect.com){target=\_blank} into your DApps and unlock support for a great variety of crypto wallets. Be sure to check out the [demo app repository](https://github.com/papermoonio/moonbeam-walletconnect-demo){target=\_blank} to see exactly how the WalletConnect integration works. To get started, you can take the following steps: 1. Press **Connect Wallet** 2. Scan the QR code using a [wallet compatible with WalletConnect](https://walletguide.walletconnect.network/){target=\_blank} ![Moonbeam WalletConnect](/images/builders/get-started/networks/moonbase/moonbase-6.webp) ### MoonGas {: #moongas } [MoonGas](https://moonbeam-gasinfo.netlify.app){target=\_blank} is a convenient dashboard for viewing the minimum, maximum, and average gas price of transactions in the prior block across all Moonbeam networks. Note, these statistics can fluctuate widely by block and occasionally include outlier values. You can check out the [repository for MoonGas](https://github.com/albertov19/moonbeam-gas-station){target=\_blank}. You'll notice that the minimum gas price for Moonbeam is {{ networks.moonbeam.min_gas_price }} Gwei, while the minimum for Moonriver is {{ networks.moonriver.min_gas_price }} Gwei and Moonbase Alpha is {{ networks.moonbase.min_gas_price }} Gwei. This difference stems from the [100 to 1 re-denomination of GLMR](https://moonbeam.network/news/moonbeam-foundation-announces-liquidity-programs-a-new-token-event-and-glmr-redenomination){target=\_blank} and thus the {{ networks.moonbeam.min_gas_price }} Gwei minimum on Moonbeam corresponds to a {{ networks.moonriver.min_gas_price }} Gwei minimum on Moonriver and a {{ networks.moonbase.min_gas_price }} Gwei on Moonbase. ![MoonGas](/images/builders/get-started/networks/moonbase/moonbase-7.webp) --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/networks/moonbeam-dev/ --- BEGIN CONTENT --- --- title: Run a Moonbeam Development Node description: Follow this tutorial to learn how to spin up your first Moonbeam development node, how to configure it for development purposes, and connect to it. categories: Basics --- # Getting Started with a Local Moonbeam Development Node
## Introduction {: #introduction } A Moonbeam development node is your own personal development environment for building and testing applications on Moonbeam. For Ethereum developers, it is comparable to the Hardhat Network. It enables you to get started quickly and easily without the overhead of a relay chain. You can spin up your node with the `--sealing` option to author blocks instantly, manually, or at a custom interval after transactions are received. By default, a block will be created when a transaction is received, which is similar to the default behavior of Hardhat Network's instamine feature. If you follow this guide to the end, you will have a Moonbeam development node running in your local environment with 10 prefunded [accounts](#pre-funded-development-accounts). !!! note This tutorial was created using the {{ networks.development.build_tag }} tag of [Moonbase Alpha](https://github.com/moonbeam-foundation/moonbeam/releases/tag/{{ networks.development.build_tag }}){target=\_blank}. The Moonbeam platform and the [Frontier](https://github.com/polkadot-evm/frontier){target=\_blank} components it relies on for Substrate-based Ethereum compatibility are still under very active development. The examples in this guide assume you have a MacOS or Ubuntu 22.04-based environment and will need to be adapted accordingly for Windows. ## Spin Up a Moonbeam Development Node {: #spin-up-a-node } There are two ways to get started running a Moonbeam node. You can use [Docker to run a pre-built binary](#getting-started-with-docker) or you can [compile the binary locally](#getting-started-with-the-binary-file) and set up a development node yourself. Using Docker is a quick and convenient way to get started, as you won't have to install Substrate and all the dependencies, and you can skip the node-building process as well. It does require you to [install Docker](https://docs.docker.com/get-started/get-docker/){target=\_blank}. On the other hand, if you decide you want to go through the process of building your development node, it could take roughly 30 minutes or longer to complete, depending on your hardware. ### Spin Up a Node with Docker {: #getting-started-with-docker } Using Docker enables you to spin up a node in a matter of seconds. Once you have Docker installed, you can take the following steps to spin up your node: 1. Execute the following command to download the latest Moonbeam image: ```bash docker pull moonbeamfoundation/moonbeam:{{ networks.development.build_tag }} ``` The tail end of the console log should look like this:
docker pull moonbeamfoundation/moonbeam:v0.43.0
v0.43.0: Pulling from moonbeamfoundation/moonbeam
b0a0cf830b12: Pull complete
fbff687640dd: Pull complete
58ea427410e2: Pull complete
811ba55e6e61: Pull complete
4316d5f1b914: Pull complete
128693ce218e: Pull complete
a3ac90b88463: Pull complete
Digest: sha256:86421aca2381265cd2e5283cb98705e24be0bc92a73937363f79d9d6e0d62088
Status: Downloaded newer image for moonbeamfoundation/moonbeam:v0.43.0
docker.io/moonbeamfoundation/moonbeam:v0.43.0
2. Spin up a Moonbeam development node by running the following Docker command, which will launch the node in instant seal mode for local testing so that blocks are authored instantly as transactions are received: === "Ubuntu" ```bash docker run --rm --name {{ networks.development.container_name }} --network host \ moonbeamfoundation/moonbeam:{{ networks.development.build_tag }} \ --dev --rpc-external ``` === "MacOS" ```bash docker run --rm --name {{ networks.development.container_name }} -p 9944:9944 \ moonbeamfoundation/moonbeam:{{ networks.development.build_tag }} \ --dev --rpc-external ``` === "Windows" ```bash docker run --rm --name {{ networks.development.container_name }} -p 9944:9944 ^ moonbeamfoundation/moonbeam:{{ networks.development.build_tag }} ^ --dev --rpc-external ``` !!! note On MacOS with silicon chips, Docker images may perform poorly. To improve performance, try [spinning up a Node with a Binary File](#getting-started-with-the-binary-file). If successful, you should see an output showing an idle state waiting for blocks to be authored:
docker run --rm --name moonbeam_development --network host \
moonbeamfoundation/moonbeam:v0.45.0 \
--dev --rpc-external

CLI parameter `--execution` has no effect anymore and will be removed in the future!
2025-07-10 09:04:26 Moonbeam Parachain Collator
2025-07-10 09:04:26 ✌️ version 0.46.0-d7df89e7161
2025-07-10 09:04:26 ❤️ by PureStake, 2019-2025
2025-07-10 09:04:26 📋 Chain specification: Moonbase Development Testnet
2025-07-10 09:04:26 🏷 Node name: black-and-white-sticks-9174
2025-07-10 09:04:26 👤 Role: AUTHORITY
2025-07-10 09:04:26 💾 Database: RocksDb at /tmp/substrateO3YeRz/chains/moonbase_dev/db/full
2025-07-10 09:04:26 🔨 Initializing Genesis block/state (state: 0xf7c4…5c0f, header-hash: 0x42bd…3b5b)
2025-07-10 09:04:26 Using default protocol ID "sup" because none is configured in the chain specs
2025-07-10 09:04:26 🏷 Local node identity is: 12D3KooWLcpczme2JeBEfLqmjqkzYVKTGKhhGmwSzHjRXGBVhDX7
2025-07-10 09:04:26 💻 Operating system: linux
2025-07-10 09:04:26 💻 CPU architecture: x86_64
2025-07-10 09:04:26 💻 Target environment: gnu
2025-07-10 09:04:26 💻 CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
2025-07-10 09:04:26 💻 CPU cores: 12
2025-07-10 09:04:26 💻 Memory: 7946MB
2025-07-10 09:04:26 💻 Kernel: 6.4.16-linuxkit
2025-07-10 09:04:26 💻 Linux distribution: Debian GNU/Linux 12 (bookworm)
2025-07-10 09:04:26 💻 Virtual machine: yes
2025-07-10 09:04:26 📦 Highest known block at #0
2025-07-10 09:04:26 Running JSON-RPC server: addr=0.0.0.0:9944, allowed origins=["*"]
2025-07-10 09:04:26 🏁 CPU score: 1.14 GiBs
2025-07-10 09:04:26 〽️ Prometheus exporter started at 127.0.0.1:9615
2025-07-10 09:04:26 🏁 Memory score: 10.41 GiBs
2025-07-10 09:04:26 🏁 Disk score (seq. writes): 987.96 MiBs
2025-07-10 09:04:26 🏁 Disk score (rand. writes): 363.65 MiBs
2025-07-10 09:04:26 Development Service Ready
2025-07-10 09:04:26 💤 Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0
2025-07-10 09:04:26 💤 Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0
For more information on some of the flags and options used in the example, check out [Flags](#node-flags) and [Options](#node-options). If you want to see a complete list of all of the flags, options, and subcommands, open the help menu by running: ```bash docker run --rm --name {{ networks.development.container_name }} \ moonbeamfoundation/moonbeam \ --help ``` To continue with the tutorial, the next section is not necessary, as you've already spun up a node with Docker. You can skip ahead to the [Configure your Moonbeam Development Node](#configure-moonbeam-dev-node) section. ### Spin Up a Node with a Binary File {: #getting-started-with-the-binary-file } As an alternative to using Docker, you can spin up a node using the Moonbeam binary. This method is more time-consuming. Depending on your hardware, the process could take around 30 minutes to complete. !!! note If you know what you are doing, you can directly download the precompiled binaries attached to each release on the [Moonbeam release page](https://github.com/moonbeam-foundation/moonbeam/releases){target=\_blank}. These will not work in all systems. For example, the binaries only work with x86-64 Linux with specific versions of dependencies. The safest way to ensure compatibility is to compile the binary on the system where it will be run. To build the binary file, you can take the following steps: 1. Clone a specific tag of the Moonbeam repo, which you can find on the [Moonbeam GitHub repository](https://github.com/moonbeam-foundation/moonbeam){target=\_blank}: ```bash git clone -b {{ networks.development.build_tag }} https://github.com/moonbeam-foundation/moonbeam cd moonbeam ``` !!! note Spaces in the installation file path will cause a compilation error. 2. If you already have Rust installed, you can skip the next two steps. Otherwise, install Rust and its prerequisites [via Rust's recommended method](https://www.rust-lang.org/tools/install){target=\_blank} by executing: ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` 3. Update your PATH environment variable by running: ```bash source $HOME/.cargo/env ``` 4. Build the development node by running: !!! note If you are using Ubuntu 20.04 or 22.04, then you will need to make sure these additional dependencies have been installed before building the binary: ```bash apt install clang protobuf-compiler libprotobuf-dev pkg-config libssl-dev -y ``` For MacOS users, these dependencies can be installed via Homebrew: ```bash brew install llvm brew install protobuf ``` ```bash cargo build --release ``` Here is what the tail end of the build output should look like:
Compiling try-runtime-cli v0.9.0 (https://github.com/paritytech/substrate?branch=rococo-v1#401c24e8)
Compiling frame-benchmarking-cli v3.0.0 (https://github.com/paritytech/substrate?branch=rococo-v1#401c24e8)
Compiling cumulus-client-cli v0.1.0 (https://github.com/paritytech/cumulus?branch=rococo-v1#9d89ed65)
Compiling moonbeam-rpc-txpool v0.6.0 (/home/purestake/moonbeam/client/rpc/txpool)
Compiling moonbeam-rpc-debug v0.1.0 (/home/purestake/moonbeam/client/rpc/debug)
Compiling moonbeam-rpc-trace v0.6.0 (/home/purestake/moonbeam/client/rpc/trace)
Compiling cumulus-client-network v0.1.0 (https://github.com/paritytech/cumulus?branch=rococo-v1#9d89ed65)
Compiling cumulus-client-consensus-relay-chain v0.1.0 (https://github.com/paritytech/cumulus?branch=rococo-v1#9d89ed65)
Compiling polkadot-test-service v0.8.29 (https://github.com/paritytech/polkadot?branch=rococo-v1#b64741e6)
Compiling cumulus-client-collator v0.1.0 (https://github.com/paritytech/cumulus?branch=rococo-v1#9d89ed65)
Compiling cumulus-client-service v0.1.0 (https://github.com/paritytech/cumulus?branch=rococo-v1#9d89ed65)
Finished release [optimized] target(s) in 31m 17s
!!! note The initial build will take a while. Depending on your hardware, you should expect approximately 30 minutes for the build process to finish. Then, you will want to run the node in development mode using the following command: ```bash ./target/release/moonbeam --dev ``` !!! note For people not familiar with Substrate, the `--dev` flag is a way to run a Substrate-based node in a single-node developer configuration for testing purposes. When you run your node with the `--dev` flag, your node is started in a fresh state, and its state does not persist. You should see an output that looks like the following, showing an idle state waiting for blocks to be produced:
./target/release/moonbeam --dev
2025-07-10 09:04:26 Moonbeam Parachain Collator
2025-07-10 09:04:26 ✌️ version 0.46.0-d7df89e7161
2025-07-10 09:04:26 ❤️ by PureStake, 2019-2025
2025-07-10 09:04:26 📋 Chain specification: Moonbase Development Testnet
2025-07-10 09:04:26 🏷 Node name: black-and-white-sticks-9174
2025-07-10 09:04:26 👤 Role: AUTHORITY
2025-07-10 09:04:26 💾 Database: RocksDb at /tmp/substrateO3YeRz/chains/moonbase_dev/db/full
2025-07-10 09:04:26 🔨 Initializing Genesis block/state (state: 0x7c34…99c5, header-hash: 0xa083…f354)
2025-07-10 09:04:26 Using default protocol ID "sup" because none is configured in the chain specs
2025-07-10 09:04:26 🏷 Local node identity is: 12D3KooWLcpczme2JeBEfLqmjqkzYVKTGKhhGmwSzHjRXGBVhDX7
2025-07-10 09:04:26 💻 Operating system: linux
2025-07-10 09:04:26 💻 CPU architecture: x86_64
2025-07-10 09:04:26 💻 Target environment: gnu
2025-07-10 09:04:26 💻 CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
2025-07-10 09:04:26 💻 CPU cores: 12
2025-07-10 09:04:26 💻 Memory: 7946MB
2025-07-10 09:04:26 💻 Kernel: 6.4.16-linuxkit
2025-07-10 09:04:26 💻 Linux distribution: Debian GNU/Linux 12 (bookworm)
2025-07-10 09:04:26 💻 Virtual machine: yes
2025-07-10 09:04:26 📦 Highest known block at #0
2025-07-10 09:04:26 Running JSON-RPC server: addr=0.0.0.0:9944, allowed origins=["*"]
2025-07-10 09:04:26 🏁 CPU score: 1.14 GiBs
2025-07-10 09:04:26 〽️ Prometheus exporter started at 127.0.0.1:9615
2025-07-10 09:04:26 🏁 Memory score: 10.41 GiBs
2025-07-10 09:04:26 🏁 Disk score (seq. writes): 987.96 MiBs
2025-07-10 09:04:26 🏁 Disk score (rand. writes): 363.65 MiBs
2025-07-10 09:04:26 Development Service Ready
2025-07-10 09:04:26 💤 Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0
2025-07-10 09:04:26 💤 Idle (0 peers), best: #0 (0xa083…f354), finalized #0 (0xa083…f354), ⬇ 0 ⬆ 0
For more information on some of the flags and options used in the example, check out the [Flags](#node-flags) and [Options](#node-options). If you want to see a complete list of all of the flags, options, and subcommands, open the help menu by running: ```bash ./target/release/moonbeam --help ``` ## Configure Your Moonbeam Development Node {: #configure-moonbeam-dev-node } Now that you know how to get a standard Moonbeam development node up and running, you may be wondering how you can configure it. The following sections will cover some common configurations you can use when you spin up your node. ### Common Flags to Configure Your Node {: #node-flags } Flags do not take an argument. To use a flag, add it to the end of a command. For example: ```bash ./target/release/moonbeam --dev ``` - **`--dev`** - specifies the development chain - **`--tmp`** - runs a temporary node in which all of the configuration will be deleted at the end of the process - **`--rpc-external`** - listen to all RPC and WebSocket interfaces ### Common Options to Configure Your Node {: #node-options } Options accept an argument to the right of the option. For example: ```bash ./target/release/moonbeam --dev --sealing 6000 ``` - **`-l ` or `--log `** - sets a custom logging filter. The syntax for the log pattern is `=`. For example, to print all of the JSON-RPC logs, the command would look like this: `-l json=trace` - **`--sealing `** - when blocks should be sealed in the dev service. Accepted arguments for interval: `instant`, `manual`, or a number representing the timer interval in milliseconds (for example, `6000` will have the node produce blocks every 6 seconds). The default is `instant``. Please refer to the [Configure Block Production](#configure-block-production) section below for more information - **`--rpc-port `** - sets the unified port for HTTP and WS connections. Accepts a port as the argument. Default is {{ networks.parachain.rpc }} - **`--ws-port `** - *deprecated as of [client v0.33.0](https://github.com/moonbeam-foundation/moonbeam/releases/tag/v0.33.0){target=\_blank}, use `--rpc-port` for HTTP and WS connections instead* - sets the WebSockets RPC server TCP port. As of [client v0.30.0](https://github.com/moonbeam-foundation/moonbeam/releases/tag/v0.30.0){target=\_blank}, it sets the unified port for both HTTP and WS connections. Accepts a port as the argument - **`--rpc-max-connections `** - specifies the combined HTTP and WS connection limit. The default is 100 connections - **`--ws-max-connections `** - *deprecated as of [client v0.33.0](https://github.com/moonbeam-foundation/moonbeam/releases/tag/v0.33.0){target=\_blank}, use `--rpc-max-connections` to limit the HTTP and WS connections instead* - this flag adjusts the combined HTTP and WS connection limit. The default is 100 connections - **`--rpc-cors `** - specifies the browser origins allowed to access the HTTP and WS RPC servers. The origins can be a comma-separated list of the origins to allow access, or you can also specify `null`. When running a development node, the default is to allow all origins For a complete list of flags and options, spin up your Moonbeam development node with `--help` added to the end of the command. ### Configure Block Production {: #configure-block-production } By default, your Moonbeam development node is spun up in instant seal mode, which instantly authors blocks as transactions are received. However, you can specify when blocks should be authored or sealed by using the `--sealing` option. The `--sealing` flag accepts any of the following arguments: - `instant` - as we already covered, this is the default option in which blocks are authored as soon as a transaction is received - `manual` - allows you to produce blocks manually. If a transaction is received, a block will not be produced until you manually create one - an interval in milliseconds - authors a block on a specific time interval. For example, if you set it to `6000`, you will have the node produce blocks every 6 seconds The flag should be appended to the start-up command in the following format: ```text --sealing ``` If you choose `manual`, you'll need to manually create the blocks yourself, which can be done with the `engine_createBlock` JSON-RPC method: ```text engine_createBlock(createEmpty: *bool*, finalize: *bool*, parentHash?: *BlockHash*) ``` For example, you can use the following snippet to manually create a block using [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank}, an Ethereum library that makes it easy to interact with JSON-RPC methods: ```js import { ethers } from 'ethers'; const produceBlock = async () => { // Connect to the Ethereum node (if applicable, replace the URL with your node's address) const provider = new ethers.JsonRpcProvider( '{{ networks.development.rpc_url }}' ); // Set the custom JSON-RPC method and parameters const method = 'engine_createBlock'; const params = [true, true, null]; try { // Send the custom JSON-RPC call const result = await provider.send(method, params); } catch (error) { // Handle any errors that may occur console.error('Error:', error.message); } }; produceBlock(); ``` !!! note If you're unfamiliar with Ethers, please refer to the [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank} documentation page to learn more. ## Prefunded Development Accounts {: #pre-funded-development-accounts } Moonbeam has a [unified accounts](/learn/core-concepts/unified-accounts/){target=\_blank} system, which enables users to have an Ethereum-styled H160 account that can interact with the Substrate API and the Ethereum API. As a result, you can interact with your account through [Polkadot.js Apps](/tokens/connect/polkadotjs/#connect-polkadotjs-apps){target=\_blank} or [MetaMask](/tokens/connect/metamask/){target=\_blank} (or any other [EVM wallet](/tokens/connect/){target=\_blank}). In addition, you can also use other [development tools](/builders/ethereum/dev-env/){target=\_blank}, such as [Remix](/builders/ethereum/dev-env/remix/){target=\_blank} and [Hardhat](/builders/ethereum/dev-env/hardhat/){target=\_blank}. Your Moonbeam development node comes with ten prefunded Ethereum-styled accounts for development. The addresses are derived from Substrate's canonical development mnemonic: ```text bottom drive obey lake curtain smoke basket hold race lonely fit walk ``` ??? note "Development account addresses and private keys" - Alith: - Public Address: `0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac` - Private Key: `0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133` - Baltathar: - Public Address: `0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0` - Private Key: `0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b` - Charleth: - Public Address: `0x798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc` - Private Key: `0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b` - Dorothy: - Public Address: `0x773539d4Ac0e786233D90A233654ccEE26a613D9` - Private Key: `0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68` - Ethan: - Public Address: `0xFf64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB` - Private Key: `0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4` - Faith: - Public Address: `0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d` - Private Key: `0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df` - Goliath: - Public Address: `0x7BF369283338E12C90514468aa3868A551AB2929` - Private Key: `0x96b8a38e12e1a31dee1eab2fffdf9d9990045f5b37e44d8cc27766ef294acf18` - Heath: - Public Address: `0x931f3600a299fd9B24cEfB3BfF79388D19804BeA` - Private Key: `0x0d6dcaaef49272a5411896be8ad16c01c35d6f8c18873387b71fbc734759b0ab` - Ida: - Public Address: `0xC41C5F1123ECCd5ce233578B2e7ebd5693869d73` - Private Key: `0x4c42532034540267bf568198ccec4cb822a025da542861fcb146a5fab6433ff8` - Judith: - Public Address: `0x2898FE7a42Be376C8BC7AF536A940F7Fd5aDd423` - Private Key: `0x94c49300a58d576011096bcb006aa06f5a91b34b4383891e8029c21dc39fbb8b` Also included with the development node is an additional prefunded account used for testing purposes: - Gerald: - Public Address: `0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b` - Private Key: `0x99b3c12287537e38c90a9219d4cb074a89a16e9cdb20bf85728ebd97c343e342` You can connect any of these accounts to [MetaMask](/tokens/connect/metamask/){target=\_blank}, [Talisman](/tokens/connect/talisman/){target=\_blank}, [Polkadot.js Apps](/tokens/connect/polkadotjs/){target=\_blank}, etc., using their private keys. ## Development Node Endpoints {: #access-your-development-node } You can access your Moonbeam development node using the following RPC and WSS endpoints: === "HTTP" ```text {{ networks.development.rpc_url }} ``` === "WSS" ```text {{ networks.development.wss_url }} ``` ## Block Explorers {: #block-explorers } For a Moonbeam development node, you can use any of the following block explorers: - **Substrate API** — [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9944#/explorer){target=\_blank} on WS port `{{ networks.parachain.ws }}` - **Ethereum API JSON-RPC-based** — [Moonbeam Basic Explorer](https://moonbeam-explorer.netlify.app/?network=MoonbeamDevNode){target=\_blank} on HTTP port `{{ networks.parachain.ws }}` ## Debug, Trace, and TxPool APIs {: #debug-trace-txpool-apis } You can also gain access to some non-standard RPC methods by running a tracing node, which allows developers to inspect and debug transactions during runtime. Tracing nodes use a different Docker image than a standard Moonbeam development node. To learn how to run a Moonbeam development tracing node, check out the [Run a Tracing Node](/node-operators/networks/tracing-node/){target=\_blank} guide, and be sure to switch to the **Moonbeam Development Node** tab throughout the instructions. Then, to access the non-standard RPC methods with your tracing node, check out the [Debug & Trace](/builders/ethereum/json-rpc/debug-trace/){target=\_blank} guide. ## Purge a Development Node {: #purging-your-node } If you want to remove data associated with your node, you can purge it. The instructions for purging a node are different depending on how you initially spun up your node. ### Purge a Node Spun Up with Docker {: #purge-docker-node } If you spun up your node using Docker along with the `-v` flag to specify a mounted directory for your container, you will need to purge that directory. To do so, you can run the following command: ```bash sudo rm -rf {{ networks.moonbase.node_directory }}/* ``` If you followed the instructions in this guide and did not use the `-v` flag, you can stop and remove the Docker container. The associated data will be removed along with it. To do so, you can run the following command: ```bash sudo docker stop `CONTAINER_ID` && docker rm `CONTAINER_ID` ``` ### Purge a Node Spun up with a Binary File {: #purge-binary-node } When running a node via the binary file, data is stored in a local directory, typically located in `~/.local/shared/moonbeam/chains/development/db`. If you want to start a fresh instance of the node, you can either delete the content of the folder or run the following command inside the `moonbeam` folder: ```bash ./target/release/moonbeam purge-chain --dev -y ``` This will remove the data folder. Note that all chain data is now lost. To learn more about all of the available `purge-chain` commands, you can check out the [Purging Binary Data](/node-operators/networks/run-a-node/systemd/#purging-compiled-binary){target=\_blank} section of our documentation. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/networks/moonbeam/ --- BEGIN CONTENT --- --- title: Get Started with Moonbeam description: Learn how to connect to Moonbeam via RPC and WSS endpoints, how to connect MetaMask to Moonbeam, and about the available Moonbeam block explorers. categories: Basics --- # Get Started with Moonbeam ## Network Endpoints {: #network-endpoints } Moonbeam has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints: === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbeam.public.curie.radiumblock.co/http```
| 200 req/sec | | 1RPC |
```https://1rpc.io/glmr```
| 10k req/day | | Grove |
```https://moonbeam.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:--------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbeam.public.curie.radiumblock.co/ws```
| 200 req/sec | | 1RPC |
```wss://1rpc.io/glmr```
| 10k req/day | ## Quick Start {: #quick-start } Before getting started, make sure you've retrieved your own endpoint and API key from one of the custom [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. Then for the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonbeam (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonbeam as provider const web3 = new Web3('INSERT_RPC_API_ENDPOINT'); // Insert your RPC URL here ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonbeam: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'INSERT_RPC_API_ENDPOINT'; // Insert your RPC URL here // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1284, name: 'moonbeam' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonbeam chain ID is: `1284`, or `0x504` in hex. ## Block Explorers {: #block-explorers } For Moonbeam, you can use any of the following block explorers: - **Ethereum API (Etherscan Equivalent)** — [Moonscan](https://moonbeam.moonscan.io){target=\_blank} - **Ethereum API JSON-RPC based** — [Moonbeam Basic Explorer](https://moonbeam-explorer.netlify.app/?network=Moonbeam){target=\_blank} - **Substrate API** — [Subscan](https://moonbeam.subscan.io){target=\_blank} or [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/explorer){target=\_blank} For more information on each of the available block explorers, please head to the [Block Explorers](/builders/get-started/explorers/){target=\_blank} section of the documentation. ## Connect MetaMask {: #connect-metamask } If you already have MetaMask installed, you can easily connect MetaMask to Moonbeam: !!! note MetaMask will popup asking for permission to add Moonbeam as a custom network. Once you approve permissions, MetaMask will switch your current network to Moonbeam. If you do not have MetaMask installed, or would like to follow a tutorial to get started, please check out the [Interacting with Moonbeam using MetaMask](/tokens/connect/metamask/){target=\_blank} guide. ## Configuration {: #configuration } Please note the following gas configuration parameters. These values are subject to change in future runtime upgrades. | Variable | Value | |:---------------------:|:------------------------------------------:| | Minimum gas price | {{ networks.moonbeam.min_gas_price }} Gwei | | Target block time | {{ networks.moonbeam.block_time }} seconds | | Block gas limit | {{ networks.moonbeam.gas_block }} | | Transaction gas limit | {{ networks.moonbeam.gas_tx }} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/networks/moonriver/ --- BEGIN CONTENT --- --- title: Moonriver Get Started Guide description: Learn how to connect to Moonriver via RPC and WSS endpoints, how to connect MetaMask to Moonriver, and about the available Moonriver block explorers. categories: Basics --- # Get Started with Moonriver ## Network Endpoints {: #network-endpoints } Moonriver has two types of endpoints available for users to connect to: one for HTTPS and one for WSS. If you're looking for your own endpoints suitable for production use, you can check out the [Endpoint Providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank} section of our documentation. Otherwise, to get started quickly you can use one of the following public HTTPS or WSS endpoints: === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:-------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonriver.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonriver.public.curie.radiumblock.co/http```
| 200 req/sec | | Grove |
```https://moonriver.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:---------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonriver.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonriver.public.curie.radiumblock.co/ws```
| 200 req/sec | ## Quick Start {: #quick-start } Before getting started, make sure you've retrieved your own endpoint and API key from one of the custom [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. Then for the [Web3.js library](/builders/ethereum/libraries/web3js/){target=\_blank}, you can create a local Web3 instance and set the provider to connect to Moonriver (both HTTP and WS are supported): ```js const { Web3 } = require('web3'); // Load Web3 library . . . // Create local Web3 instance - set Moonriver as provider const web3 = new Web3('INSERT_RPC_API_ENDPOINT'); // Insert your RPC URL here ``` For the [Ethers.js library](/builders/ethereum/libraries/ethersjs/){target=\_blank}, define the provider by using `ethers.JsonRpcProvider(providerURL, {object})` and setting the provider URL to Moonriver: ```js const ethers = require('ethers'); // Load Ethers library const providerURL = 'INSERT_RPC_API_ENDPOINT'; // Insert your RPC URL here // Define provider const provider = new ethers.JsonRpcProvider(providerURL, { chainId: 1285, name: 'moonriver' }); ``` Any Ethereum wallet should be able to generate a valid address for Moonbeam (for example, [MetaMask](https://metamask.io){target=\_blank}). ## Chain ID {: #chain-id } Moonriver chain ID is: `1285`, or `0x505` in hex. ## Block Explorers {: #block-explorers } For Moonriver, you can use any of the following block explorers: - **Ethereum API (Etherscan Equivalent)** — [Moonscan](https://moonriver.moonscan.io){target=\_blank} - **Ethereum API JSON-RPC based** — [Moonbeam Basic Explorer](https://moonbeam-explorer.netlify.app/?network=Moonriver){target=\_blank} - **Substrate API** — [Subscan](https://moonriver.subscan.io){target=\_blank} or [Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonriver.moonbeam.network#/explorer){target=\_blank} For more information on each of the available block explorers, please head to the [Block Explorers](/builders/get-started/explorers/) section of the documentation. ## Connect MetaMask {: #connect-metamask } If you already have MetaMask installed, you can easily connect MetaMask to Moonriver: !!! note MetaMask will popup asking for permission to add Moonriver as a custom network. Once you approve permissions, MetaMask will switch your current network to Moonriver. If you do not have MetaMask installed, or would like to follow a tutorial to get started, please check out the [Interacting with Moonbeam using MetaMask](/tokens/connect/metamask/) guide. ## Configuration {: #configuration } Please note the following gas configuration parameters. These values are subject to change in future runtime upgrades. | Variable | Value | |:---------------------:|:-------------------------------------------:| | Minimum gas price | {{ networks.moonriver.min_gas_price }} Gwei | | Target block time | {{ networks.moonriver.block_time }} seconds | | Block gas limit | {{ networks.moonriver.gas_block }} | | Transaction gas limit | {{ networks.moonriver.gas_tx }} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/quick-start/ --- BEGIN CONTENT --- --- title: Quickly Get Started description: Everything you need to know to get started developing, deploying, and interacting with smart contracts on Moonbeam. categories: Basics --- # Quick Start Guide for Developing on Moonbeam ## Quick Overview {: #overview } Moonbeam is a fully Ethereum-compatible smart contract platform on Polkadot. As such, you can interact with Moonbeam via the [Ethereum API](/builders/ethereum/){target=\_blank} and [Substrate API](/builders/substrate/){target=\_blank}. Although Moonbeam is a Substrate-based platform, Moonbeam uses a [unified accounts](/learn/core-concepts/unified-accounts/){target=\_blank} system, which replaces Substrate-style accounts and keys with Ethereum-style accounts and keys. As a result, you can interact with your Moonbeam account with [MetaMask](/tokens/connect/metamask/){target=\_blank}, [Ledger](/tokens/connect/ledger/){target=\_blank}, and other Ethereum-compatible wallets by simply adding Moonbeam's network configurations. Similarly, you can develop on Moonbeam using Ethereum [libraries](/builders/ethereum/libraries/){target=\_blank} and [development environments](/builders/ethereum/dev-env/){target=\_blank}. ## Moonbeam Networks {: #moonbeam-networks } To get started developing on Moonbeam, it's important to be aware of the various networks within the Moonbeam ecosystem. | Network | Network Type | Relay Chain | Native Asset Symbol | Native Asset Decimals | |:-----------------------------------------------------------------------------------------:|:-------------:|:--------------------------------------------------------------------------------:|:-------------------:|:---------------------:| | [Moonbeam](/builders/get-started/networks/moonbeam/){target=\_blank} | MainNet | [Polkadot](https://polkadot.com){target=\_blank} | GLMR | 18 | | [Moonriver](/builders/get-started/networks/moonriver/){target=\_blank} | MainNet | [Kusama](https://kusama.network){target=\_blank} | MOVR | 18 | | [Moonbase Alpha](/builders/get-started/networks/moonbase/){target=\_blank} | TestNet | [Alphanet relay](/learn/platform/networks/moonbase/#relay-chain){target=\_blank} | DEV | 18 | | [Moonbeam Development Node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} | Local TestNet | None | DEV | 18 | !!! note A Moonbeam development node doesn't have a relay chain as its purpose is to be your own personal development environment where you can get started developing quickly without the overhead of a relay chain. ### Network Configurations {: #network-configurations } When working with developer tools, depending on the tool, you might need to configure Moonbeam to interact with the network. To do so, you can use the following information: === "Moonbeam" | Variable | Value | |:---------------:|:------------------------------------------------------------------------------------------------------:| | Chain ID |
```{{ networks.moonbeam.chain_id }}```
| | Public RPC URLs |
```https://moonbeam.public.blastapi.io```
```https://moonbeam.unitedbloc.com```
| | Public WSS URLs |
```wss://moonbeam.public.blastapi.io```
| === "Moonriver" | Variable | Value | |:---------------:|:--------------------------------------------------------------------------------------------------------:| | Chain ID |
```{{ networks.moonriver.chain_id }}```
| | Public RPC URLs |
```https://moonriver.public.blastapi.io```
```https://moonriver.unitedbloc.com```
| | Public WSS URLs |
```wss://moonriver.public.blastapi.io```
| === "Moonbase Alpha" | Variable | Value | |:---------------:|:-----------------------------------------------------------------------------------------------------------:| | Chain ID |
```{{ networks.moonbase.chain_id }}```
| | Public RPC URLs |
```https://moonbase-alpha.public.blastapi.io```
```{{ networks.moonbase.rpc_url }}```
| | Public WSS URLs |
```wss://moonbase-alpha.public.blastapi.io```
```{{ networks.moonbase.wss_url }}```
| === "Moonbeam Dev Node" | Variable | Value | |:-------------:|:----------------------------------------------------:| | Chain ID |
```{{ networks.development.chain_id }}```
| | Local RPC URL |
```{{ networks.development.rpc_url }}```
| | Local WSS URL |
```{{ networks.development.wss_url }}```
| !!! note You can create your own endpoint suitable for development or production from one of the [supported RPC providers](/builders/get-started/endpoints/#endpoint-providers){target=\_blank}. ### Block Explorers {: #explorers } Moonbeam provides two different kinds of explorers: ones to query the Ethereum API, and others dedicated to the Substrate API. All EVM-based transactions are accessible via the Ethereum API whereas the Substrate API can be relied upon for Substrate-native functions such as governance, staking, and some information about EVM-based transactions. For more information on each explorer, please check out the [Block Explorers](/builders/get-started/explorers/){target=\_blank} page. === "Moonbeam" | Block Explorer | Type | URL | |:--------------:|:---------:|:-------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonbeam.moonscan.io/](https://moonbeam.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=Moonbeam](https://moonbeam-explorer.netlify.app/?network=Moonbeam){target=\_blank} | | Subscan | Substrate | [https://moonbeam.subscan.io/](https://moonbeam.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/explorer){target=\_blank} | === "Moonriver" | Block Explorer | Type | URL | |:--------------:|:---------:|:-----------------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonriver.moonscan.io/](https://moonriver.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=Moonriver](https://moonbeam-explorer.netlify.app/?network=Moonriver){target=\_blank} | | Subscan | Substrate | [https://moonriver.subscan.io/](https://moonriver.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonrvier.moonbeam.network#/explorer){target=\_blank} | === "Moonbase Alpha" | Block Explorer | Type | URL | |:--------------:|:---------:|:----------------------------------------------------------------------------------------------------------------------------------------------:| | Moonscan | EVM | [https://moonbase.moonscan.io/](https://moonbase.moonscan.io){target=\_blank} | | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=MoonbaseAlpha](https://moonbeam-explorer.netlify.app/?network=MoonbaseAlpha){target=\_blank} | | Subscan | Substrate | [https://moonbase.subscan.io/](https://moonbase.subscan.io){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/explorer){target=\_blank} | === "Moonbeam Dev Node" | Block Explorer | Type | URL | |:--------------:|:---------:|:-------------------------------------------------------------------------------------------------------------------------------------------------:| | Expedition | EVM | [https://moonbeam-explorer.netlify.app/?network=MoonbeamDevNode](https://moonbeam-explorer.netlify.app/?network=MoonbeamDevNode){target=\_blank} | | Polkadot.js | Substrate | [https://polkadot.js.org/apps/#/explorer](https://polkadot.js.org/apps/?rpc=wss://ws%3A%2F%2F127.0.0.1%3A9944#/explorer){target=\_blank} | ## Funding TestNet Accounts {: #testnet-tokens } To get started developing on one of the TestNets, you'll need to fund your account with DEV tokens to send transactions. Please note that DEV tokens have no real value and are for testing purposes only. | TestNet | Where To Get Tokens From | |:-----------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [Moonbase Alpha](/builders/get-started/networks/moonbase/){target=\_blank} | The [Moonbase Alpha Faucet](https://faucet.moonbeam.network){target=\_blank} website.
The faucet dispenses {{ networks.moonbase.website_faucet_amount }} every 24 hours | | [Moonbeam Development Node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} | Any of the [ten pre-funded accounts](/builders/get-started/networks/moonbeam-dev/#pre-funded-development-accounts){target=\_blank} that come with your
development node | ## Development Tools {: #development-tools } As Moonbeam is a Substrate-based chain that is fully Ethereum-compatible, you can use Substrate-based tools and Ethereum-based tools. ### JavaScript Tools {: #javascript } === "Ethereum" | Tool | Type | |:------------------------------------------------------------------------:|:---------------:| | [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank} | Library | | [Web3.js](/builders/ethereum/libraries/web3js/){target=\_blank} | Library | | [Hardhat](/builders/ethereum/dev-env/hardhat/){target=\_blank} | Dev Environment | | [OpenZeppelin](/builders/ethereum/dev-env/openzeppelin/){target=\_blank} | Dev Environment | | [Remix](/builders/ethereum/dev-env/remix/){target=\_blank} | Dev Environment | | [Scaffold-Eth](/builders/ethereum/dev-env/scaffold-eth/){target=\_blank} | Dev Environment | | [thirdweb](/builders/ethereum/dev-env/thirdweb/){target=\_blank} | Dev Environment | | [Waffle & Mars](/builders/ethereum/dev-env/waffle-mars/){target=\_blank} | Dev Environment | === "Substrate" | Tool | Type | |:---------------------------------------------------------------------------------:|:-------:| | [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank} | Library | ### Python Tools {: #python } === "Ethereum" | Tool | Type | |:---------------------------------------------------------------:|:---------------:| | [Web3.py](/builders/ethereum/libraries/web3py/){target=\_blank} | Library | | [Ape](/builders/ethereum/dev-env/ape/){target=\_blank} | Dev Environment | === "Substrate" | Tool | Type | |:-----------------------------------------------------------------------------------------------:|:-------:| | [Py Substrate Interface](/builders/substrate/libraries/py-substrate-interface/){target=\_blank} | Library | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/core-concepts/instructions/ --- BEGIN CONTENT --- --- title: XCM Instructions description: When XCM instructions are combined, they form an XCM message that performs a cross-chain action. Take a look at some of the most common instructions. categories: XCM, Basics --- # XCM Instructions ## Introduction {: #introduction } XCM messages contain a series of [actions and instructions](https://github.com/paritytech/xcm-format#5-the-xcvm-instruction-set){target=\_blank} that are executed by the Cross-Consensus Virtual Machine (XCVM). An action (for example, transferring a token from one blockchain to another) consists of instructions that the XCVM partly executes in the origin and destination chains. For example, an XCM message that transfers DOT from Polkadot to Moonbeam will include the following XCM instructions (in that order), some of which are executed on Polkadot and some of which are executed on Moonbeam: 1. [TransferReserveAsset](#transfer-reserve-asset) — executed in Polkadot 2. [ReserveAssetDeposited](#reserve-asset-deposited) — executed in Moonbeam 3. [ClearOrigin](#clear-origin) — executed in Moonbeam 4. [BuyExecution](#buy-execution) — executed in Moonbeam 5. [DepositAsset](#deposit-asset) — executed in Moonbeam Building the instructions for an XCM message from scratch is not an easy task. Consequently, there are wrapper functions and pallets that developers can leverage to use XCM features. The [Polkadot XCM](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} and [XCM Transactor](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank} Pallets provide functions with a predefined set of XCM instructions to either send [XC-20s](/builders/interoperability/xcm/xc20/overview/){target=\_blank} or remotely execute on other chains via XCM. If you're interested in experimenting with different combinations of instructions, you can [use the Polkadot XCM Pallet to execute and send custom XCM messages](/builders/interoperability/xcm/send-execute-xcm/){target=\_blank}. This guide provides an overview of some of the most commonly used XCM instructions, including those in the above example. ## Buy Execution {: #buy-execution } The [`BuyExecution`](https://github.com/paritytech/xcm-format#buyexecution){target=\_blank} instruction typically gets executed in the target chain. It takes assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), to pay for execution fees. The target chain determines the fees to pay. ## Clear Origin {: #clear-origin } The [`ClearOrigin`](https://github.com/paritytech/xcm-format#clearorigin){target=\_blank} instruction gets executed in the target chain. It clears the origin of the XCM author, thereby ensuring that later XCM instructions cannot command the authority of the author. ## Deposit Asset {: #deposit-asset } The [`DepositAsset`](https://github.com/paritytech/xcm-format#depositasset){target=\_blank} instruction gets executed in the target chain. It removes the assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), and sends them to a destination account on the target chain. ## Descend Origin {: #descend-origin } The [`DescendOrigin`](https://github.com/paritytech/xcm-format#descendorigin){target=\_blank} instruction gets executed in the target chain. It mutates the origin on the target chain to match the origin on the source chain, ensuring execution on the target chain occurs on behalf of the same entity initiating the XCM message on the source chain. ## Initiate Reserve Withdraw {: #initiate-reserve-withdraw } The [`InitiateReserveWithdraw`](https://github.com/paritytech/xcm-format#initiatereservewithdraw){target=\_blank} instruction gets executed in the source chain. It removes the assets from the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM), (essentially burning them), and sends an XCM message to the reserve chain starting with the `WithdrawAsset` instruction. ## Refund Surplus {: #refund-surplus } The [`RefundSurplus`](https://github.com/paritytech/xcm-format#refundsurplus){target=\_blank} instruction typically gets executed in the target chain after the XCM is processed. This instruction will take any leftover assets from the `BuyExecution` instruction and put the assets into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). ## Reserve Asset Deposited {: #reserve-asset-deposited } The [`ReserveAssetDeposited`](https://github.com/paritytech/xcm-format#reserveassetdeposited-){target=\_blank} instruction gets executed in the target chain. It takes a representation of the assets received in the Sovereign account and places them into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). ## Set Appendix {: #set-appendix } The [`SetAppendix`](https://github.com/paritytech/xcm-format#setappendix){target=\_blank} instruction gets executed in the target chain. It sets the appendix register, which holds code that should be run after the current execution is finished. ## Transfer Reserve Asset {: #transfer-reserve-asset } The [`TransferReserveAsset`](https://github.com/paritytech/xcm-format#transferreserveasset){target=\_blank} instruction gets executed in the reserve chain. It moves assets from the origin account and deposits them into a destination account on the target chain. It then sends an XCM message to the target chain with the `ReserveAssetDeposited` instruction, followed by the XCM instructions that are to be executed. ## Transact {: #transact } The [`Transact`](https://github.com/paritytech/xcm-format#transact){target=\_blank} instruction gets executed in the target chain. It dispatches encoded call data from a given origin, allowing for the execution of specific operations or functions on the target chain. ## Withdraw Asset {: #withdraw-asset } The [`WithdrawAsset`](https://github.com/paritytech/xcm-format#withdrawasset){target=\_blank} instruction can be executed in either the source or target chain. It removes assets and places them into the holding register, a temporary position in the Cross-Consensus Virtual Machine (XCVM). --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/overview/ --- BEGIN CONTENT --- --- title: Cross-Consensus Messaging (XCM) description: An overview of how cross-consensus messaging (XCM) works and how developers can leverage Polkadot/Kusama XCM to gain access to new assets. categories: Basics, XCM --- # Cross-Consensus Messaging (XCM) ## Introduction {: #introduction } [Polkadot's architecture](https://wiki.polkadot.com/learn/learn-architecture/){target=\_blank} allows parachains to natively interoperate with each other, enabling cross-blockchain transfers of any type of data or asset. To do so, a [Cross-Consensus Message (XCM)](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank} format defines a language around how the message transfer between two interoperating blockchains should be performed. XCM is not specific to Polkadot, as it aims to be a generic and extensible language between different consensus systems. This page is a brief introduction and overview of XCM and other related elements. More information can be found in [Polkadot's Wiki](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank}. If you want to jump to more XCM-related content, feel free to check out the following pages: - [**Core XCM Concepts**](/builders/interoperability/xcm/core-concepts/){target=\_blank} - learn topics related to [XCM Instructions](/builders/interoperability/xcm/core-concepts/instructions/){target=\_blank}, [Multilocations](/builders/interoperability/xcm/core-concepts/multilocations/){target=\_blank}, and [XCM Fees](/builders/interoperability/xcm/core-concepts/weights-fees/){target=\_blank} - [**XC Registration**](/builders/interoperability/xcm/xc-registration/){target=\_blank} - go through the process of [Opening an XCM Channel with Moonbeam](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} and how to [Register Polkadot Native Assets as XC-20s](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} - [**XC-20s**](/builders/interoperability/xcm/xc20/){target=\_blank} - read an [Overview](/builders/interoperability/xcm/xc20/overview/){target=\_blank} of this Moonbeam-only asset class and learn how to [Interact with XC-20s](/builders/interoperability/xcm/xc20/interact/){target=\_blank} and how to [Send them via XCM](/builders/interoperability/xcm/xc20/send-xc20s/){target=\_blank} - [**Remote Execution via XCM**](/builders/interoperability/xcm/remote-execution/){target=\_blank} - grasp all concepts related to remote execution via XCM, starting with a [High-Level Overview](/builders/interoperability/xcm/remote-execution/overview/){target=\_blank}, then [Computed Origins](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank} and wrapping up with [Remote Calls via XCM](/builders/interoperability/xcm/remote-execution/substrate-calls/){target=\_blank} and [Remote EVM Calls via XCM](/builders/interoperability/xcm/remote-execution/remote-evm-calls/){target=\_blank} - [**XCM SDK**](https://moonbeam-foundation.github.io/xcm-sdk/latest/){target=\_blank} - learn how to [Use Moonbeam's XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm/){target=\_blank} - **XCM Debugging and Tools** - learn how to test some XCM scenarios by [Sending and Executing Generic XCM Messages](/builders/interoperability/xcm/send-execute-xcm/){target=\_blank}, or how to use the [XCM Utilities Precompile](/builders/interoperability/xcm/xcm-utils/){target=\_blank} to access XCM_related utility functions directly within the EVM ## General XCM Definitions {: #general-xcm-definitions } - **XCM** — stands for Cross-Consensus Message. It is a general way for consensus systems to communicate with each other - **VMP** — stands for Vertical Message Passing, one of the transport methods for XCMs. It allows parachains to exchange messages with the relay chain. *UMP* (Upward Message Passing) enables parachains to send messages to their relay chain, while *DMP* (Downward Message Passing) enables the relay chain to pass messages down to one of their parachains - **XCMP** — stands for Cross-Consensus Message Passing, one of the transport methods for XCMs. It allows parachains to exchange messages with other parachains on the same relay chain - **HRMP** — stands for Horizontal Relay-routed Message Passing, a stop-gap protocol while a full XCMP implementation is launched. It has the same interface as XCMP, but messages are stored on the relay chain - **Sovereign account** — an account each chain in the ecosystem has, one for the relay chain and the other for other parachains. It is calculated as the `blake2` hash of a specific word and parachain ID concatenated (`blake2(para+ParachainID)` for the Sovereign account in the relay chain, and `blake2(sibl+ParachainID)` for the Sovereign account in other parachains), truncating the hash to the correct length. The account is owned by root and can only be used through SUDO (if available) or [governance (referenda)](/learn/features/governance/){target=\_blank}. The Sovereign account typically signs XCM messages in other chains in the ecosystem - **Multilocation** — a way to specify a point in the entire relay chain/parachain ecosystem relative to a given origin. For example, it can be used to specify a specific parachain, asset, account, or even a pallet inside a parachain. In general terms, a multilocation is defined with a `parents` and an `interior`: - `parents` - refers to how many "hops" into a parent blockchain you need to take from a given origin - `interior` - refers to how many fields you need to define the target point. For example, to target a parachain with ID `1000` from another parachain, the multilocation would be `{ "parents": 1, "interior": { "X1": [{ "Parachain": 1000 }]}}` ## Cross-Chain Transport Protocols via XCM {: #xcm-transport-protocols } XCM implements two cross-consensus or transport protocols for acting on XCM messages between its constituent parachains, Moonbeam being one of them: - **Vertical Message Passing (VMP)** — once a project is onboarded as a parachain, it automatically has a bi-directional communication channel with the relay chain. Therefore, there is no need for chain registration. VMP is divided into two kinds of message-passing transport protocols: * **Upward Message Passing (UMP)** — allows parachains to send messages to their relay chain, for example, from Moonbeam to Polkadot * **Downward Message Passing (DMP)** — allows the relay chain to pass messages down to one of their parachains, for example, from Polkadot to Moonbeam - **Cross-Chain Message Passing (XCMP)** — allows two parachains to exchange messages as long as they are connected to the same relay chain. Cross-chain transactions are resolved using a simple queuing mechanism based on a Merkle tree to ensure fidelity. Collators exchange messages between parachains, while the relay chain validators will verify that the message transmission happened !!! note Currently, while XCMP is being developed, a stop-gap protocol is implemented called Horizontal Relay-routed Message Passing (HRMP), in which the messages are stored in and read from the relay chain. This will be deprecated in the future for the full XCMP implementation. ![Vertical Message Passing and Cross-chain Message Passing Overview](/images/builders/interoperability/xcm/overview/overview-1.webp) ## Establishing Cross-Chain Communication {: #channel-registration } Before two chains can start communicating, a messaging channel must be opened. Channels are unidirectional, meaning that a channel from chain A to chain B will only pass messages from A to B. Therefore, two channels must be opened to send messages back and forth. A channel for XCMs between the relay chain and parachain is automatically opened when a connection is established. However, when parachain A wants to open a communication channel with parachain B, parachain A must send an open channel extrinsic to its network. This extrinsic is an XCM as well! Even though parachain A has expressed its intentions of opening an XCM channel with parachain B, the latter has not signaled to the relay chain its intentions to receive messages from parachain A. Therefore, to have an established channel, parachain B must send an extrinsic (an XCM) to the relay chain. The accepting channel extrinsic is similar to the previous one. However, the encoded call data only includes the new method (accept channel) and the parachain ID of the sender (parachain A in this example). Once both parachains have agreed, the channel is opened within the following epoch. To learn more about the channel registration process, please refer to the [How to Establish an XC Integration with Moonbeam](/builders/interoperability/xcm/xc-registration/xc-integration/){target=\_blank} guide. ![XCM Channel Registration Overview](/images/builders/interoperability/xcm/overview/overview-2.webp) Once the channel is established, cross-chain messages can be sent between parachains. For asset transfers, assets need to be registered before being transferred through XCMs, either by being baked into the runtime as a constant or through a pallet. Moonbeam relies on a Substrate pallet to handle asset registration without the need for runtime upgrades, making the process a lot simpler. To learn how to register an asset on Moonbeam and the information necessary to add Moonbeam assets to another chain, please refer to the [How to Register Cross-Chain Assets](/builders/interoperability/xcm/xc-registration/assets/){target=\_blank} guide. ## XCM on Moonbeam {: #moonbeam-and-xcm } As Moonbeam is a parachain within the Polkadot ecosystems, one of the most direct implementations of XCM is to enable asset transfer from Polkadot and other parachains from/to Moonbeam. This allows users to bring their tokens to Moonbeam and all its dApps. To this end, Moonbeam has introduced [XC-20s](/builders/interoperability/xcm/xc20/overview/){target=\_blank}, which expand on Moonbeam's unique Ethereum compatibility features. XC-20s allow Polkadot native assets to be represented via a standard [ERC-20 interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/assets-erc20/ERC20.sol){target=\_blank} through a precompiled contract. When these assets are registered on Moonbeam, they can be set as XCM execution fee assets. Consequently, when a user transfers such an asset to Moonbeam, a small part of the amount will be used to cover the XCM execution fees. In addition, ERC-20s that are deployed to Moonbeam can be sent to other chains in the Polkadot ecosystem via XCM. Consequently, from a developer's perspective, XC-20s are ERC-20 tokens with the added benefit of being an XCM cross-chain asset, and dApps can easily support them through a familiar ERC-20 interface. ![Moonbeam XC-20 XCM Integration With Polkadot](/images/builders/interoperability/xcm/overview/overview-3.webp) To send XC-20s across the Polkadot ecosystem from Moonbeam, developers need to use the [Polkadot XCM Pallet](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} for transfers via the Substrate API and the [X-Tokens Precompile](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-precompile/){target=\_blank} or the [XCM Precompile](/builders/interoperability/xcm/xc20/send-xc20s/eth-api/){target=\_blank} for transfers via the Ethereum API. Another unique feature of Moonbeam is the ability to initiate XCM actions from EVM smart contracts or to call its EVM through XCM messages via remote execution. This unlocks a new set of possibilities, where contracts on Moonbeam can access parachain-specific functionalities via XCM, or other parachain ecosystems can use EVM smart contracts on Moonbeam to expand their functions. The following sections provide a high-level overview of the main use cases mentioned before. ### XCM Transfers between Moonbeam & Polkadot {: #transfers-moonbeam-polkadot } As Moonbeam is a parachain within the Polkadot ecosystem, a straightforward implementation of XCM + VMP is DOT transfers from/to Polkadot/Moonbeam. To this end, DOT was registered as [_xcDOT_](https://moonscan.io/token/0xffffffff1fcacbd218edc0eba20fc2308c778080){target=\_blank} on Moonbeam. Alice (Polkadot) wants to transfer a certain amount of DOT from Polkadot to her account on Moonbeam, named Alith. Therefore, she initiates an XCM that expresses her intentions. For such transfers, Moonbeam owns a Sovereign account on Polkadot. Consequently, the XCM message execution on Polkadot will transfer the amount of DOT to Moonbeam's Sovereign account on Polkadot. Once the assets are deposited, the second part of the message is sent to Moonbeam. Moonbeam will locally execute the action the XCM message is programmed to do. In this case, it is to mint and transfer the same amount of _xcDOT_ to the account defined by Alice, which in this case is Alith. The fee to execute the XCM in the target parachain is paid in the asset being transferred (_xcDOT_ for this example). ![Transfers from the Relay Chain to Moonbeam](/images/builders/interoperability/xcm/overview/overview-4.webp) Note the following: - The Alice and Alith accounts can be different. For example, Polkadot's accounts are SR25519 (or ED25519), while Moonbeam's are ECDSA (Ethereum-styled) accounts. They can also have different owners - There is a certain degree of trust where one chain relies on the other to execute its part of the XCM message. This is programmed at a runtime level so that it can be easily verified - For this example, _xcDOT_ is a wrapped representation of the original DOT being held in Moonbeam's Sovereign account on Polkadot. _xcDOT_ can be transferred within Moonbeam at any time, and they can be redeemed for DOT on a 1:1 basis as well (minus some fees) Alith deposited her _xcDOT_ in a liquidity pool. Next, Charleth acquires some _xcDOT_ by swapping against that liquidity pool, and he wants to transfer some _xcDOT_ to Charley's Polkadot account. Therefore, he initiates an XCM that expresses his intentions. Consequently, the XCM message execution on Moonbeam will burn the number of _xcDOT_. Once the assets are burned, the second part of the message is sent to Polkadot. Polkadot will execute the action the XCM message is programmed to do locally. In this case, it is to transfer the same amount of _xcDOT_ burned from the Moonbeam Sovereign account to the account defined by Charleth, which in this case is Charley. ![Transfers Back from Moonbeam to the Relay Chain](/images/builders/interoperability/xcm/overview/overview-5.webp) ### XCM Transfers between Moonbeam & Other Parachains {: #transfers-moonbeam-other-parachains } Since Moonbeam is a parachain within the Polkadot ecosystem, a straightforward implementation of XCM and XCMP asset transfers from and to Moonbeam and other parachains. This section gives a high-level overview of the main differences compared to XCMs from Polkadot/Moonbeam. The first requirement is that a bidirectional channel between the parachains must exist, and the asset being transferred must be registered in the target parachain. Only when both conditions are met can XCMs be sent between parachains. Then, when Alith (Moonbeam) transfers a certain amount of GLMR from Moonbeam to another account (Alice) in a target parachain, tokens are sent to a Sovereign Account owned by that target parachain on Moonbeam. As the XCM message is executed in the target parachain, it is expected that this will mint and transfer the same amount of _xcGLMR_ (cross-chain GLMR) to the account defined by Alith, which in this case is Alice. The fee to execute the XCM in the target parachain is paid in the transferred asset (_xcGLMR_ for this example). ![Transfers from Moonbeam to another Parachain](/images/builders/interoperability/xcm/overview/overview-6.webp) As explained in the previous section, the process is similar for _xcGLMR_ to move back to Moonbeam. First, the XCM message execution burns the number of _xcGLMR_ returned to Moonbeam. Once burned, the remnant part of the message is sent to Moonbeam via the relay chain. Moonbeam will locally execute the XCM message's and transfer GLMR (the same amount of burned _xcGLMR_) from the target parachain Sovereign account to the specified address. ### Remote Execution between Other Chains & Moonbeam {: #execution-chains-moonbeam } As mentioned before, XCM also enables remote execution from/to Moonbeam to other chains in the Polkadot ecosystem. Similarly to the other use cases, it is necessary for XCM-specific channels to be established before remote execution can happen between the chains. Channels are general-purpose, so they can be used for both asset transfers and remote execution. Another important component is the asset for which the remote execution fees are paid. On Moonbeam, when an XC-20 is registered, it can be set as an XCM execution fee asset. Consequently, when transferring that XC-20 to Moonbeam, the XCM execution fee is deducted from the amount being transferred. For remote execution, users can include a small amount of tokens in the XCM message to cover XCM execution fees. Alice (Polkadot) wants to perform a certain remote action through a smart contract on Moonbeam. Therefore, she initiates an XCM that expresses her intentions; she must have previously funded the XCM execution account she owns on Moonbeam with either GLMR or _xcDOT_. Moonbeam will locally execute the action the XCM message is programmed to do. In this case, it is to withdraw the asset decided by Alice for the XCM execution fee and buy some execution time on Moonbeam to execute the smart contract call on Moonbeam's EVM. You can read more about the flow in detail on the [Remote Execution](/builders/interoperability/xcm/remote-execution/overview/){target=\_blank} page. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/remote-execution/overview/ --- BEGIN CONTENT --- --- title: Remote Execution Overview description: Learn the basics of remote execution via XCM messages, which allow users to execute actions on other blockchains using accounts they control remotely via XCM. categories: XCM Remote Execution, Basics --- # Remote Execution via XCM ## Introduction {: #introduction } The [Cross-Consensus Message (XCM)](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank} format defines how messages can be sent between interoperable blockchains. This format opens the door to sending an XCM message that executes an arbitrary set of bytes in a Moonbeam-based network, the relay chain, or other parachains in the Polkadot/Kusama ecosystems. Remote execution via XCM opens a new set of possibilities for cross-chain interactions, from chains executing actions on other chains to users performing remote actions without switching chains. This page covers the fundamentals of XCM remote execution. If you want to learn how to perform remote execution via XCM, please refer to the [Remote Execution via the Substrate API](/builders/interoperability/xcm/remote-execution/substrate-calls/xcm-transactor-pallet/){target=\_blank} or the [Remote Execution via the Ethereum API](/builders/interoperability/xcm/xc20/send-xc20s/xtokens-precompile/){target=\_blank} guides. ## Execution Origin {: #execution-origin } Generally speaking, all transactions have an origin, which is where a call comes from. Ethereum transactions have only one origin type, the `msg.sender`, which is the account that initiated the transaction. Substrate-based transactions are more complex, as they can have different origins with different privilege levels. This is similar to having an EVM smart contract call with a specific `require` statement in which the call must come from an allowed address. In contrast, these privilege levels are programmed in the Substrate-based runtime itself. Origins are super important across different components of the Substrate runtime and, hence, the Moonbeam runtime. For example, they define the authority level they inherit in the [on-chain governance implementation](/learn/features/governance/){target=\_blank}. During the execution of an XCM message, the origin defines the context in which the XCM is being executed. By default, the XCM is executed by the source chain's Sovereign account in the destination chain. This Polkadot-specific property of having remote origins that are calculated when executing XCM is known as [Computed Origins](/builders/interoperability/xcm/remote-execution/computed-origins/){target=\_blank} (formerly known as Multilocation Derivative Accounts). Depending on the destination chain's configuration, including the `DescendOrigin` XCM instruction can mutate the origin from which the XCM message is executed. This property is significant for remote XCM execution, as the action being executed considers the context of the newly mutated origin and not the source chain's Sovereign account. ## XCM Instructions for Remote Execution {: #xcm-instructions-remote-execution } The core XCM instructions required to perform remote execution on Moonbeam (as an example) via XCM are the following: - [`DescendOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#descend-origin){target=\_blank} - (optional) gets executed in Moonbeam. Mutates the origin to create a new Computed Origin that represents a keyless account controlled via XCM by the sender in the source chain - [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} - gets executed in Moonbeam. Takes funds from the Computed Origin - [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} - gets executed in Moonbeam. Uses the funds taken by the previous XCM instruction to pay for the XCM execution, including the remote call - [`Transact`](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} - gets executed in Moonbeam. Executes the arbitrary bytes provided in the XCM instruction The XCM instructions detailed above can be complemented by other XCM instructions to handle certain scenarios, like failure on execution, more accurately. One example is the inclusion of [`SetAppendix`](/builders/interoperability/xcm/core-concepts/instructions/#set-appendix){target=\_blank}, [`RefundSurplus`](/builders/interoperability/xcm/core-concepts/instructions/#refund-surplus){target=\_blank}, and [`Deposit`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=\_blank}. ## General Remote Execution via XCM Flow {: #general-remote-execution-via-xcm-flow } A user initiates a transaction in the source chain through a pallet that builds the XCM with at least the [required XCM instructions for remote execution](#xcm-instructions-remote-execution). The transaction is executed in the source chain, which sends an XCM message with the given instructions to the destination chain. The XCM message arrives at the destination chain, which executes it. It is executed with the source chain's Sovereign account as a Computed Origin by default. One example that uses this type of origin is when chains open or accept an HRMP channel on the relay chain. If the XCM message included a [`DescendOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#descend-origin){target=\_blank} instruction, the destination chain may mutate the origin to calculate a new Computed Origin (as is the case with Moonbeam-based networks). Next, [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=\_blank} takes funds from the Computed Origin (either a Sovereign account or mutated), which are then used to pay for the XCM execution through the [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=\_blank} XCM instruction. Note that on both instructions, you need to specify which asset you want to use. In addition, you must include the bytes to be executed in the amount of execution to buy. Lastly, [`Transact`](/builders/interoperability/xcm/core-concepts/instructions/#transact){target=\_blank} executes an arbitrary set of bytes that correspond to a pallet and function in the destination chain. You have to specify the type of origin to use (typically `SovereignAccount`) and the weight required to execute the bytes (similar to gas in the Ethereum realm). ![Diagram of the XCM instructions executed on the destination chain for remote execution.](/images/builders/interoperability/xcm/remote-execution/overview/overview-1.webp) --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc20/overview/ --- BEGIN CONTENT --- --- title: XC-20s and Cross-Chain Assets description: Learn about the types of cross-chain assets on Moonbeam, in particular, local and external XC-20s, and view a list of the external XC-20s on Moonbeam. categories: Basics, XC-20 --- # Overview of XC-20s ## Introduction {: #introduction } The [Cross-Consensus Message (XCM)](https://wiki.polkadot.com/learn/learn-xcm/){target=\_blank} format provides a universal way for blockchains to exchange messages and transfer assets. To extend this interoperability to the EVM, Moonbeam introduced XC-20s, ERC-20 tokens on Moonbeam that are fully compatible with XCM transfers. Any ERC-20 deployed on Moonbeam can be configured as an XC-20, making it accessible to any chain connected via XCM. This allows EVM-focused developers to work with familiar ERC-20 workflows while benefiting from Polkadot’s native cross-chain functionality, all without needing Substrate-specific expertise. From a technical standpoint, local XC-20s are ERC-20 tokens originating on Moonbeam (including bridged tokens deemed native once issued on Moonbeam), whereas external XC-20s are wrapped representations of tokens whose canonical ledger exists on another parachain or the relay chain. In all cases, XC-20s function just like standard ERC-20s—supporting common EVM-based use cases (such as DeFi, DEXs, and lending platforms)—but with the added advantage of seamless cross-chain operability. ![Moonbeam XC-20 XCM Integration With Polkadot](/images/builders/interoperability/xcm/overview/overview-3.webp) This page aims to cover the basics on XC-20s; if you want to learn how to interact with or transfer XC-20s, please refer to the [Send XC-20s guide](/builders/interoperability/xcm/xc20/send-xc20s/overview/){target=\_blank}. ## Types of XC-20s {: #types-of-xc-20s } There are two types of XC-20s: local and external. ### What are Local XC-20s? {: #local-xc20s } Local XC-20s are all ERC-20s that exist on the EVM, and that can be transferred cross-chain through XCM. For local XC-20s to be transferred to another parachain, the asset must be registered on that chain. When transferring local XC-20s, the underlying tokens reside in the destination chain's Sovereign account on Moonbeam. A [sovereign account](/builders/interoperability/xcm/core-concepts/sovereign-accounts/){target=\_blank} is a keyless account governed by a blockchain runtime—rather than an individual—that can hold assets and interact with other chains. Local XC-20s must follow [the ERC-20 interface outlined in this guide](/builders/interoperability/xcm/xc20/interact/#the-erc20-interface){target=\_blank}. They must implement the standard ERC-20 function signatures, including the correct function selector of the `transfer` function as described in [EIP-20](https://eips.ethereum.org/EIPS/eip-20){target=\_blank}. However, additional functionality can still be added as long as it doesn’t break the base methods. Creating a local XC-20 is equivalent to deploying a standard ERC-20 and enabling cross-chain features on any Moonbeam network. ### What are External XC-20s? {: #external-xc20s } External XC-20s are cross-chain tokens originating from another parachain or the relay chain, and they are represented on Moonbeam as ERC-20 tokens. The original tokens remain locked in a Moonbeam sovereign account on their home chain, while the wrapped ERC-20 representation can be freely utilized on Moonbeam. When you transfer external XC-20s, the canonical assets remain in the sovereign account on their source chain, while the ERC-20 representation is what circulates on Moonbeam. External XC-20s all have _xc_ prepended to their names to distinguish them as cross-chain assets. For example, DOT, native to the Polkadot relay chain, is known as xcDOT when represented as an XC-20 on Moonbeam. ### Local XC-20s vs External XC-20s {: #local-xc-20s-vs-external-xc-20s } Local XC-20s are EVM-native ERC-20 tokens whose “home” (or reserve chain) is Moonbeam from a Polkadot perspective. This includes tokens originally bridged in from outside Polkadot (for example, Wormhole-wrapped ETH), because once they’re issued on Moonbeam as ERC-20s, Polkadot views them as local to Moonbeam. When local XC-20s are transferred to another parachain, the tokens move into that chain’s sovereign account on Moonbeam. External XC-20s, on the other hand, are ERC-20 representations of tokens whose canonical ledger remains on another parachain or the relay chain. Moonbeam holds the “wrapped” version, while the underlying tokens stay locked in Moonbeam’s sovereign account on the originating chain. From a cross-chain transfer perspective, local and external XC-20s can be sent through Polkadot’s XCM infrastructure using the Ethereum or Substrate API. Because the underlying asset is an ERC-20 with EVM bytecode following the [EIP-20 token standard](https://eips.ethereum.org/EIPS/eip-20){target=\_blank}, both transfers initiated via the Substrate and Ehereum APIs generate EVM logs visible to EVM-based explorers such as [Moonscan](https://moonscan.io){target=\_blank}. In contrast, you can't send a regular ERC-20 transfer using the Substrate API. Aside from cross-chain transfers through XCM, all other XC-20 interactions (such as querying balances or adjusting allowances) must occur in the EVM. Cross-chain transfers of XC-20s are executed via the Polkadot XCM Pallet, which utilizes regular mint, burn, and transfer mechanisms of ERC-20s for the XCM asset flow. If you’d like to learn how to send XC-20s using that pallet, refer to the [Using the Polkadot XCM Pallet](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} guide. ## Asset Reserves {: #asset-reserves } When transferring tokens across chains in the Polkadot or Kusama ecosystems, each token has a “reserve” chain that holds its canonical ledger—the source of truth for minting, burning, and supply management. For XC-20s, understanding which chain is the reserve determines whether the asset is managed locally on Moonbeam or remotely on another chain. Regardless of where the reserve is located, XC-20s on Moonbeam are still ERC-20 tokens that developers and users can interact with in the EVM. However, from an XCM perspective, the reserve chain determines how the tokens are locked, unlocked, minted, or burned behind the scenes when performing cross-chain operations. ### Local Reserve Assets {: #local-reserve-assets } A local reserve asset on Moonbeam is a token whose canonical ledger—from an XCM perspective—resides natively on Moonbeam. In other words, Moonbeam is the asset’s home chain, where minting and burning take place. For example, Wormhole-wrapped ETH (wETH) is considered a local reserve asset on Moonbeam, even though Ethereum is the ultimate source of ETH. Once ETH is wrapped by Wormhole and enters the Polkadot ecosystem via Moonbeam, wETH can be transferred to other parachains through [Moonbeam Routed Liquidity (MRL)](/builders/interoperability/mrl/){target=\_blank}. The important caveat is that, on a purely Ethereum-level view, ETH remains governed by and minted on Ethereum. However, from an XCM standpoint, wETH on Moonbeam is treated as a local reserve asset, meaning the canonical supply of wETH (as far as Polkadot ecosystems are concerned) exists on Moonbeam. ### Remote Reserve Assets {: #remote-reserve-assets } A remote reserve asset is a token whose canonical ledger—the source of truth for minting and burning—resides on a chain different from where it’s currently in use. In the case of xcDOT on Moonbeam, the underlying DOT tokens representing the xcDOT remain locked in Moonbeam’s sovereign account on the Polkadot relay chain, while xcDOT functions as a wrapped representation in Moonbeam’s EVM environment. Users can hold and transact with xcDOT on Moonbeam (for DeFi, governance, and more), knowing that the underlying DOT is safely locked on the relay chain. At any point, the wrapped xcDOT can be redeemed for the original DOT, effectively burning the xcDOT and unlocking the corresponding DOT tokens on Polkadot. ## Current List of External XC-20s {: #current-xc20-assets } The current list of available external XC-20 assets per network is as follows: === "Moonbeam" | Origin | Symbol | XC-20 Address | |:---------------------:|:---------:|:------------------------------------------------------------------------------------------------------------------------------------:| | Polkadot | xcDOT | [0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080](https://moonscan.io/token/0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080){target=\_blank} | | Acala | xcaUSD | [0xfFfFFFFF52C56A9257bB97f4B2b6F7B2D624ecda](https://moonscan.io/token/0xfFfFFFFF52C56A9257bB97f4B2b6F7B2D624ecda){target=\_blank} | | Acala | xcACA | [0xffffFFffa922Fef94566104a6e5A35a4fCDDAA9f](https://moonscan.io/token/0xffffFFffa922Fef94566104a6e5A35a4fCDDAA9f){target=\_blank} | | Acala | xcLDOT | [0xFFfFfFffA9cfFfa9834235Fe53f4733F1b8B28d4](https://moonscan.io/token/0xFFfFfFffA9cfFfa9834235Fe53f4733F1b8B28d4){target=\_blank} | | Apillon | xcNCTR | [0xFfFFfFfF8A9736B44EbF188972725bED67BF694E](https://moonscan.io/token/0xFfFFfFfF8A9736B44EbF188972725bED67BF694E){target=\_blank} | | Astar | xcASTR | [0xFfFFFfffA893AD19e540E172C10d78D4d479B5Cf](https://moonscan.io/token/0xFfFFFfffA893AD19e540E172C10d78D4d479B5Cf){target=\_blank} | | Bifrost | xcBNC | [0xFFffffFf7cC06abdF7201b350A1265c62C8601d2](https://moonscan.io/token/0xFFffffFf7cC06abdF7201b350A1265c62C8601d2){target=\_blank} | | Bifrost | xcBNCS | [0xfFfffffF6aF229AE7f0F4e0188157e189a487D59](https://moonscan.io/token/0xfFfffffF6aF229AE7f0F4e0188157e189a487D59){target=\_blank} | | Bifrost | xcFIL | [0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2](https://moonscan.io/token/0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2){target=\_blank} | | Bifrost | xcvASTR | [0xFffFffff55C732C47639231a4C4373245763d26E](https://moonscan.io/token/0xFffFffff55C732C47639231a4C4373245763d26E){target=\_blank} | | Bifrost | xcvBNC | [0xffFffFff31d724194b6A76e1d639C8787E16796b](https://moonscan.io/token/0xffFffFff31d724194b6A76e1d639C8787E16796b){target=\_blank} | | Bifrost | xcvDOT | [0xFFFfffFf15e1b7E3dF971DD813Bc394deB899aBf](https://moonscan.io/token/0xFFFfffFf15e1b7E3dF971DD813Bc394deB899aBf){target=\_blank} | | Bifrost | xcvFIL | [0xFffffFffCd0aD0EA6576B7b285295c85E94cf4c1](https://moonscan.io/token/0xFffffFffCd0aD0EA6576B7b285295c85E94cf4c1){target=\_blank} | | Bifrost | xcvGLMR | [0xFfFfFFff99dABE1a8De0EA22bAa6FD48fdE96F6c](https://moonscan.io/token/0xFfFfFFff99dABE1a8De0EA22bAa6FD48fdE96F6c){target=\_blank} | | Bifrost | xcvMANTA | [0xFFfFFfFfdA2a05FB50e7ae99275F4341AEd43379](https://moonscan.io/token/0xFFfFFfFfdA2a05FB50e7ae99275F4341AEd43379){target=\_blank} | | Centrifuge | xcCFG | [0xFFfFfFff44bD9D2FFEE20B25D1Cf9E78Edb6Eae3](https://moonscan.io/token/0xFFfFfFff44bD9D2FFEE20B25D1Cf9E78Edb6Eae3){target=\_blank} | | Composable | xcIBCMOVR | [0xFfFfffFF3AFcd2cAd6174387df17180a0362E592](https://moonscan.io/token/0xFfFfffFF3AFcd2cAd6174387df17180a0362E592){target=\_blank} | | Composable | xcIBCPICA | [0xfFFFFfFFABe9934e61db3b11be4251E6e869cf59](https://moonscan.io/token/0xfFFFFfFFABe9934e61db3b11be4251E6e869cf59){target=\_blank} | | Composable | xcIBCIST | [0xfFfFffff6A3977d5B65D1044FD744B14D9Cef932](https://moonscan.io/token/0xfFfFffff6A3977d5B65D1044FD744B14D9Cef932){target=\_blank} | | Composable | xcIBCBLD | [0xFffFffff9664be0234ea4dc64558F695C4f2A9EE](https://moonscan.io/token/0xFffFffff9664be0234ea4dc64558F695C4f2A9EE){target=\_blank} | | Composable | xcIBCTIA | [0xFFFfFfff644a12F6F01b754987D175F5A780A75B](https://moonscan.io/token/0xFFFfFfff644a12F6F01b754987D175F5A780A75B){target=\_blank} | | Composable | xcIBCATOM | [0xffFFFffF6807D5082ff2f6F86BdE409245e2D953](https://moonscan.io/token/0xffFFFffF6807D5082ff2f6F86BdE409245e2D953){target=\_blank} | | Darwinia | xcRING | [0xFfffFfff5e90e365eDcA87fB4c8306Df1E91464f](https://moonscan.io/token/0xFfffFfff5e90e365eDcA87fB4c8306Df1E91464f){target=\_blank} | | DED | xcDED | [0xfFffFFFf5da2d7214D268375cf8fb1715705FdC6](https://moonscan.io/token/0xfFffFFFf5da2d7214D268375cf8fb1715705FdC6){target=\_blank} | | Equilibrium | xcEQ | [0xFffFFfFf8f6267e040D8a0638C576dfBa4F0F6D6](https://moonscan.io/token/0xFffFFfFf8f6267e040D8a0638C576dfBa4F0F6D6){target=\_blank} | | Equilibrium | xcEQD | [0xFFffFfFF8cdA1707bAF23834d211B08726B1E499](https://moonscan.io/token/0xFFffFfFF8cdA1707bAF23834d211B08726B1E499){target=\_blank} | | HydraDX | xcHDX | [0xFFFfFfff345Dc44DDAE98Df024Eb494321E73FcC](https://moonscan.io/token/0xFFFfFfff345Dc44DDAE98Df024Eb494321E73FcC){target=\_blank} | | Interlay | xcIBTC | [0xFFFFFfFf5AC1f9A51A93F5C527385edF7Fe98A52](https://moonscan.io/token/0xFFFFFfFf5AC1f9A51A93F5C527385edF7Fe98A52){target=\_blank} | | Interlay | xcINTR | [0xFffFFFFF4C1cbCd97597339702436d4F18a375Ab](https://moonscan.io/token/0xFffFFFFF4C1cbCd97597339702436d4F18a375Ab){target=\_blank} | | Manta | xcMANTA | [0xfFFffFFf7D3875460d4509eb8d0362c611B4E841](https://moonscan.io/token/0xfFFffFFf7D3875460d4509eb8d0362c611B4E841){target=\_blank} | | Nodle | xcNODL | [0xfffffffFe896ba7Cb118b9Fa571c6dC0a99dEfF1](https://moonscan.io/token/0xfffffffFe896ba7Cb118b9Fa571c6dC0a99dEfF1){target=\_blank} | | OriginTrail Parachain | xcNEURO | [0xFfffffFfB3229c8E7657eABEA704d5e75246e544](https://moonscan.io/token/0xFfffffFfB3229c8E7657eABEA704d5e75246e544){target=\_blank} | | Parallel | xcPARA | [0xFfFffFFF18898CB5Fe1E88E668152B4f4052A947](https://moonscan.io/token/0xFfFffFFF18898CB5Fe1E88E668152B4f4052A947){target=\_blank} | | Peaq | xcPEAQ | [0xFffFFFFFEC4908b74688a01374f789B48E9a3eab](https://moonscan.io/token/0xFffFFFFFEC4908b74688a01374f789B48E9a3eab){target=\_blank} | | Pendulum | xcPEN | [0xffFFfFFf2257622F345E1ACDe0D4f46D7d1D77D0](https://moonscan.io/token/0xffFFfFFf2257622F345E1ACDe0D4f46D7d1D77D0){target=\_blank} | | Phala | xcPHA | [0xFFFfFfFf63d24eCc8eB8a7b5D0803e900F7b6cED](https://moonscan.io/token/0xFFFfFfFf63d24eCc8eB8a7b5D0803e900F7b6cED){target=\_blank} | | Polkadex | xcPDEX | [0xfFffFFFF43e0d9b84010b1b67bA501bc81e33C7A](https://moonscan.io/token/0xfFffFFFF43e0d9b84010b1b67bA501bc81e33C7A){target=\_blank} | | Polkadot Asset Hub | xcPINK | [0xfFfFFfFf30478fAFBE935e466da114E14fB3563d](https://moonscan.io/token/0xfFfFFfFf30478fAFBE935e466da114E14fB3563d){target=\_blank} | | Polkadot Asset Hub | xcSTINK | [0xFffFffFf54c556bD1d0F64ec6c78f1B477525E56](https://moonscan.io/token/0xFffFffFf54c556bD1d0F64ec6c78f1B477525E56){target=\_blank} | | Polkadot Asset Hub | xcUSDC | [0xFFfffffF7D2B0B761Af01Ca8e25242976ac0aD7D](https://moonscan.io/token/0xFFfffffF7D2B0B761Af01Ca8e25242976ac0aD7D){target=\_blank} | | Polkadot Asset Hub | xcUSDT | [0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d](https://moonscan.io/token/0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d){target=\_blank} | | Polkadot Asset Hub | xcWIFD | [0xfffffffF2e1D1ac9eA1686255bEfe995B31abc96](https://moonscan.io/token/0xfffffffF2e1D1ac9eA1686255bEfe995B31abc96){target=\_blank} | | Snowbridge | WBTC.e | [0xfFffFFFf1B4Bb1ac5749F73D866FfC91a3432c47](https://moonscan.io/address/0xffffffff1B4BB1AC5749F73D866FFC91A3432C47){target=\_blank} | | Snowbridge | wstETH.e | [0xFfFFFfFF5D5DEB44BF7278DEE5381BEB24CB6573](https://moonscan.io/token/0xFfFFFfFF5D5DEB44BF7278DEE5381BEB24CB6573){target=\_blank} | | Snowbridge | WETH.e | [0xfFffFFFF86829AFE1521AD2296719DF3ACE8DED7](https://moonscan.io/token/0xfFffFFFF86829AFE1521AD2296719DF3ACE8DED7){target=\_blank} | | Subsocial | xcSUB | [0xfFfFffFf43B4560Bc0C451a3386E082bff50aC90](https://moonscan.io/token/0xfFfFffFf43B4560Bc0C451a3386E082bff50aC90){target=\_blank} | | Unique | xcUNQ | [0xFffffFFFD58f77E6693CFB99EbE273d73C678DC2](https://moonscan.io/token/0xFffffFFFD58f77E6693CFB99EbE273d73C678DC2){target=\_blank} | | Zeitgeist | xcZTG | [0xFFFFfffF71815ab6142E0E20c7259126C6B40612](https://moonscan.io/token/0xFFFFfffF71815ab6142E0E20c7259126C6B40612){target=\_blank} | _*You can check each [Asset ID](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/assets){target=\_blank} on Polkadot.js Apps_ === "Moonriver" | Origin | Symbol | XC-20 Address | |:----------------:|:-------:|:--------------------------------------------------------------------------------------------------------------------------------------------:| | Kusama | xcKSM | [0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080](https://moonriver.moonscan.io/token/0xffffffff1fcacbd218edc0eba20fc2308c778080){target=\_blank} | | Bifrost | xcBNC | [0xFFfFFfFFF075423be54811EcB478e911F22dDe7D](https://moonriver.moonscan.io/token/0xFFfFFfFFF075423be54811EcB478e911F22dDe7D){target=\_blank} | | Bifrost | xcvBNC | [0xFFffffff3646A00f78caDf8883c5A2791BfCDdc4](https://moonriver.moonscan.io/token/0xFFffffff3646A00f78caDf8883c5A2791BfCDdc4){target=\_blank} | | Bifrost | xcvKSM | [0xFFffffFFC6DEec7Fc8B11A2C8ddE9a59F8c62EFe](https://moonriver.moonscan.io/token/0xFFffffFFC6DEec7Fc8B11A2C8ddE9a59F8c62EFe){target=\_blank} | | Bifrost | xcvMOVR | [0xfFfffFfF98e37bF6a393504b5aDC5B53B4D0ba11](https://moonriver.moonscan.io/token/0xfFfffFfF98e37bF6a393504b5aDC5B53B4D0ba11){target=\_blank} | | Calamari | xcKMA | [0xffffffffA083189F870640B141AE1E882C2B5BAD](https://moonriver.moonscan.io/token/0xffffffffA083189F870640B141AE1E882C2B5BAD){target=\_blank} | | Crab | xcCRAB | [0xFFFffFfF8283448b3cB519Ca4732F2ddDC6A6165](https://moonriver.moonscan.io/token/0xFFFffFfF8283448b3cB519Ca4732F2ddDC6A6165){target=\_blank} | | Crust-Shadow | xcCSM | [0xffFfFFFf519811215E05eFA24830Eebe9c43aCD7](https://moonriver.moonscan.io/token/0xffFfFFFf519811215E05eFA24830Eebe9c43aCD7){target=\_blank} | | Heiko | xcHKO | [0xffffffFF394054BCDa1902B6A6436840435655a3](https://moonriver.moonscan.io/token/0xffffffFF394054BCDa1902B6A6436840435655a3){target=\_blank} | | Integritee | xcTEER | [0xFfFfffFf4F0CD46769550E5938F6beE2F5d4ef1e](https://moonriver.moonscan.io/token/0xFfFfffFf4F0CD46769550E5938F6beE2F5d4ef1e){target=\_blank} | | Karura | xcKAR | [0xFfFFFFfF08220AD2E6e157f26eD8bD22A336A0A5](https://moonriver.moonscan.io/token/0xFfFFFFfF08220AD2E6e157f26eD8bD22A336A0A5){target=\_blank} | | Karura | xcaSEED | [0xFfFffFFfa1B026a00FbAA67c86D5d1d5BF8D8228](https://moonriver.moonscan.io/token/0xFfFffFFfa1B026a00FbAA67c86D5d1d5BF8D8228){target=\_blank} | | Khala | xcPHA | [0xffFfFFff8E6b63d9e447B6d4C45BDA8AF9dc9603](https://moonriver.moonscan.io/token/0xffFfFFff8E6b63d9e447B6d4C45BDA8AF9dc9603){target=\_blank} | | Kintsugi | xcKINT | [0xfffFFFFF83F4f317d3cbF6EC6250AeC3697b3fF2](https://moonriver.moonscan.io/token/0xfffFFFFF83F4f317d3cbF6EC6250AeC3697b3fF2){target=\_blank} | | Kintsugi | xckBTC | [0xFFFfFfFfF6E528AD57184579beeE00c5d5e646F0](https://moonriver.moonscan.io/token/0xFFFfFfFfF6E528AD57184579beeE00c5d5e646F0){target=\_blank} | | Kusama Asset Hub | xcRMRK | [0xffffffFF893264794d9d57E1E0E21E0042aF5A0A](https://moonriver.moonscan.io/token/0xffffffFF893264794d9d57E1E0E21E0042aF5A0A){target=\_blank} | | Kusama Asset Hub | xcUSDT | [0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d](https://moonriver.moonscan.io/token/0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d){target=\_blank} | | Litmus | xcLIT | [0xfffFFfFF31103d490325BB0a8E40eF62e2F614C0](https://moonriver.moonscan.io/token/0xfffFFfFF31103d490325BB0a8E40eF62e2F614C0){target=\_blank} | | Mangata | xcMGX | [0xffFfFffF58d867EEa1Ce5126A4769542116324e9](https://moonriver.moonscan.io/token/0xffFfFffF58d867EEa1Ce5126A4769542116324e9){target=\_blank} | | Picasso | xcPICA | [0xFffFfFFf7dD9B9C60ac83e49D7E3E1f7A1370aD2](https://moonriver.moonscan.io/token/0xFffFfFFf7dD9B9C60ac83e49D7E3E1f7A1370aD2){target=\_blank} | | Robonomics | xcXRT | [0xFffFFffF51470Dca3dbe535bD2880a9CcDBc6Bd9](https://moonriver.moonscan.io/token/0xFffFFffF51470Dca3dbe535bD2880a9CcDBc6Bd9){target=\_blank} | | Shiden | xcSDN | [0xFFFfffFF0Ca324C842330521525E7De111F38972](https://moonriver.moonscan.io/token/0xFFFfffFF0Ca324C842330521525E7De111F38972){target=\_blank} | | Tinkernet | xcTNKR | [0xfFFfFffF683474B842852111cc31d470bD8f5081](https://moonriver.moonscan.io/token/0xffffffff683474b842852111cc31d470bd8f5081){target=\_blank} | | Turing | xcTUR | [0xfFffffFf6448d0746f2a66342B67ef9CAf89478E](https://moonriver.moonscan.io/token/0xfFffffFf6448d0746f2a66342B67ef9CAf89478E){target=\_blank} | _*You can check each [Asset ID](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonriver.moonbeam.network#/assets){target=\_blank} on Polkadot.js Apps_ === "Moonbase Alpha" | Origin | Symbol | XC-20 Address | |:--------------------:|:------:|:-------------------------------------------------------------------------------------------------------------------------------------------:| | Relay Chain Alphanet | xcUNIT | [0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080](https://moonbase.moonscan.io/token/0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080){target=\_blank} | _*You can check each [Asset ID](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbase.moonbeam.network#/assets){target=\_blank} on Polkadot.js Apps_ ### Retrieve List of External XC-20s and Their Metadata {: #list-xchain-assets } To fetch a list of the currently available external XC-20s along with their associated metadata, you can query the chain state using the [Polkadot.js API](/builders/substrate/libraries/polkadot-js-api/){target=\_blank}. You'll take the following steps: 1. Create an API provider for the network you'd like to get the list of assets for. You can use the following WSS endpoints for each network: === "Moonbeam" ```text wss://wss.api.moonbeam.network ``` === "Moonriver" ```text wss://wss.api.moonriver.moonbeam.network ``` === "Moonbase Alpha" ```text {{ networks.moonbase.wss_url }} ``` 2. Query the `assets` pallet for all assets 3. Iterate over the list of assets to get all of the asset IDs along with their associated metadata ```js import { ApiPromise, WsProvider } from '@polkadot/api'; const getXc20s = async () => { try { const substrateProvider = new WsProvider('INSERT_WSS_ENDPOINT'); const api = await ApiPromise.create({ provider: substrateProvider }); const assets = await api.query.assets.asset.entries(); await Promise.all( assets.map(async ([{ args: [id] }]) => { try { const metadata = await api.query.assets.metadata(id); const humanMetadata = metadata.toHuman(); console.log(`\nAsset ID: ${id}`); console.log('Metadata:'); console.log(' Name:', humanMetadata.name); console.log(' Symbol:', humanMetadata.symbol); console.log(' Decimals:', humanMetadata.decimals); console.log(' Deposit:', humanMetadata.deposit); console.log(' IsFrozen:', humanMetadata.isFrozen); console.log('-----'); } catch (error) { console.error(`Error fetching metadata for asset ${id}:`, error); } }) ); await api.disconnect(); } catch (error) { console.error('Error in getXc20s:', error); } }; getXc20s().catch(console.error); ``` The result will display the asset ID along with some additional information for all of the registered external XC-20s. ## Retrieve Local XC-20 Metadata {: #retrieve-local-xc20-metadata } Since local XC-20s are ERC-20s on Moonbeam that can be transferred via XCM to another parachain, you can interact with local XC-20s like you would an ERC-20. As long as you have the address and the ABI of the ERC-20, you can retrieve its metadata by interacting with its ERC-20 interface to retrieve the name, symbol, and decimals for the asset. The following is an example that retrieves the asset metadata for the [Jupiter token](https://moonbase.moonscan.io/token/0x9aac6fb41773af877a2be73c99897f3ddfacf576){target=\_blank} on Moonbase Alpha: === "Ethers.js" ```js import { ethers } from 'ethers'; const providerRPC = { moonbase: { name: 'moonbase', rpc: 'https://rpc.api.moonbase.moonbeam.network', // Insert your RPC URL here chainId: 1287, // 0x507 in hex, }, }; const provider = new ethers.JsonRpcProvider(providerRPC.moonbase.rpc, { chainId: providerRPC.moonbase.chainId, name: providerRPC.moonbase.name, }); // Replace with the address of the ERC-20 token const tokenAddress = '0x9Aac6FB41773af877a2Be73c99897F3DdFACf576'; const tokenABI = [ 'function name() view returns (string)', 'function symbol() view returns (string)', 'function decimals() view returns (uint8)', ]; const tokenContract = new ethers.Contract(tokenAddress, tokenABI, provider); async function getTokenMetadata() { try { const [name, symbol, decimals] = await Promise.all([ tokenContract.name(), tokenContract.symbol(), tokenContract.decimals(), ]); console.log(`Name: ${name}`); console.log(`Symbol: ${symbol}`); console.log(`Decimals: ${decimals}`); } catch (error) { console.error('Error fetching token metadata:', error); } } getTokenMetadata(); ``` === "Web3.js" ```js import { Web3 } from 'web3'; // Insert your RPC URL here const web3 = new Web3('https://rpc.api.moonbase.moonbeam.network'); // Replace with the address of the ERC-20 token const tokenAddress = '0x9Aac6FB41773af877a2Be73c99897F3DdFACf576'; const tokenABI = [ // ERC-20 ABI { constant: true, inputs: [], name: 'name', outputs: [{ name: '', type: 'string' }], payable: false, stateMutability: 'view', type: 'function', }, { constant: true, inputs: [], name: 'symbol', outputs: [{ name: '', type: 'string' }], payable: false, stateMutability: 'view', type: 'function', }, { constant: true, inputs: [], name: 'decimals', outputs: [{ name: '', type: 'uint8' }], payable: false, stateMutability: 'view', type: 'function', }, ]; const tokenContract = new web3.eth.Contract(tokenABI, tokenAddress); async function getTokenMetadata() { try { const [name, symbol, decimals] = await Promise.all([ tokenContract.methods.name().call(), tokenContract.methods.symbol().call(), tokenContract.methods.decimals().call(), ]); console.log(`Name: ${name}`); console.log(`Symbol: ${symbol}`); console.log(`Decimals: ${decimals}`); } catch (error) { console.error('Error fetching token metadata:', error); } } getTokenMetadata(); ``` === "Web3.py" ```py from web3 import Web3 web3 = Web3(Web3.HTTPProvider("https://rpc.api.moonbase.moonbeam.network")) # Replace with the address of the ERC-20 token token_address = "0x9Aac6FB41773af877a2Be73c99897F3DdFACf576" token_abi = [ # ERC-20 ABI { "constant": True, "inputs": [], "name": "name", "outputs": [{"name": "", "type": "string"}], "payable": False, "stateMutability": "view", "type": "function", }, { "constant": True, "inputs": [], "name": "symbol", "outputs": [{"name": "", "type": "string"}], "payable": False, "stateMutability": "view", "type": "function", }, { "constant": True, "inputs": [], "name": "decimals", "outputs": [{"name": "", "type": "uint8"}], "payable": False, "stateMutability": "view", "type": "function", }, ] token_contract = web3.eth.contract(address=token_address, abi=token_abi) def get_token_metadata(): try: name = token_contract.functions.name().call() symbol = token_contract.functions.symbol().call() decimals = token_contract.functions.decimals().call() print(f"Name: {name}") print(f"Symbol: {symbol}") print(f"Decimals: {decimals}") except Exception as e: print(f"Error fetching token metadata: {e}") get_token_metadata() ``` --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/interoperability/xcm/xc20/send-xc20s/overview/ --- BEGIN CONTENT --- --- title: XC-20 Transfers Overview description: Explore the types of asset transfers and some of the fundamentals of remote asset transfers via XCM, including the XCM instructions for asset transfers. categories: Basics, XC-20 --- # Overview of XC-20 Transfers ## Introduction {: #introduction } Assets can move between parachains using XCM. Two main approaches exist: - **Asset teleporting** – destroys tokens on the reserve chain and mints the same amount on the destination chain. Each chain holds the native asset as a reserve, similar to a burn-mint bridging mechanism. Because each chain can create tokens, a degree of trust is required - **Remote transfers** – moves tokens from the reserve chain to a Sovereign account (an account on the reserve chain trustlessly controlled by the destination chain). The destination chain then mints a wrapped (also called “virtual” or “cross-chain”) representation. This wrapped version is always interchangeable 1:1 with the original asset, functioning like a lock-mint and burn-unlock bridge. The chain where the asset originates is known as the reserve chain ![Asset Teleporting and Remote Transfers](/images/builders/interoperability/xcm/xc20/send-xc20s/overview/overview-1.webp) Moonbeam currently uses remote transfers for XC-20 transfers. This page covers the fundamentals of XCM-based remote transfers. To learn how to perform XC-20 transfers, refer to the the [XC-20 transfers via the Substrate API](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank} guide. ## XCM Instructions for Asset Transfers {: #xcm-instructions-for-asset-transfers } The XCM Pallet and Precompile abstract much of the complexity involved in cross-chain asset transfers, automatically constructing the necessary XCM messages. Nevertheless, having a basic understanding of the underlying instructions can be useful. For reference, you can find the Polkadot XCM Pallet extrinsics for sending XC-20s in the [Using the Polkadot XCM Pallet To Send XC-20s guide](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=_blank}. The instructions in each XCM transfer vary depending on the asset and the transfer route. For example, returning a native token like xcDOT to its reserve chain (from Moonbeam to Polkadot) differs from sending DOT from Polkadot to Moonbeam. Below are examples of the instructions commonly involved in these token transfers. ### Instructions to Transfer a Reserve Asset from the Reserve Chain {: #transfer-native-from-origin } When DOT is transferred from Polkadot to Moonbeam, the following XCM instructions are executed in sequence: 1. [`TransferReserveAsset`](/builders/interoperability/xcm/core-concepts/instructions/#transfer-reserve-asset){target=_blank} - executes on Polkadot, moving the DOT from the sender and depositing it into Moonbeam’s Sovereign account on Polkadot 2. [`ReserveAssetDeposited`](/builders/interoperability/xcm/core-concepts/instructions/#reserve-asset-deposited){target=_blank} - executes on Moonbeam, minting the corresponding ERC-20 representation of DOT (xcDOT) on Moonbeam 3. [`ClearOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#clear-origin){target=_blank} - executes on Moonbeam, clearing any origin data—previously set to Polkadot’s Sovereign account 4. [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=_blank} - executes on Moonbeam, determining the execution fees. Here, a portion of the newly minted xcDOT is used to pay the cost of XCM 5. [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=_blank} - executes on Moonbeam, delivering the xcDOT to the intended recipient’s account on Moonbeam This process invokes `TransferReserveAsset` with `assets`, `dest`, and `xcm`parameters. Within the `xcm` parameter, you typically specify the `BuyExecution` and `DepositAsset` instructions. As shown in the [`TransferReserveAsset` instruction](https://github.com/paritytech/polkadot-sdk/blob/{{ polkadot_sdk }}/polkadot/xcm/xcm-executor/src/lib.rs#L630){target=\_blank}, the flow also includes `ReserveAssetDeposited` and `ClearOrigin` to complete the transfer. For more information on constructing an XCM message for asset transfers, such as DOT to Moonbeam, refer to the [Polkadot XCM Pallet guide](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=\_blank}. ### Instructions to Transfer a Reserve Asset back to the Reserve Chain {: #transfer-native-to-origin } In scenarios where you want to move an asset back to its reserve chain, such as sending xcDOT from Moonbeam to Polkadot, Moonbeam uses the following set of XCM instructions: 1. [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=_blank} – executes on Moonbeam, taking the specified token (xcDOT) from the sender 2. [`InitiateReserveWithdraw`](/builders/interoperability/xcm/core-concepts/instructions/#initiate-reserve-withdraw){target=_blank} – executes on Moonbeam, which, burns the token on Moonbeam (removing the wrapped representation), and sends an XCM message to Polkadot, indicating the tokens should be released there 3. [`WithdrawAsset`](/builders/interoperability/xcm/core-concepts/instructions/#withdraw-asset){target=_blank} – executes on Polkadot, removing the tokens from Moonbeam’s Sovereign account on Polkadot 4. [`ClearOrigin`](/builders/interoperability/xcm/core-concepts/instructions/#clear-origin){target=_blank} – gets executed on Polkadot. Clears any origin data (e.g., the Sovereign account on Moonbeam) 5. [`BuyExecution`](/builders/interoperability/xcm/core-concepts/instructions/#buy-execution){target=_blank} – Polkadot determines the execution fees and uses part of the DOT being transferred to pay for them 6. [`DepositAsset`](/builders/interoperability/xcm/core-concepts/instructions/#deposit-asset){target=_blank} – finally, the native DOT tokens are deposited into the specified Polkadot account Steps 3 through 6 are automatically triggered by the `InitiateReserveWithdraw` instruction (step 2) and execute on Polkadot. Once `InitiateReserveWithdraw` is invoked on Moonbeam, the assembled XCM message instructs Polkadot to run those final instructions, completing the cross-chain transfer. In other words, while Moonbeam constructs the XCM instructions behind the scenes, they ultimately execute on Polkadot to complete the asset’s return to its reserve chain. For more information on constructing an XCM message to transfer reserve assets to a target chain, such as xcDOT to Polkadot, you refer to the guide to the [Polkadot XCM Pallet](/builders/interoperability/xcm/xc20/send-xc20s/xcm-pallet/){target=_blank}. !!! note The specific instructions may vary over time, but this overall flow remains consistent: the tokens are withdrawn from the user on Moonbeam, burned from the local representation, and unlocked on the reserve chain. At the end of the process, they become fully accessible again on their reserve chain. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/node-operators/networks/collators/overview/ --- BEGIN CONTENT --- --- title: Run a Collator Node description: Instructions on how to dive in and become a collator in the Moonbeam Network once you are running a node. categories: Basics, Node Operators and Collators --- # Run a Collator on Moonbeam ## Introduction {: #introduction } Collators are members of the network that maintain the parachains they take part in. They run a full node (for both their particular parachain and the relay chain), and they produce the state transition proof for relay chain validators. There are some [requirements](/node-operators/networks/collators/requirements/){target=\_blank} that need to be considered prior to becoming a collator candidate including machine, bonding, account, and community requirements. Candidates will need a minimum amount of tokens bonded (self-bonded) to be considered eligible. Only a certain number of the top collator candidates by total stake, including self-bonded and delegated stake, will be in the active set of collators. Otherwise, the collator will remain in the candidate pool. Once a candidate is selected to be in the active set of collators, they are eligible to produce blocks. Moonbeam uses the [Nimbus Parachain Consensus Framework](/learn/features/consensus/){target=\_blank}. This provides a two-step filter to allocate candidates to the active set of collators, then assign collators to a block production slot: - The parachain staking filter selects the top candidates in terms of tokens staked in each network. For the exact number of top candidates per each network and the minimum bond amount, you can check out the [Minimum Collator Bond](/node-operators/networks/collators/requirements/#minimum-collator-bond){target=\_blank} section of our documentation. This filtered pool is called selected candidates (also known as the active set), which are rotated every round - The fixed size subset filter picks a pseudo-random subset of the previously selected candidates for each block production slot Users can spin up full nodes on Moonbeam, Moonriver, and Moonbase Alpha and activate the `collate` feature to participate in the ecosystem as collator candidates. To do this, you can checkout the [Run a Node](/node-operators/networks/run-a-node/){target=\_blank} section of the documentation and spin up a node using either [Docker](/node-operators/networks/run-a-node/docker/){target=\_blank} or [Systemd](/node-operators/networks/run-a-node/systemd/){target=\_blank}. ## Join the Discord {: #join-discord } As a collator, it is important to keep track of updates and changes to configuration. It is also important to be able to easily contact us and vice versa in case there is any issue with your node, as that will not only negatively affect collator and delegator rewards, it will also negatively affect the network. For this purpose, we use [Discord](https://discord.com/invite/moonbeam){target=\_blank}. The most relevant Discord channels for collators are the following: - **tech-upgrades-announcements** — here we will publish any updates or changes in configuration changes collators will be required to follow. We will also announce any technical issues to monitor, such as network stalls - **collators** — this is the general collator discussion channel. We are proud of having an active and friendly collator community so if you have any questions, this is the place to ask. We will also ping collators here for any issues that require their attention. - **meet-the-collators** — in this channel you can introduce yourself to potential delegators After you join our Discord, feel free to DM *gilmouta* or *artkaseman* and introduce yourself. This will let us know who to contact if we see an issue with your node, and will also let us assign the relevant Discord collator role, enabling you to post in *meet-the-collators*. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/node-operators/networks/run-a-node/overview/ --- BEGIN CONTENT --- --- title: Run a Node description: Learn about all of the necessary details to run a full parachain node for the Moonbeam Network to have your RPC endpoint or produce blocks. categories: Basics, Node Operators and Collators --- # Run a Node on Moonbeam ## Introduction {: #introduction } Running a full node on a Moonbeam-based network allows you to connect to the network, sync with a bootnode, obtain local access to RPC endpoints, author blocks on the parachain, and more. There are multiple deployments of Moonbeam, including the Moonbase Alpha TestNet, Moonriver on Kusama, and Moonbeam on Polkadot. Here's how these environments are named and their corresponding [chain specification file](https://docs.polkadot.com/develop/parachains/deployment/generate-chain-specs/) names: | Network | Hosted By | Chain Name | |:--------------:|:-------------------:|:-----------------------------------:| | Moonbase Alpha | Moonbeam Foundation | {{ networks.moonbase.chain_spec }} | | Moonriver | Kusama | {{ networks.moonriver.chain_spec }} | | Moonbeam | Polkadot | {{ networks.moonbeam.chain_spec }} | !!! note Moonbase Alpha is still considered an Alphanet, and as such _will not_ have 100% uptime. The parachain might be purged as needed. During the development of your application, make sure you implement a method to redeploy your contracts and accounts to a fresh parachain quickly. If a chain purge is required, it will be announced via our [Discord channel](https://discord.com/invite/PfpUATX) at least 24 hours in advance. ## Requirements {: #requirements } Running a parachain node is similar to a typical Substrate node, but there are some differences. A Substrate parachain node is a bigger build because it contains code to run the parachain itself, as well as code to sync the relay chain and facilitate communication between the two. As such, this build is quite large and may take over 30 min and require 32GB of memory. The minimum specs recommended to run a node are shown in the following table. For our Kusama and Polkadot MainNet deployments, disk requirements will be higher as the network grows. === "Moonbeam" | Component | Requirement | |:------------:|:--------------------------------------------------------------------------------------------------------------------------:| | **CPU** | {{ networks.moonbeam.node.cores }} Cores (Fastest per core speed) | | **RAM** | {{ networks.moonbeam.node.ram }} GB | | **SSD** | {{ networks.moonbeam.node.hd }} TB (recommended) | | **Firewall** | P2P port must be open to incoming traffic:
    - Source: Any
    - Destination: 30333, 30334 TCP | === "Moonriver" | Component | Requirement | |:------------:|:--------------------------------------------------------------------------------------------------------------------------:| | **CPU** | {{ networks.moonriver.node.cores }} Cores (Fastest per core speed) | | **RAM** | {{ networks.moonriver.node.ram }} GB | | **SSD** | {{ networks.moonriver.node.hd }} TB (recommended) | | **Firewall** | P2P port must be open to incoming traffic:
    - Source: Any
    - Destination: 30333, 30334 TCP | === "Moonbase Alpha" | Component | Requirement | |:------------:|:--------------------------------------------------------------------------------------------------------------------------:| | **CPU** | {{ networks.moonbase.node.cores }} Cores (Fastest per core speed) | | **RAM** | {{ networks.moonbase.node.ram }} GB | | **SSD** | {{ networks.moonbase.node.hd }} TB (recommended) | | **Firewall** | P2P port must be open to incoming traffic:
    - Source: Any
    - Destination: 30333, 30334 TCP | !!! note If you don't see an `Imported` message (without the `[Relaychain]` tag) when running a node, you might need to double-check your port configuration. ## Running Ports {: #running-ports } As stated before, the relay/parachain nodes will listen on multiple ports. The default Substrate ports are used in the parachain, while the relay chain will listen on the next higher port. The only ports that need to be open for incoming traffic are those designated for P2P. **Collators must not have RPC or WS ports opened**. !!! note As of client v0.33.0, the `--ws-port` and `--ws-max-connections` flags have been deprecated and removed in favor of the `--rpc-port` and `--rpc-max-connections` flags for both RPC and WSS connections. The default port is `9944`, and the default maximum number of connections is set to 100. ### Default Ports for a Parachain Full-Node {: #default-ports-for-a-parachain-full-node } | Description | Port | |:--------------:|:-----------------------------------:| | **P2P** | {{ networks.parachain.p2p }} (TCP) | | **RPC & WS** | {{ networks.parachain.ws }} | | **Prometheus** | {{ networks.parachain.prometheus }} | ### Default Ports of Embedded Relay Chain {: #default-ports-of-embedded-relay-chain } | Description | Port | |:--------------:|:-------------------------------------:| | **P2P** | {{ networks.relay_chain.p2p }} (TCP) | | **RPC & WS** | {{ networks.relay_chain.ws }} | | **Prometheus** | {{ networks.relay_chain.prometheus }} | ## Installation {: #installation } There are a couple different guides to help you get started running a Moonbeam-based node: - [Using Docker](/node-operators/networks/run-a-node/docker/) - this method provides a quick and easy way to get started with a Docker container - [Using Systemd](/node-operators/networks/run-a-node/systemd/) - this method is recommended for those with experience compiling a Substrate node ## Debug, Trace and TxPool APIs {: #debug-trace-txpool-apis } You can also gain access to some non-standard RPC methods by running a tracing node, which allow developers to inspect and debug transactions during runtime. Tracing nodes use a different Docker image than a standard Moonbase Alpha, Moonriver, or Moonbeam node. Check out the [Run a Tracing Node](/node-operators/networks/tracing-node/) guide and be sure to switch to the right network tab throughout the instructions. Then to interact with your tracing node, check out the [Debug & Trace](/builders/ethereum/json-rpc/debug-trace/) guide. ## Lazy Loading {: #lazy-loading } Lazy loading lets a Moonbeam node operate while downloading network state in the background, eliminating the need to wait for full synchronization before use. You can activate lazy loading with the following flag: - **`--lazy-loading-remote-rpc`** - allows lazy loading by relying on a specified RPC for network state until the node is fully synchronized e.g. `--lazy-loading-remote-rpc 'INSERT-RPC-URL'` Upon spooling up a node with this feature, you'll see output like the following:
[Lazy loading 🌗]
You are now running the Moonbeam client in lazy loading mode, where data is retrieved
from a live RPC node on demand.
Using remote state from: https://moonbeam.unitedbloc.com
Forking from block: 8482853
To ensure the client works properly, please note the following:
1. *Avoid Throttling*: Ensure that the backing RPC node is not limiting the number of
requests, as this can prevent the lazy loading client from functioning correctly;
2. *Be Patient*: As the client may take approximately 20 times longer than normal to
retrieve and process the necessary data for the requested operation.
The service will start in 10 seconds...
!!! note Lazy loading a Moonbeam requires a large number of RPC requests. To avoid being rate-limited by a public endpoint, it's highly recommended to use a [dedicated endpoint](/builders/get-started/endpoints#endpoint-providers). You can further customize your use of the lazy loading functionality with the following optional parameters: - **`--lazy-loading-block`** - specifies a block hash from which to start loading data. If not provided, the latest block will be used - **`--lazy-loading-delay-between-requests`** - the delay (in milliseconds) between RPC requests when using lazy loading. This parameter controls the amount of time to wait between consecutive RPC requests. This can help manage request rate and avoid overwhelming the server. Default value is `100` milliseconds - **`--lazy-loading-max-retries-per-request`** - the maximum number of retries for an RPC request when using lazy loading. Default value is `10` retries - **`--lazy-loading-runtime-override`** - path to a WASM file to override the runtime when forking. If not provided, it will fetch the runtime from the block being forked - **`--lazy-loading-state-overrides`** - path to a JSON file containing state overrides to be applied when forking The state overrides file should define the respective pallet, storage item, and value that you seek to override as follows: ```json [ { "pallet": "System", "storage": "SelectedCandidates", "value": "0x04f24ff3a9cf04c71dbc94d0b566f7a27b94566cac" } ] ``` ## Logs and Troubleshooting {: #logs-and-troubleshooting } You will see logs from both the relay chain and the parachain. The relay chain will be prefixed by `[Relaychain]`, while the parachain has no prefix. ### P2P Ports Not Open {: #p2p-ports-not-open } If you don't see an `Imported` message (without the `[Relaychain]` tag), you need to check the P2P port configuration. P2P port must be open to incoming traffic. ### In Sync {: #in-sync } Both chains must be in sync at all times, and you should see either `Imported` or `Idle` messages and have connected peers. ### Genesis Mismatching {: #genesis-mismatching } The Moonbase Alpha TestNet may need to be purged and upgraded once in a while. Consequently, you may see the following message: ```text DATE [Relaychain] Bootnode with peer id `ID` is on a different chain (our genesis: GENESIS_ID theirs: OTHER_GENESIS_ID) ``` This typically means that you are running an older version and will need to upgrade. We announce the upgrades (and corresponding chain purge) via our [Discord channel](https://discord.com/invite/PfpUATX) at least 24 hours in advance. Instructions for purging chain data will vary slightly depending on how you spun up your node: - For Docker, you can check out the [Purge Your Node](/node-operators/networks/run-a-node/docker/#purge-your-node) section of the [Using Docker](/node-operators/networks/run-a-node/docker/) page - For Systemd, you can take a look at the [Purge Your Node](/node-operators/networks/run-a-node/systemd/#purge-your-node) section of the [Using Systemd](/node-operators/networks/run-a-node/systemd/) page --- END CONTENT --- ## Reference Concepts [shared: true] The following section contains reference material for Moonbeam. It includes network endpoints, JSON-RPC methods, and contract or token addresses. While it may not be required for all use cases, it offers a deeper technical layer for advanced development work. --- ## List of shared concept pages: ## Full content for shared concepts: Doc-Content: https://docs.moonbeam.network/learn/dapp-directory/ --- BEGIN CONTENT --- --- title: List your Dapp on the Moonbeam DApp Directory description: Follow this tutorial to learn how to list your Moonbeam or Moonriver project or update a current listing on the Moonbeam Foundation DApp Directory. dropdown_description: Explore the DApp Directory and listing process categories: Reference --- # How to List your Project on the Moonbeam DApp Directory ## Introduction to the Moonbeam DApp Directory {: #introduction-to-state-of-the-dapps } The Moonbeam ecosystem comprises two distinct production networks: Moonbeam and Moonriver. Each network has its own dedicated [DApp Directory](https://apps.moonbeam.network/moonbeam/app-dir){target=\_blank}, maintained by the Moonbeam Foundation. These directories categorize projects spanning from DeFi to NFTs to gaming, providing users with comprehensive access to diverse applications. You'll supply core project details like name, description, and relevant links when adding your project. Depending on your project type, you may include additional data such as on-chain stats and token information. Despite the distinction between the Moonbeam and Moonriver DApp directories, the submission process remains the same. To list your project on the DApp Directory, you must submit a pull request to the [Moonbeam Foundation's App Directory Data repository on GitHub](https://github.com/moonbeam-foundation/app-directory-data){target=\_blank}. This guide outlines the necessary data and formatting specifics for your submission. ![The Moonbeam DApp Directory home page](/images/learn/dapps-list/directory-1.webp) ## Overview of the Project Data {: #overview-project-data } There are four main sources of data that are used for a project's listing in the Moonbeam DApp Directory: - **Core Project Data** - core project data such as descriptions, logos, and screenshots. This data also includes IDs used to query data from external platforms - **Active Users and Transaction Volume** - on-chain data based on smart contract activity for all of the contracts associated with the project. Data is discovered via the use of contract labeling in Moonscan, which is then indexed by Web3Go and consumed by the DApp Directory - **TVL Data** - TVL data for the protocol, sourced from the project's listing on DefiLlama - **Project Token Information** - token information, which is sourced from the project's listing on CoinGecko ## Prerequisites for Using External Data Sources {: #configuring-external-data-sources } Before pulling data from the mentioned sources, certain prerequisites must be fulfilled. However, it's worth noting that these steps may not apply to all project types. For instance, in the case of wallets, where there are no smart contracts, the DApp Directory is currently unable to display user and transaction activity data. ### Configure the Data Source for Active Users and Transaction Volume {: #configure-active-users } For projects that have smart contracts deployed on Moonbeam or Moonriver, it is important that those contracts can be linked to the DApp Directory project data. The end-to-end flow for linking smart contract activity to the DApp Directory is as follows: 1. The smart contract owner fills in the [form to label contracts on Moonscan](https://moonscan.io/contactus?id=5){target=\_blank} 2. The contracts become labeled in Moonscan 3. Periodically, the entire list of labeled contracts is exported and transmitted to Web3Go to be ingested 4. Every hour, Web3Go loads smart contract activity within Moonbeam and Moonriver and runs a job to index this data by the labels To get your project's smart contracts properly labeled on [Moonscan](https://moonscan.io){target=\_blank}, please refer to Web3Go's documentation on the [Labeling Structure](https://dinlol.gitbook.io/moonscan-smart-contract-label-for-projects/labeling-structure){target=\_blank} and [How to Submit Contract Information](https://dinlol.gitbook.io/moonscan-smart-contract-label-for-projects/how-to-submit-contract-information){target=\_blank} on Moonscan. Once you've labeled your smart contracts and are ready to submit your project to the DApp Directory, configuring the Directory to utilize your smart contract data becomes straightforward. You'll only need the **Project** component of your labeled contracts. Consider the following example project with two smart contracts: a Comptroller and a Router recently updated to a new version. | Project | Contract Name | Contract Version | Resulting Label | |:----------:|:-------------:|:----------------:|:--------------------------:| | My Project | Comptroller | V1 | My Project: Comptroller V1 | | My Project | Router | V2 | My Project: Router V2 | To submit your project to the Moonbeam DApp Directory, ensure you have your **Project** name ready, identified here as `My Project`. If you're ready to add your project to the DApp Directory, skip to the [How to Submit Your Project Listing](#how-to-submit-your-project-listing) section. ### Configure the Data Source for TVL {: #configure-tvl } If the project represents a DeFi protocol with TVL (whereby value is locked in the protocol's smart contract), it is possible to display TVL in the Moonbeam DApp Directory. TVL data is pulled from [DefiLlama](https://defillama.com){target=\_blank}, so you must list your project there. To get your project listed, please refer to DefiLlama's documentation on [How to list a DeFi project](https://docs.llama.fi/list-your-project/submit-a-project){target=\_blank}. After listing your project, you can easily configure the DApp Directory to pull data from DefiLlama. To do so, you'll need the DefiLlama identifier, which you can find in the URL for your protocol's page. For example, the URL for Moonwell's page is `https://defillama.com/protocol/moonwell`, so the identifier is `moonwell`. If you have the identifier and are ready to submit your project to the Moonbeam DApp Directory, skip to the [How to Submit Your Project Listing](#how-to-submit-your-project-listing) section. ### Configure the Data Source for Project Token Information {: #project-token-information } If a project has a token, it is possible to display the name of the token, current price, and contract in the DApp Directory. However, the data is pulled from [CoinGecko](https://www.coingecko.com){target=\_blank}, so the project's token must be listed there. If your token is not listed there, you can complete [CoinGecko's Request Form](https://support.coingecko.com/hc/en-us/requests/new){target=\_blank} to initiate the listing process. Assuming your project's token is listed there, you must obtain the CoinGecko **API ID** value. You can find the **API ID** value in the **Information** section of the token's page on CoinGecko. For example, the **API ID** on [Moonwell's token page](https://www.coingecko.com/en/coins/moonwell){target=\_blank} is `moonwell-artemis`. If you have the CoinGecko ID and are ready to submit your project to the Moonbeam DApp Directory, you can continue to the next section. ## How to Submit Your Project Listing {: #how-to-submit-your-project-listing } As mentioned, you must submit a pull request to the Moonbeam Foundation's GitHub repository that holds the DApp Directory's data. Before getting started, it's worth noting that to expedite the review process, the GitHub user who submits the pull request is recommended to be a major contributor to the project's GitHub so that the Moonbeam Foundation can quickly verify that they represent the project. You can check out the [Review Process](#review-process) section for more information. To begin, you have two options for adding your project information to the [`app-directory-data` repository on GitHub](https://github.com/moonbeam-foundation/app-directory-data){targe\_blank}. You can utilize [GitHub's browser-based editor](https://github.dev/moonbeam-foundation/app-directory-data){target=\_blank}, which offers a user-friendly interface. ![The app-directory-data repository loaded on GitHub's browser-based editor](/images/learn/dapps-list/directory-2.webp) Or you can clone the repository locally and make modifications using your preferred code editor, in which you can use the following command to clone the repository: ```bash git clone https://github.com/moonbeam-foundation/app-directory-data.git ``` Once you've cloned the project, you can create a new branch to which you will add all of your changes. To do this on the browser-based editor, take the following steps: 1. Click on the current branch name in the bottom left corner 2. A menu will appear at the top of the page. Enter the name of your branch 3. Click **Create new branch...** ![Create a new branch on GitHub's browser-based editor](/images/learn/dapps-list/directory-3.webp) The page will reload, and your branch name will now be displayed in the bottom left corner. ### Projects with Deployments on Moonbeam and Moonriver {: #projects-with-deployments } If a project is deployed to both Moonbeam and Moonriver, there are two different options available: - Create a separate project structure for each deployment - Use a single project structure and modify the project data file for both projects Separate project structures should be used if: - The two deployments have distinct representations in DefiLlama (i.e., two distinct identifiers) - The project has two different tokens, one native to Moonbeam and one native to Moonriver Otherwise, either option may be used. ### Set Up the Folder Structure for Your Project {: #set-up-the-file-structure } All configurations for each project listed in the DApp Directory are stored in the `projects` folder. To get started, you must have a name that uniquely and properly identifies your project. Using your project name, you can take the following steps: 1. Create a new directory for your project using your unique project name 2. In your project directory, you'll need to create: 1. A project data file is a JSON file that defines all your project data and contains references to the images stored in the `logos` and `screenshots` folders. The list of fields you can use to define your data, with descriptions, is outlined in the next section. The file must be named using your unique project name 2. A `logos` folder where your project logo images are stored 3. (Optional) A `screenshots` folder where screenshots for the project are stored ??? code "Example folder structure" ```text my-project ├── my-project.json ├── logos │ ├── my-project-logo-small.jpeg │ └── my-project-logo-full.jpeg └── screenshots ├── my-project-screenshot1-small.jpeg ├── my-project-screenshot1-full.jpeg ├── my-project-screenshot2-small.jpeg └── my-project-screenshot2-full.jpeg ``` ![The file structure displayed on GitHub's browser-based editor](/images/learn/dapps-list/directory-4.webp) With the foundational file structure in place, you're ready to populate the necessary information for your project submission. ### Add Information to the Project Data File {: #add-information } Your project's data file is where you'll add all the information for your project. The file permits the following top-level properties: |
Property
| Type | Description | |:--------------------------------------:|:-----------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | `id` | String | Unique identifier for the dApp in the Moonbeam DApp Directory. It should be a unique, human-readable string representing this project. E.g., `my-project` | | `slug` | String | Identifier used in certain third-party sources. In particular, if the project is listed in DefiLlama, this value should be set to the DefiLlama identifier. See the [Configure the Data Source for TVL](#configure-tvl) section for more information | | `name` | String | The project name as it will appear in the DApp Directory. E.g., `My Project` | | `category` | String | The category the project should be associated with. A project can only have one category, and it corresponds to the category list in the left-hand nav of the DApp Directory. See the [Category and Tags](#category-and-tags) section for the accepted list of values | | `coinGeckoId` | String | If the project has a token listed on CoinGecko, this property should have the **API ID** value corresponding to the given token. See the [Configure the Data Source for Project Token Information](#project-token-information) section for more information | | `chains` | Array of Strings | List of Moonbeam ecosystem chains on which the project is deployed. Valid values are currently `moonbeam` and `moonriver` | | `web3goIDs` | Array of Strings | List of Web3Go identifiers for a given dApp. The identifiers should correspond to the **Project** component of the smart contract labels set up in Moonscan. Generally, there should only be one value in the array. See the [Configure the Data Source for Active Users and Transaction Volume](#configure-active-users) section for more information | | `logo` | Map of Strings to JSON objects | Map of logo image files associated with this project and stored in the `logos` directory. See the [Logos](#logos) section for more information | | `shortDescription` | String | A short description of the project used in the display card when browsing dapps in the directory. This should be kept to under 80 characters | | `description` | String | A longer description used in the project detail page. Markdown or similar formatting cannot be used. Line breaks can be used using `\r\n`. The text should be limited to a few paragraphs | | `tags` | Array of Strings | A list of applicable [tags](#category-and-tags) for this project. Tag values will show up in the project details. See the [Category and Tags](#category-and-tags) section for the accepted list of values | | `contracts` | Array of contract JSON objects | List of contracts for the project. Currently, this is used only for token contracts. The list of smart contracts which make up the protocol is externally sourced from Moonscan. See the [Contracts](#contracts) section for more information | | `urls` | Map of Strings (names) to Strings (URLs) | Mapping of URLs for websites and socials associated with the project. See the [URLs](#urls) section for the accepted list of properties | | `screenshots` | Array of Maps of Strings (size) to image JSON objects | List of screenshot image files associated with this project and stored in the `screenshots` directory. See the [Screenshots](#screenshots) section for more information | | `projectCreationDate` | int | The date the project was created. Used for sorting purposes in the DApp Directory | ??? code "Example project data file" ```json { "id": "moonwell", "slug": "moonwell", "name": "Moonwell", "category": "lending", "coinGeckoId": "moonwell-artemis", "chains": [ "moonbeam" ], "web3goIDs": [ "Moonwell Artemis" ], "logo": { "small": { "fileName": "moonwell-logo-small.jpeg", "width": 40, "height": 40, "mimeType": "image/jpeg" }, "large": { "fileName": "moonwell-logo-large.jpeg", "width": 400, "height": 400, "mimeType": "image/jpeg" }, "full": { "fileName": "moonwell-logo-full.jpeg", "width": 3000, "height": 3000, "mimeType": "image/jpeg" } }, "shortDescription": "Lending, borrowing, and DeFi protocol built on Moonbeam and Moonriver", "description": "Moonwell is an open lending, borrowing, and decentralized finance protocol built on Moonbeam and Moonriver. Moonwell’s composable design can accommodate a full range of DeFi applications in the greater Polkadot and Kusama (DotSama) ecosystem.\r\n\r\nOur first deployment will be on Kusama’s Moonriver, the sister network of Polkadot’s Moonbeam. Moonriver is where new products are expected to be incubated and developed prior to being deployed on Moonbeam.", "tags": [ "Lending", "DeFi" ], "contracts": [ { "contract": "0x511ab53f793683763e5a8829738301368a2411e3", "chain": "moonbeam", "name": "WELL Token" } ], "urls": { "website": "https://moonwell.fi/", "try": "https://moonwell.fi/", "twitter": "https://twitter.com/MoonwellDeFi", "medium": "https://moonwell.medium.com/", "telegram": "https://t.me/moonwellfichat", "github": "https://github.com/moonwell-open-source", "discord": "https://discord.gg/moonwellfi" }, "screenshots": [ { "small": { "fileName": "moonwell-screenshot-small1.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "moonwell-screenshot-full1.png", "width": 514, "height": 300, "mimeType": "image/png" } }, { "small": { "fileName": "moonwell-screenshot-small2.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "moonwell-screenshot-full2.png", "width": 1716, "height": 800, "mimeType": "image/png" } }, { "small": { "fileName": "moonwell-screenshot-small3.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "moonwell-screenshot-full3.png", "width": 1054, "height": 637, "mimeType": "image/png" } }, { "small": { "fileName": "moonwell-screenshot-small4.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "moonwell-screenshot-full4.png", "width": 1365, "height": 436, "mimeType": "image/png" } } ], "projectCreationDate": 1644828523000 } ``` #### Category and Tags {: #category-and-tags } A category is the primary classification for a project. A project can be categorized under only one category, but it can have multiple tags. Ensure you carefully select the most applicable category for your project to ensure it is easily found. Any secondary classifications can be included as a tag. The currently supported values for `category` are: ```text - Bridges - DAO - DEX - DeFi - Gaming - Lending - NFTs - Other - Social - Wallets ``` The currently supported values for `tag` are: ```text - Bridges - DAO - DEX - DeFi - DePIN - Developer Tools - Explorers - Files - GLMR Grants - Gaming - Infrastructure - IoT - Lending - MOVR Grants - Messaging - NFT - NFT Marketplaces - On-ramp - Other - Social - Tool - VPN - Wallets - ZeroTrust ``` #### URLs {: #urls } The `urls` property name/value pairs are used so a project can provide links to their website, socials, etc. The following table lists the supported `urls` properties: | Property Name | Description | Example | |:-------------:|:------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------:| | `website` | The main website for the project | https://moonbeam.network/ | | `try` | URL a user should visit if they want to try out the dApp. Typically, this page will have a link to launch the dApp | https://moonbeam.network/ | | `twitter` | The project's Twitter profile | https://twitter.com/MoonbeamNetwork | | `medium` | The project's Medium site | https://medium.com/moonbeam-network | | `telegram` | The project's Telegram | https://t.me/Moonbeam_Official | | `github` | The project's GitHub repository | https://github.com/moonbeam-foundation/moonbeam | | `discord` | The project's Discord | https://discord.com/invite/PfpUATX | The format of the property name/value pairs should follow the JSON standard, for example: ```json "urls": { "website": "https://moonbeam.network/", "try": "https://docs.moonbeam.network/", "twitter": "https://twitter.com/MoonbeamNetwork" } ``` #### Logos {: #logos } The `logos` property of the main project data file is a map of image sizes (i.e., `small`, `large`, `full`) to corresponding image JSON objects. The image JSON object contains the display properties for the given image. The following table lists the properties of the image JSON object: | Property | Type | Description | |:----------:|:------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------:| | `fileName` | String | The name of the image file (unqualified) stored in the `logos` directory | | `width` | int | The width of the logo image in pixels | | `height` | int | The height of the logo image in pixels | | `mimeType` | String | The standard [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types){target=\_blank} of the file. E.g., `"image/jpeg"` | Currently, only the `small` size is utilized, and the dimensions for small logos should be 40x40 pixels. Here is an example showing the structure of the `logo` property that supplies `small` and `full` logos: ```json "logo": { "small": { "fileName": "my-project-logo-small.jpeg", "width": 40, "height": 40, "mimeType": "image/jpeg" }, "full": { "fileName": "my-project-logo-full.jpeg", "width": 3000, "height": 3000, "mimeType": "image/jpeg" } } ``` #### Screenshots {: #screenshots } The `screenshots` property of the main project data file is an array of maps. Each map in the array is for a specific screenshot. However, different-sized images for each screenshot should be supplied so that different sizes can be used in different contexts (e.g., thumbnails vs full-sized images). Thus, for each screenshot, there is a map of image sizes (i.e., `small`, `large`, `full`) to corresponding image JSON objects. The image JSON object contains the display properties for the given image. The following table lists the properties of the image JSON object: | Property | Type | Description | |:----------:|:------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------:| | `fileName` | String | The name of the image file (unqualified) stored in the `screenshots` directory | | `width` | int | The width of the logo image in pixels | | `height` | int | The height of the logo image in pixels | | `mimeType` | String | The standard [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types){target=\_blank} of the file. E.g., `"image/jpeg"` | Here is an example showing the structure of the `screenshot` property for two screenshots (`screenshot1` and `screenshot2`): ```json "screenshots": [ { "small": { "fileName": "my-project-screenshot1-small.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "my-project-screenshot1-full.png", "width": 514, "height": 300, "mimeType": "image/png" } }, { "small": { "fileName": "my-project-screenshot2-small.png", "width": 429, "height": 200, "mimeType": "image/png" }, "full": { "fileName": "my-project-screenshot2-full.png", "width": 1716, "height": 800, "mimeType": "image/png" } } ] ``` #### Contracts {: #contracts } A list of contracts for the project. Currently, this is used only for token contracts. The smart contracts that make up the protocol are sourced from [Moonscan](https://moonscan.io){target=\_blank} based on tagging, so they do not need to be listed here. If you have not properly labeled your contracts or are unsure if they are labeled according to the Moonbeam community standard, please refer to the [Configure the Data Source for Active Users and Transaction Volume](#configure-active-users) section. The following table lists the properties found in the contract JSON object: | Property | Type | Description | |:----------:|:------:|:-----------------------------------------------------------------------------:| | `contract` | String | The address for the smart contract | | `chain` | String | The chain on which the contract is deployed (i.e., `moonbeam` or `moonriver`) | | `name` | String | The name of the contract | Here is a `contracts` array with a single smart contract for the WGLMR token: ```json "contracts": [ { "contract": "0xAcc15dC74880C9944775448304B263D191c6077F", "chain": "moonbeam", "name": "Wrapped GLMR Token" } ] ``` ### Submit a Pull Request {: #submit-a-pull-request } After you've populated the project data file and added your logos and screenshots, you should be ready to submit your pull request. ![All of the project files added on GitHub's browser-based editor](/images/learn/dapps-list/directory-5.webp) From the web-based editor, take the following steps to commit your changes to the `app-directory-data` repository: 1. Click on the **Source Control** tab, which should show you how many pages have been added or changed 2. Review the files under the **Changes** section. Click the **+** button next to **Changes**, or as you review each file, click the **+** button next to the file name to add them to the list of **Staged Changes** ![Staging the changed files on GitHub's browser-based editor](/images/learn/dapps-list/directory-6.webp) All of your files should now be under the **Staged Changes** section. All you have to commit and push the changes are: 1. Enter a descriptive commit message, such as "Add My Project", making sure to use your actual project name 2. Click **Commit & Push** ![Committing the staged files on GitHub's browser-based editor](/images/learn/dapps-list/directory-7.webp) Now that you've committed the changes, you'll need to head over to the [`app-directory-data` repository](https://github.com/moonbeam-foundation/app-directory-data){target=\_blank} and open a pull request against the `develop` branch: 1. At the top of the repository page, click **Compare and Pull** button displayed on the banner, or 2. If the banner is not there anymore, you'll need to select your branch from the branches dropdown 3. Click the **Contribute** dropdown 4. Click the **Open pull request** button ![The main page of the app-directory-data repository on GitHub](/images/learn/dapps-list/directory-8.webp) You'll be taken to the **Comparing changes** page, where you'll need to: 1. Make sure that you are merging your branch into the `develop` branch, which is the **base** branch 2. Add a title 3. Add a description of the changes 4. Click **Create pull request** ![Submit a pull request on the Comparing changes page of the app-directory-data repository on GitHub](/images/learn/dapps-list/directory-9.webp) ### The Review Process {: #review-process } Submitted pull requests will be reviewed bi-weekly by the Moonbeam Foundation. During the review, and especially for new projects, the Foundation may have to verify that the GitHub user who created the pull request is a contributor and/or represents the specific project. One way projects can expedite this process is if the submitter's GitHub account is also a major contributor to the project itself on GitHub. Alternatively, teams should leave a note in the pull request comments indicating how we can get in touch with project team members to verify. A comment will be added to the pull request if any changes are requested. After your pull request has been approved, it will be merged, and your project will be added to the Moonbeam DApp Directory! ## How to Update Your Project Listing {: #how-to-update-your-project-listing } As your project evolves, you may need to update your project's listing or images related to your listing. You can create a new branch for your changes, find and modify your existing project's data from the root `projects` directory, and make the desired changes. If you are no longer using a logo or screenshot, please remember to remove it from the `logos` or `screenshots` directory. Once your changes have been made, you must follow the same instructions in the [Submit a Pull Request](#submit-a-pull-request) section so the changes can be [reviewed](#review-process) by the Moonbeam Foundation. Please note that pull requests are reviewed on a bi-weekly basis, so if the update is urgent, you can create a [forum post](https://forum.moonbeam.network){target=\_blank} asking for assistance. ## DApp Directory API {: #dapp-directory-api } The DApp Directory also features a queryable API that you can use to integrate data from Moonbeam's DApp Directory into your application. The API is public and currently does not require authentication. The base URL for the API is as follows: ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/ ``` ### Query a Project {: #query-a-project} You can retrieve all the information for a particular project by appending `/projects/INSERT_PROJECT_NAME` to the base URL. If you need clarification on the project name, you can omit the project name as shown below to retrieve data for every listed project and find the project in the response. ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/projects ``` Here's an example of querying the API for StellaSwap, which returns the project description, social media information, user counts, relevant smart contract addresses, market data, images, and more. ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/projects/stellaswap ``` You can visit the query URL directory in the browser, using a tool like Postman, or directly from the command line with Curl as follows: ```bash curl -H "Content-Type: application/json" -X GET 'https://apps.moonbeam.network/api/ds/v1/app-dir/projects/stellaswap' ``` ??? code "API Response to Querying StellaSwap" ```json { "project":{ "currentTx":{ "moonbeam":2883079 }, "web3goIDs":[ "StellaSwap" ], "name":"StellaSwap", "currentTVL":{ "moonbeam":5046832.23328 }, "currentUsers":{ "moonbeam":52455 }, "coinGeckoId":"stellaswap", "shortDescription":"The leading DEX and DeFi gateway on Moonbeam", "id":"stellaswap", "featured":true, "tags":[ "DEX", "DeFi" ], "tvlChange7d":{ "moonbeam":-1.61482567543498 }, "urls":{ "telegram":"https://t.me/stellaswap", "website":"https://stellaswap.com/", "try":"https://stellaswap.com/", "twitter":"https://twitter.com/StellaSwap", "github":"https://github.com/stellaswap", "medium":"https://stellaswap.medium.com/" }, "web3goContracts":[ { "name":"StellaSwap: stDOT Oracle Master", "chain":"moonbeam", "contract":"0x3b23f0675ffc45153eca239664ccaefc5e816b9c" }, { "name":"StellaSwap: stDOT Token", "chain":"moonbeam", "contract":"0xbc7e02c4178a7df7d3e564323a5c359dc96c4db4" }, { "name":"StellaSwap: stDOT Controller", "chain":"moonbeam", "contract":"0x002d34d6a1b4a8e665fec43fd5d923f4d7cd254f" }, { "name":"StellaSwap: stDOT Proxy Admin", "chain":"moonbeam", "contract":"0xe8a5c0039226269313c89c093a6c3524c4d39fa4" }, { "name":"StellaSwap: madUSDC GLMR V2", "chain":"moonbeam", "contract":"0x2ad0e92461df950e2b1c72e2f7a865c81eaa3ce6" }, { "name":"StellaSwap: Dual ETH - GLMR Rewarder V1", "chain":"moonbeam", "contract":"0x2ba130297d1966e077c2fb5e4b434e8802925277" }, { "name":"StellaSwap: BCMC Rewarder V1", "chain":"moonbeam", "contract":"0x18e75887aa81e113636e18d5a78e3ff93787ec88" }, { "name":"StellaSwap: Pulsar Position Manager V1", "chain":"moonbeam", "contract":"0x1ff2adaa387dd27c22b31086e658108588eda03a" }, { "name":"StellaSwap: DualETH Pool LP Token V1", "chain":"moonbeam", "contract":"0xa3ee3a0a36dc915fdc93062e4b386df37d00217e" }, { "name":"StellaSwap: Interlay Rewarder V1", "chain":"moonbeam", "contract":"0x3a7572220afaddc31a72a520642111776d92b2d2" }, { "name":"StellaSwap: Router V1", "chain":"moonbeam", "contract":"0xd0a01ec574d1fc6652edf79cb2f880fd47d34ab1" }, { "name":"StellaSwap: xStella - GLMR Rewarder 2nd V1", "chain":"moonbeam", "contract":"0xb4dba7fe6fcc613963d64204fcf789e9e376679a" }, { "name":"StellaSwap: GLMR Rewarder First V1", "chain":"moonbeam", "contract":"0x69f9d134991e141c4244f397514ba05d67861cc0" }, { "name":"StellaSwap: CELER Rewarder 0 V1", "chain":"moonbeam", "contract":"0xbebd88782a1145b71df3f4986ef7686154ce01d9" }, { "name":"StellaSwap: MATICILO V1", "chain":"moonbeam", "contract":"0xfffa340944ff32f50c7935e2b5d22a7c3393b313" }, { "name":"StellaSwap: ETHmad - GLMR V1", "chain":"moonbeam", "contract":"0x9fe074a56ffa7f4079c6190be6e8452911b7e349" }, { "name":"StellaSwap: STELLA Token", "chain":"moonbeam", "contract":"0x0e358838ce72d5e61e0018a2ffac4bec5f4c88d2" }, { "name":"StellaSwap: SFL - 4pool Wormhole V1", "chain":"moonbeam", "contract":"0xb1bc9f56103175193519ae1540a0a4572b1566f6" }, { "name":"StellaSwap: BICO Trusted Forwarder V1", "chain":"moonbeam", "contract":"0x3d08ce1f9609bb02f47192ff620634d9eb0e7b56" }, { "name":"StellaSwap: Gass Refund V1", "chain":"moonbeam", "contract":"0xee42d4861b56b32776e6fe9a2fe122af0e3f4a33" }, { "name":"StellaSwap: xcDOT - GLMR V1", "chain":"moonbeam", "contract":"0xe76215efea540ea87a2e1a4bf63b1af6942481f3" }, { "name":"StellaSwap: 4pool LP V1", "chain":"moonbeam", "contract":"0xda782836b65edc4e6811c7702c5e21786203ba9d" }, { "name":"StellaSwap: SFL LP V1", "chain":"moonbeam", "contract":"0xa0aa99f71033378864ed6e499eb03612264e319a" }, { "name":"StellaSwap: SFL - 4pool V1", "chain":"moonbeam", "contract":"0x422b5b7a15fb12c518aa29f9def640b4773427f8" }, { "name":"StellaSwap: Acala - GLMR Rewarder V1", "chain":"moonbeam", "contract":"0x9de8171bebfa577d6663b594c60841fe096eff97" }, { "name":"StellaSwap: Zap V1", "chain":"moonbeam", "contract":"0x01834cf26717f0351d9762cc9cca7dc059d140df" }, { "name":"StellaSwap: GLMR Rewarder for UST - GLMR V1", "chain":"moonbeam", "contract":"0xc85ddcff71200f9673137e2f93ce504bdbf7db4e" }, { "name":"StellaSwap: xStella Token", "chain":"moonbeam", "contract":"0x06a3b410b681c82417a906993acefb91bab6a080" }, { "name":"StellaSwap: ETHmad - GLMR V2", "chain":"moonbeam", "contract":"0xa6ec79c97e533e7bddb00898e22c6908742e039b" }, { "name":"StellaSwap: WBTC - USDT Contract V1", "chain":"moonbeam", "contract":"0xcae51da6dceacd84f79df4b88d9f92035d1479e9" }, { "name":"StellaSwap: AVAXILO V1", "chain":"moonbeam", "contract":"0x96bef4719ae7c053113292e6aa7fc36e62b243e8" }, { "name":"StellaSwap: Swap For Gas V1", "chain":"moonbeam", "contract":"0xb64dee2d182fed3dd6c273303fb08f11808c9c23" }, { "name":"StellaSwap: Farming Centre V1", "chain":"moonbeam", "contract":"0x0d4f8a55a5b2583189468ca3b0a32d972f90e6e5" }, { "name":"StellaSwap: FTMILO V1", "chain":"moonbeam", "contract":"0x096352f7ea415a336b41fc48b33142eff19a8ad8" }, { "name":"StellaSwap: Acala Rewarder V1", "chain":"moonbeam", "contract":"0xb7b5d3659ad213478bc8bfb94d064d0efdda8f7c" }, { "name":"StellaSwap: USDC Rewarder V1", "chain":"moonbeam", "contract":"0xa52123adc0bc5c4c030d1ff4f5dad966366a646c" }, { "name":"StellaSwap: Vault V1", "chain":"moonbeam", "contract":"0x54e2d14df9348b3fba7e372328595b9f3ae243fe" }, { "name":"StellaSwap: CELER Rewarder 1 V1", "chain":"moonbeam", "contract":"0x70cbd76ed57393e0cd81e796de850080c775d24f" }, { "name":"StellaSwap: Stella Timelock V1", "chain":"moonbeam", "contract":"0xc6f73b028cd3154a5bb87f49aa43aa259a6522fb" }, { "name":"StellaSwap: GLMR - MAI Vault V1", "chain":"moonbeam", "contract":"0x3a82f4da24f93a32dc3c2a28cfa9d6e63ec28531" }, { "name":"StellaSwap: UST - GLMR V1", "chain":"moonbeam", "contract":"0x556d9c067e7a0534564d55f394be0064993d2d3c" }, { "name":"StellaSwap: SFL - axlUSDC - 4pool V1", "chain":"moonbeam", "contract":"0xa1ffdc79f998e7fa91ba3a6f098b84c9275b0483" }, { "name":"StellaSwap: Stable Router V1", "chain":"moonbeam", "contract":"0xb0dfd6f3fddb219e60fcdc1ea3d04b22f2ffa9cc" }, { "name":"StellaSwap: ATOM - GLMR Rewarder New V1", "chain":"moonbeam", "contract":"0x5aa224966e302424ec13a4f51b80bcfc205984b6" }, { "name":"StellaSwap: CELR Rewarder V1", "chain":"moonbeam", "contract":"0x05ad30253f0b20be35d84253d6aca8bd7ec0c66c" }, { "name":"StellaSwap: Router V3", "chain":"moonbeam", "contract":"0xe6d0ed3759709b743707dcfecae39bc180c981fe" }, { "name":"StellaSwap: xStella - GLMR Rewarder V1", "chain":"moonbeam", "contract":"0x896135ff51debe8083a2e03f9d44b1d3c77a0324" }, { "name":"StellaSwap: XStella - MAI Vault V1", "chain":"moonbeam", "contract":"0x3756465c5b1c1c4cee473880c9726e20875284f1" }, { "name":"StellaSwap: ATOM - USDC Rewarder New V1", "chain":"moonbeam", "contract":"0x5546e272c67fac10719f1223b1c0212fa3e41a8f" }, { "name":"StellaSwap: SFL - athUSDC - 4pool V1", "chain":"moonbeam", "contract":"0x715d7721fa7e8616ae9d274704af77857779f6f0" }, { "name":"StellaSwap: IDO Locker V1", "chain":"moonbeam", "contract":"0x4b1381b5b959a8ba7f44414c7d758e53d500a8a9" }, { "name":"StellaSwap: Locker V1", "chain":"moonbeam", "contract":"0x8995066b7f1fb3abe3c88040b677d03d607a0b58" }, { "name":"StellaSwap: ATOM - USDC - GLMR Rewarder V1", "chain":"moonbeam", "contract":"0xe06e720aaed5f5b817cb3743108ae0a12fe69e9b" }, { "name":"StellaSwap: Mistake in Rewarder V1", "chain":"moonbeam", "contract":"0x168ceb7e49c21e3f37820a34590171214a765f5f" }, { "name":"StellaSwap: LP 4pool - Wormhole V1", "chain":"moonbeam", "contract":"0xb326b5189aa42acaa3c649b120f084ed8f4dcaa6" }, { "name":"StellaSwap: Farms V1", "chain":"moonbeam", "contract":"0xedfb330f5fa216c9d2039b99c8ce9da85ea91c1e" }, { "name":"StellaSwap: Factory V1", "chain":"moonbeam", "contract":"0x68a384d826d3678f78bb9fb1533c7e9577dacc0e" }, { "name":"StellaSwap: anyETH-madETH Pool", "chain":"moonbeam", "contract":"0xb86271571c90ad4e0c9776228437340b42623402" }, { "name":"StellaSwap: Dual Farms V2", "chain":"moonbeam", "contract":"0xf3a5454496e26ac57da879bf3285fa85debf0388" }, { "name":"StellaSwap: CELER Rewarder 01 - 02 V1", "chain":"moonbeam", "contract":"0x713f76076283fcd81babe06c76ff51485edf9d5e" }, { "name":"StellaSwap: SCNFT Token", "chain":"moonbeam", "contract":"0x5f23a6a0b6b90fdeeb4816afbfb2ec0408fda59e" }, { "name":"StellaSwap: ATOM - GLMR - GLMR Rewarder V1", "chain":"moonbeam", "contract":"0xe60c41de5537418fde05b804df077397dfa84d75" }, { "name":"StellaSwap: Timelock Main V1", "chain":"moonbeam", "contract":"0x9a8693c6f7bf0f44e885118f3f83e2cdb4e611b8" }, { "name":"StellaSwap: MAI - B4P - Wormhole V1", "chain":"moonbeam", "contract":"0xf0a2ae65342f143fc09c83e5f19b706abb37414d" }, { "name":"StellaSwap: LP Token V1", "chain":"moonbeam", "contract":"0x7b17122b941d2173192c7d8d68faabdc88421326" }, { "name":"StellaSwap: Multisig V1", "chain":"moonbeam", "contract":"0x4300e09284e3bb4d9044ddab31efaf5f3301daba" }, { "name":"StellaSwap: Router V2", "chain":"moonbeam", "contract":"0x70085a09d30d6f8c4ecf6ee10120d1847383bb57" }, { "name":"StellaSwap: DOTxc - GLMR V1", "chain":"moonbeam", "contract":"0x505b0a5458dd12605b84bb2928dd2bc5b44993b9" }, { "name":"StellaSwap: SFL - MAI - 4pool V1", "chain":"moonbeam", "contract":"0x7fbe3126c03444d43fc403626ec81e3e809e6b46" }, { "name":"StellaSwap: xStella - USDC Rewarder V1", "chain":"moonbeam", "contract":"0xfa16d5b8bf03677945f0a750c8d2a30001b2fa93" }, { "name":"StellaSwap: madUSDC - GLMR V1", "chain":"moonbeam", "contract":"0x9200cb047a9c4b34a17ccf86334e3f434f948301" } ], "slug":"stellaswap", "createdAt":1699292612617, "tvlChange1d":{ "moonbeam":-0.748278690902012 }, "logo":{ "small":{ "width":36, "fileName":"stellaswap-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":510, "fileName":"stellaswap-logo-large.jpeg", "mimeType":"image/jpeg", "height":510 }, "full":{ "width":3000, "fileName":"stellaswap-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "chains":[ "moonbeam" ], "usersChange7d":{ "moonbeam":-17.2727272727273 }, "marketData":{ "symbol":"stella", "marketCap":808908, "marketCapRank":2865, "priceChangePercentage1y":-43.01356, "currentPrice":0.01729378, "priceChangePercentage14d":-17.23772, "contracts":{ "moonbeam":"0x0e358838ce72d5e61e0018a2ffac4bec5f4c88d2" }, "priceChangePercentage60d":-39.75633, "priceChangePercentage30d":-26.13934, "priceChangePercentage24h":-4.63782, "priceChangePercentage200d":-74.57003, "marketCapChangePercentage24h":-4.62971, "priceChange24h":-0.0008410608839097, "marketCapChange24h":-39268.122562502, "priceChangePercentage7d":-7.91278 }, "projectCreationDate":1644828523000, "contracts":[ { "chain":"moonbeam", "contract":"0x0e358838ce72d5e61e0018a2ffac4bec5f4c88d2" } ], "updatedAt":1722544694830, "category":"dex", "description":"StellaSwap is one of the first automated market-making (AMM), decentralized exchange (DEX) for the Moonbeam parachain network. The unique value proposition of StellaSwap is that we're committed in establishing a strong foundation with our native token, STELLA, as a governance token, diverse farms, a built in bridge and user-centered service. \r\n\r\nStellaSwap's main objective is to create a broader range of network effects to address the issues of liquidity in the DeFi space, instead of limiting ourselves to a single solution like many DEXs are doing now. This manifests itself in the diverse product suite of StellaSwap that will be explained in more details. Our products are structured in such a way that facilitates decentralized governance of STELLA holders, while continuing to innovate on the collective foundations by design.", "usersChange1d":{ "moonbeam":-6.18556701030928 } } } ``` ### Query a Category {: #query-a-category} You can also query the API by [category](#category-and-tags). For example, you can retrieve information about all NFT projects with the following query: ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/projects?category=nfts ``` ??? code "API Response to Querying NFT projects" ```json { "projects":[ { "urls":{ "telegram":"https://t.me/nfts2me", "website":"https://nfts2me.com/", "try":"https://nfts2me.com/", "twitter":"https://twitter.com/nfts2me", "medium":"https://nfts2me.medium.com/", "discord":"https://nfts2me.com/discord/" }, "slug":"nfts2me", "createdAt":1699292617117, "logo":{ "small":{ "width":36, "fileName":"nfts2me-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"nfts2me-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"nfts2me-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"NFTs2Me", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1673608509000, "shortDescription":"NFTs2Me is a toolkit for creating and managing NFT projects.", "contracts":[ { "chain":"moonbeam", "contract":"0x2269bCeB3f4e0AA53D2FC43B1B7C5C5D13B119a5" } ], "updatedAt":1722498896566, "category":"nfts", "description":"NFTs2Me is a tool for creating and managing NFT projects. It includes features such as an art generator, delayed reveal, minting widget, token gating, and support for multiple blockchain platforms. It also offers customization options, an affiliate system, automatic logo and banner generation, and support for redeemable NFTs. It is user-friendly and suitable for those new to the world of NFTs.\n\nIn addition to these features, NFTs2Me also offers a minting widget and free IPFS hosting to make it simple to mint and store your NFTs securely and efficiently. The minting widget allows you to easily create and mint new NFTs, while the free IPFS hosting provides a secure and decentralized way to store your NFTs.", "id":"nfts2me", "tags":[ "NFT", "Tool" ] }, { "urls":{ "telegram":"https://t.me/rmrkapp", "website":"https://singular.app/", "try":"https://singular.app/", "twitter":"https://twitter.com/RmrkSingular", "discord":"https://discord.gg/TjB6v5AGZz" }, "slug":"singular-app", "createdAt":1699292616171, "logo":{ "small":{ "width":36, "fileName":"singular-app-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":400, "fileName":"singular-app-logo-large.png", "mimeType":"image/png", "height":400 }, "full":{ "width":3000, "fileName":"singular-app-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"Singular App", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1686240710000, "shortDescription":"The home of NFTs by @RmrkApp. Create and trade your nestable, equippable, soulbound, and multi-asset NFTs with us - no coding required.", "contracts":[ ], "updatedAt":1722498914806, "category":"nfts", "description":"Singular is an NFT 2.0 marketplace that allows users to buy, sell, and trade both regular and advanced NFTs. Users can create and/or connect a wallet, browse digital items, and securely conduct transactions using blockchain technology.", "id":"singular-app", "tags":[ "NFT Marketplaces" ] }, { "urls":{ "telegram":"https:/t.me/metacourtgg", "website":"https://www.metacourt.gg/", "try":"https://www.metacourt.gg/", "twitter":"https://twitter.com/metacourtgg", "medium":"https://metacourtgg.medium.com/", "discord":"https://discord.gg/9AnnfKCb39" }, "slug":"metacourt", "createdAt":1699292616238, "logo":{ "small":{ "width":36, "fileName":"metacourt-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"metacourt-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"metacourt-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Metacourt", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1663756794000, "shortDescription":"Metacourt created NFTdeals for anyone who wants to become an influencer and trade their social media", "contracts":[ ], "updatedAt":1722498888422, "category":"nfts", "description":"Influencer accelerator for anyone who wants to become an influencer in the space. We allow selling your social media through NFTs and joining influencer marketing campaigns.", "id":"metacourt", "tags":[ "NFT Marketplaces" ] }, { "urls":{ "telegram":"https://t.me/tofuNFT", "website":"https://tofunft.com/", "try":"https://tofunft.com/", "twitter":"https://twitter.com/tofuNFT", "medium":"https://medium.com/tofunftofficial", "discord":"https://discord.com/invite/3wFUTZmTm7" }, "slug":"tofunft", "createdAt":1699292615874, "logo":{ "small":{ "width":36, "fileName":"tofunft-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"tofunft-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"tofunft-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"tofuNFT", "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1644828523000, "shortDescription":"The largest multichain NFT marketplace", "contracts":[ ], "updatedAt":1722498924881, "category":"nfts", "description":"tofuNFT.com is an NFT marketplace focused on GameFi and collectibles, rebranded from SCV’s NFT market. Enjoy exploring & trading with your buddies!", "id":"tofunft", "tags":[ "NFT Marketplaces", "NFT" ] }, { "urls":{ "website":"https://d-book.io", "try":"https://d-book.io", "twitter":"https://twitter.com/dbook_io" }, "slug":"d-book.io", "createdAt":1699292617021, "logo":{ "small":{ "width":129, "fileName":"d-book.io-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":129, "fileName":"d-book.io-logo-large.png", "mimeType":"image/png", "height":36 }, "full":{ "width":3000, "fileName":"d-book.io-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"D-book.io", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1682016612000, "shortDescription":"Buğra Ayan is a speaker,and university lecturer in Turkey who founded the Web3 Association Turkey.", "contracts":[ { "chain":"moonbeam", "contract":"0x8d4BA02D0973749ad7c646DcaAa60BDC66F6F6D2" } ], "updatedAt":1722498866417, "category":"nfts", "description":"We are an NFT Book Platform that connects authors and the decentralized world, aiming for a transformation ecosystem.", "id":"d-book.io", "tags":[ "NFT Marketplaces", "NFT" ] }, { "urls":{ "telegram":"https://t.me/BcmHuntGroup", "website":"https://bcmhunt.com/", "try":"https://bcmhunt.com/", "twitter":"https://twitter.com/bcmhunt", "medium":"https://medium.com/bcmhunt", "discord":"https://discord.com/invite/Ee9aJ287J2" }, "slug":"blockchain-monster-hunt", "createdAt":1699292616780, "logo":{ "small":{ "width":36, "fileName":"blockchain-monster-hunt-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":510, "fileName":"blockchain-monster-hunt-logo-large.jpeg", "mimeType":"image/jpeg", "height":510 }, "full":{ "width":3000, "fileName":"blockchain-monster-hunt-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Blockchain Monster Hunt", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1644828523000, "shortDescription":"The First Multichain NFT Monster Hunt", "contracts":[ ], "updatedAt":1722498855937, "category":"nfts", "description":"Blockchain Monster Hunt (BCMH) is the world’s first multi-chain game that runs entirely on the blockchain itself. Inspired by Pokémon-GO,BCMH allows players to continuously explore brand new places on the blockchain to hunt and battle monsters. Each block on the blockchain is a unique digital space where a limited number of monsters (of the same DNA gene and rarity) may exist. Players and collectors can hunt or battle for a chance to capture these unique monsters and to earn coins.", "id":"blockchain-monster-hunt", "tags":[ "NFT", "Gaming", "GLMR Grants" ] }, { "urls":{ "website":"https://speedboat.studio/", "try":"https://speedboat.studio/", "twitter":"https://twitter.com/Speedboat_STDO", "medium":"https://medium.com/@speedboat_studio", "discord":"https://discord.gg/y7TQbtEWSV" }, "slug":"speedboat.studio", "createdAt":1699292616328, "logo":{ "small":{ "width":36, "fileName":"speedboat.studio-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":190, "fileName":"speedboat.studio-logo-large.png", "mimeType":"image/png", "height":190 }, "full":{ "width":3000, "fileName":"speedboat.studio-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"Speedboat", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1657584952000, "shortDescription":"Your no-code Web3 toolkit", "contracts":[ ], "updatedAt":1722498916466, "category":"nfts", "description":"Speedboat is a Web3 toolkit for everyone. Built on the idea that NFTs are not just expensive JPEGs, but programmable experiences.", "id":"speedboat.studio", "tags":[ "NFT", "Tool" ] }, { "urls":{ "telegram":"https://t.me/+qGh0InPSPc1iMTNk", "website":"https://www.glmrapes.com/", "try":"https://www.glmrapes.com/", "twitter":"https://twitter.com/GLMRApes", "discord":"https://discord.com/invite/glmrapes" }, "web3goContracts":[ { "name":"GLMR Apes: GLMR Ape", "chain":"moonbeam", "contract":"0x8fbe243d898e7c88a6724bb9eb13d746614d23d6" }, { "name":"GLMR Apes: GLMR Jungle", "chain":"moonbeam", "contract":"0xcb13945ca8104f813992e4315f8ffefe64ac49ca" } ], "currentTx":{ "moonbeam":7830 }, "slug":"glmr-apes", "web3goIDs":[ "GLMR Apes" ], "createdAt":1699292616827, "logo":{ "small":{ "width":47, "fileName":"glmr-apes-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":528, "fileName":"glmr-apes-logo-large.png", "mimeType":"image/png", "height":408 }, "full":{ "width":3000, "fileName":"glmr-apes-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"GLMR APES", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "usersChange7d":{ "moonbeam":-66.6666666666667 }, "currentUsers":{ "moonbeam":1531 }, "projectCreationDate":1644828523000, "shortDescription":"The first NFT collection on GLMR by & for the community", "contracts":[ ], "updatedAt":1722547408370, "category":"nfts", "description":"GLIMMER APES is the first NFT collection on GLMR by & for the community. The longer you’re bonding with GLMR Apes and the friendlier their behavior. Join the troops as soon as possible to become an EARLY APE, take part in our giveaways and games and land in the GLMR APE VIP CLUB.", "id":"glmr-apes", "tags":[ "NFT", "Gaming" ], "usersChange1d":{ "moonbeam":0 } }, { "urls":{ "website":"https://snakesoldiers.com", "try":"https://snakesoldiers.com", "twitter":"https://twitter.com/snakesoldiers", "github":"https://github.com/steven2308/snake-soldiers-contracts", "medium":"https://medium.com/@snakesoldiers/emoting-to-influence-the-hatch-df3eab7e45b8", "discord":"http://discord.gg/A6zQSz4YU4" }, "slug":"snake-soldiers", "createdAt":1699292616971, "logo":{ "small":{ "width":36, "fileName":"snake-soldiers-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"snake-soldiers-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"snake-soldiers-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Snake Soldiers", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1691439275000, "shortDescription":"NFT game collection divided in 3 categories: Generals, Commanders and Soldiers🐍. Built on Moonbeam", "contracts":[ { "chain":"moonbeam", "contract":"0x3ab955216BdD76f51fbe02A3fe237D6612BBD09F" } ], "updatedAt":1722498915320, "category":"nfts", "description":"Snake Soldiers is an NFT collection with a supply of at most 5k units, all unique and distributed among 3 ranks. Each snake will be usable inside a play to own game, where snakes will be the main characters, necessary to interact with the SerpenTerra ecosystem. This metaverse will be based on the RMRK 2.0 standard, making forward compatible and giving super powers to the NFTs.", "id":"snake-soldiers", "tags":[ "NFT" ] }, { "urls":{ "telegram":"https://t.me/+LqmDOeGUQdRmYjVh%60%60", "website":"https://omni-x.io", "try":"https://omni-x.io", "twitter":"https://twitter.com/omnix_nft", "github":"https://github.com/Omni-X-NFT", "discord":"https://discord.gg/omni-x" }, "slug":"omni-x", "createdAt":1699292617077, "logo":{ "small":{ "width":36, "fileName":"omni-x-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":107, "fileName":"omni-x-logo-large.jpeg", "mimeType":"image/jpeg", "height":108 }, "full":{ "width":3000, "fileName":"omni-x-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Omni-X", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1673811786000, "shortDescription":"The first natively omnichain NFT platform", "contracts":[ ], "updatedAt":1722498898538, "category":"nfts", "description":"Omni X is an omnichain NFT protocol and marketplace that connects communities, creators, and enthusiasts across multiple blockchains. \n\nWe provide tooling for creating ONFT collections, bridging regular NFTs to ONFTs and grant access to unparalleled liquidity that allows users to buy and sell NFTs from any blockchain to any other blockchain.", "id":"omni-x", "tags":[ "NFT Marketplaces", "Infrastructure" ] }, { "urls":{ "website":"https://www.publicpressure.io/", "try":"https://www.publicpressure.io/", "twitter":"https://twitter.com/jointhepressure", "discord":"https://discord.gg/publicpressure" }, "slug":"publicpressure", "createdAt":1702283744356, "logo":{ "small":{ "width":36, "fileName":"publicpressure-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"publicpressure-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"publicpressure-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Public Pressure", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1651597275000, "shortDescription":"Support your favorite artists, own their music, get rewarded.", "contracts":[ ], "updatedAt":1722498907699, "category":"nfts", "description":"We are the web3 music platform powered by artists, labels and fans", "id":"publicpressure", "tags":[ "NFT Marketplaces" ] }, { "currentTx":{ "moonbeam":8409 }, "web3goIDs":[ "Moonbeans" ], "name":"Moonbeans", "currentUsers":{ "moonbeam":1134 }, "coinGeckoId":"moonbeans", "shortDescription":"Galactic Co-Op & Profit sharing NFT platform and soon to be Metaverse", "id":"moonbeans", "tags":[ "NFT Marketplaces" ], "urls":{ "website":"https://moonbeans.io/", "twitter":"https://twitter.com/moonbeansio", "github":"https://github.com/m00nbeans", "discord":"https://discord.com/invite/qqE9aBPzQ9", "telegram":"https://t.me/moonbeansio", "try":"https://moonbeans.io/", "medium":"https://medium.com/@MoonBeans" }, "web3goContracts":[ { "name":"Moonbeans: Beanie Distributor V2", "chain":"moonbeam", "contract":"0xda6367c6510d8f2d20a345888f9dff3eb3226b02" }, { "name":"Moonbeans: Marketplace V9", "chain":"moonbeam", "contract":"0x683724817a7d526d6256aec0d6f8ddf541b924de" }, { "name":"Moonbeans: Storefront Ownership V1", "chain":"moonbeam", "contract":"0x971dfedd548f2269e515957404cbbee1f507cd01" } ], "slug":"moonbeans", "createdAt":1699292615978, "logo":{ "small":{ "width":36, "fileName":"moonbeans-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"moonbeans-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"moonbeans-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "usersChange7d":{ "moonbeam":0 }, "marketData":{ "symbol":"beans", "marketCap":0, "priceChangePercentage1y":-62.22489, "currentPrice":0.062264, "priceChangePercentage14d":-13.93552, "contracts":{ }, "priceChangePercentage60d":-44.93764, "priceChangePercentage30d":-33.587, "priceChangePercentage24h":-0.05451, "priceChangePercentage200d":-83.0363, "marketCapChangePercentage24h":0, "priceChange24h":-0.0000339560550113, "marketCapChange24h":0, "priceChangePercentage7d":-5.36696 }, "projectCreationDate":1644828523000, "contracts":[ { "chain":"moonbeam", "contract":"0x65b09ef8c5a096c5fd3a80f1f7369e56eb932412" }, { "chain":"moonriver", "contract":"0xC2392DD3e3fED2c8Ed9f7f0bDf6026fcd1348453" } ], "updatedAt":1722548296818, "category":"nfts", "description":"Moonbeans is a fully functional NFT marketplace launched on October 8th 2021, after releasing 465 Beanies into the Moonriver network to wreak havoc. The platform is still in beta, but has been performing incredibly well. With minimal fees for artists, traders, and project developers, Moonbeans aims to grow and aid the Moonrver network as a whole to develop, learn, and earn. With multiple collections now live (Beanies, Damned Pirates Society), minting (RivrMaids), Moonbeans is the heart of the Moonriver NFT ecosystem.", "usersChange1d":{ "moonbeam":0 } }, { "urls":{ "telegram":"https://t.me/blocsport", "website":"https://blocsport.one/", "try":"https://blocsport.one/", "twitter":"https://twitter.com/blocsport1", "medium":"https://blocsport1.medium.com/" }, "slug":"blocsport-one", "createdAt":1699292616637, "logo":{ "small":{ "width":36, "fileName":"blocsport-one-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"blocsport-one-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"blocsport-one-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Blocsport.one", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1644828523000, "shortDescription":"Web 3.0 metaverse, smart sports money, athlete NFT launchpad & assets tokenization", "contracts":[ ], "updatedAt":1722498857332, "category":"nfts", "description":"Blocsport.one is a Swiss sports tech company founded in 2019 that is transforming the sports business by building a transparent and reliable sports ecosystem uniting athletes, clubs, and fans based on blockchain. Company owns NFTdeals.io exclusive marketplace and has the biometric-enabled football scouting DApp live. Blocsport.one helps the young promising athletes get the money and exposure for their career development, which is nobody else doing in the world.", "id":"blocsport-one", "tags":[ "NFT" ] }, { "urls":{ "telegram":"https://t.me/mintverse", "website":"https://www.mintverse.com/", "try":"https://www.mintverse.com/", "twitter":"https://twitter.com/mintverse_", "medium":"https://medium.com/mintverse", "discord":"https://discord.com/invite/mhhnbvAaq9" }, "slug":"mintverse", "createdAt":1702283733666, "logo":{ "small":{ "width":36, "fileName":"mintverse-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"mintverse-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"mintverse-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Mintverse", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1651597514000, "shortDescription":"Mint, Explore & Trade Liquid NFT Assets Across Multiple Chains", "contracts":[ ], "updatedAt":1722498889300, "category":"nfts", "description":"Comprehensive NFT Aggregation Marketplace with a 0% trading fee", "id":"mintverse", "tags":[ "NFT Marketplaces" ] }, { "urls":{ "telegram":"https://t.me/rmrkapp", "website":"https://upgradooor.app", "try":"https://upgradooor.app", "twitter":"https://x.com/rmrkapp", "github":"https://github.com/rmrk-team", "medium":"https://medium.com/rmrkapp" }, "slug":"upgradooor", "createdAt":1699292616895, "logo":{ "small":{ "width":36, "fileName":"upgradooor-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"upgradooor-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"upgradooor-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Upgradooor", "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1692259742000, "shortDescription":"Upgrade your NFT 1.0 collections to NFT 2.0 by wrapping them into advanced functionality", "contracts":[ ], "updatedAt":1722498927244, "category":"nfts", "description":"As a collection issuer, use Upgradooor to initialize the process of upgrading your collection to NFT 2.0 if you are currently using ERC721.\n\nAs a holder, once the collection owner initiates the process, you can wrap any NFT you hold in that collection and instantly turn it into an equippable, multi-asset, composable NFT with no added risk.\n\nYou can always unwrap at will, and all the changes will still wait for you when you decide to re-claim the 2.0 wrapper again.\n\nUpgrading allows you to:\n\n- add more assets (outputs) to a legacy NFT, preventing needless airdrop spam\n- airdrop NFTs into the NFT itself, preventing detachment of context, and saving tremendous amounts of gas by letting people transfer just the parent NFT\n- define equippable settings and even achieve compatibility with other collections, for cross collection equippables and thus cross collection royalties and commissions\n- see your NFTs on Singular, and use GBM auctions as a unique and novel listing mechanic", "id":"upgradooor", "tags":[ "NFT", "Tool" ] }, { "urls":{ "telegram":"https://t.me/moonfit_official_community", "website":"https://moonfit.xyz/", "try":"https://moonfit.xyz/", "twitter":"https://twitter.com/MoonFitOfficial", "discord":"https://discord.gg/hStdUVtHXp" }, "slug":"moonfit", "createdAt":1702283734897, "logo":{ "small":{ "width":36, "fileName":"moonfit-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"moonfit-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"moonfit-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"MoonFit", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1654692249000, "shortDescription":"Web3 & NFT Lifestyle App That Pays You Anytime You Burn Calories", "contracts":[ ], "updatedAt":1722498891201, "category":"nfts", "description":"MoonFit is a Web3 Lifestyle App that promotes active living by rewarding users with tokens and NFTs anytime they burn calories through physical activities.", "id":"moonfit", "tags":[ "NFT", "Gaming" ] }, { "urls":{ "telegram":"https://t.me/rmrkapp", "website":"https://rmrk.app/", "try":"https://rmrk.app/", "twitter":"https://twitter.com/rmrkapp", "discord":"https://discord.com/invite/bV9kQbVC99" }, "slug":"rmrk", "createdAt":1699292615938, "logo":{ "small":{ "width":36, "fileName":"rmrk-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"rmrk-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"rmrk-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"RMRK", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "marketData":{ "symbol":"rmrk", "marketCap":5985029, "marketCapRank":1602, "priceChangePercentage1y":-64.99216, "currentPrice":0.62974, "priceChangePercentage14d":-24.26661, "contracts":{ "moonbeam":"0x524d524b4c9366be706d3a90dcf70076ca037ae3" }, "priceChangePercentage60d":-51.72181, "priceChangePercentage30d":-30.11256, "priceChangePercentage24h":-2.58554, "priceChangePercentage200d":-75.55551, "marketCapChangePercentage24h":-2.50147, "priceChange24h":-0.01671434617594, "marketCapChange24h":-153554.8536219, "priceChangePercentage7d":-1.5052 }, "coinGeckoId":"rmrk", "projectCreationDate":1644828523000, "shortDescription":"Creators of NFTs 2.0 via ERC6059, ERC6220, ERC5773, EIP6381, and EIP6454.\nNFT equippables, future compatibility, reputation, and token balances.", "contracts":[ ], "updatedAt":1722548302467, "category":"nfts", "description":"With the RMRK NFT Building Block System\nOur ERC NFT standards allow you to unlock the true potential of NFTs.\nTailored to work with each other, these EVM smart contracts will help you create your NFT projects of varying complexity.", "id":"rmrk", "tags":[ "NFT", "Infrastructure" ] }, { "urls":{ "website":"https://www.mynft.com/", "try":"https://bridge.mynft.com/home", "twitter":"https://twitter.com/mynft" }, "slug":"mynft", "createdAt":1699292616578, "logo":{ "small":{ "width":36, "fileName":"mynft-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"mynft-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"mynft-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"myNFT", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1644828523000, "shortDescription":"The marketplace that puts the power back in your hands", "contracts":[ ], "updatedAt":1722498895020, "category":"nfts", "description":"myNFT is the marketplace that puts the power back in your hands. It is a creative workshop, a trading platform and a discovery engine, helping you tell your story and share your passions, on your own terms. myNFT is built on decentralized technologies empowering you to create, trade, and discover. myNFT is built by Perpetual Altruism, a leader in the NFT space and the creator of charitable NFT publisher Cryptograph and the GBM auction system. Perpetual Altruism is backed by prominent investors and creators and is also the recipient of grants from the Web3 Foundation and the Moonbeam network for their work on the decentralized internet, which powers myNFT.", "id":"mynft", "tags":[ "NFT Marketplaces", "GLMR Grants", "MOVR Grants" ] }, { "urls":{ "website":"https://readl.co/", "try":"https://readl.co/", "twitter":"https://twitter.com/readl_co", "medium":"https://medium.com/@readlnetwork", "discord":"https://discord.gg/XPTENepHqY" }, "slug":"readl", "createdAt":1702283745749, "logo":{ "small":{ "width":36, "fileName":"readl-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"readl-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"readl-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Readl", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1655885161000, "shortDescription":"Bringing the publishing industry to web3", "contracts":[ ], "updatedAt":1722498910044, "category":"nfts", "description":"Readl is the protocol that provides publishers and storytellers with the infrastructure to publish their content on the blockchain, while providing a user-friendly platform to enjoy any story, in any format.", "id":"readl", "tags":[ "NFT Marketplaces", "MOVR Grants" ] }, { "urls":{ "telegram":"https://t.me/rmrkapp", "website":"https://emotes.app", "try":"https://emotes.app", "twitter":"https://x.com/rmrkapp", "github":"https://github.com/rmrk-team", "medium":"https://medium.com/rmrkapp" }, "slug":"emotes.app", "createdAt":1699292616951, "logo":{ "small":{ "width":36, "fileName":"emotes.app-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"emotes.app-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"emotes.app-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Emotes.app", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1692254489000, "shortDescription":"React on anyone's NFT - throw 💩 at those apes, give a 🤗 to those Pudgies!", "contracts":[ ], "updatedAt":1722498871347, "category":"nfts", "description":"Emotes.app is a RMRK mini-app which allows you to send emotes / reactions to anyone's NFT. It utilizes RMRK's ERC7009 and is trivial to integrate into any project wanting to take advantage of the community's reactions to their NFTs.\n\nUse it to direct storylines, affect NFT egg hatching, or just do relative price comparison when influencers like one NFTs and dislike another!", "id":"emotes.app", "tags":[ "NFT", "Social" ] }, { "urls":{ "telegram":"https://twitter.com/PolkaPets", "website":"https://www.polkapet.world/", "try":"https://www.polkapet.world/", "twitter":"https://twitter.com/PolkaPets", "medium":"https://polkapetworld.medium.com/" }, "slug":"polkapet-world", "createdAt":1702283743596, "logo":{ "small":{ "width":36, "fileName":"polkapet-world-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"polkapet-world-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"polkapet-world-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"PolkaPets", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "marketData":{ "priceChangePercentage60d":1206.42918, "symbol":"pets", "marketCap":0, "priceChangePercentage30d":619.39533, "priceChangePercentage200d":135.91624, "priceChangePercentage1y":355.00061, "currentPrice":0.00515699, "priceChangePercentage14d":-15.30948, "contracts":{ "moonriver":"0x1e0f2a75be02c025bd84177765f89200c04337da" }, "priceChangePercentage7d":749.62625 }, "coinGeckoId":"polkapet-world", "projectCreationDate":1651157216000, "shortDescription":"Welcome to PolkaPet World", "contracts":[ ], "updatedAt":1722548303208, "category":"nfts", "description":"An immersive NFT collection created in partnership with the biggest and best PolkaDot projects ", "id":"polkapet-world", "tags":[ "NFT" ] }, { "urls":{ "website":"https://www.moonarines.com/", "try":"https://www.moonarines.com/", "discord":"https://discord.gg/bXhSyW8htW" }, "slug":"moonarines", "createdAt":1702283733870, "logo":{ "small":{ "width":36, "fileName":"moonarines-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"moonarines-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"moonarines-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Moonarines", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1654792422000, "shortDescription":"Be part of the conquest of the digital space", "contracts":[ ], "updatedAt":1722498889804, "category":"nfts", "description":"The Moonarines are unique NFT characters starting soon on the Moonriver Network!\nWith the Moonarines, the NFT owners will be taken to an unforgettable adventure to explore the Cryptoverse!", "id":"moonarines", "tags":[ "NFT" ] }, { "urls":{ "telegram":"https://t.me/NFTrade", "website":"https://nftrade.com/", "try":"https://nftrade.com/", "twitter":"https://twitter.com/NFTradeOfficial", "medium":"https://medium.com/@NFTrade", "discord":"https://discord.com/invite/SESqfsyw8k" }, "slug":"nftrade", "createdAt":1699292616005, "logo":{ "small":{ "width":36, "fileName":"nftrade-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"nftrade-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"nftrade-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"NFTrade", "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "marketData":{ "symbol":"nftd", "marketCap":234018, "marketCapRank":3653, "priceChangePercentage1y":-65.38449, "currentPrice":0.00502075, "priceChangePercentage14d":-7.09922, "contracts":{ }, "priceChangePercentage60d":-27.37596, "priceChangePercentage30d":-14.12267, "priceChangePercentage24h":-2.22137, "priceChangePercentage200d":-56.66993, "marketCapChangePercentage24h":-2.16658, "priceChange24h":-0.00011406326237191, "marketCapChange24h":-5182.473845666, "priceChangePercentage7d":-6.88049 }, "coinGeckoId":"nftrade", "projectCreationDate":1644828523000, "shortDescription":"Create, Buy, Sell, Swap and Farm NFTs", "contracts":[ ], "updatedAt":1722548304198, "category":"nfts", "description":"NFTrade is a multi-chain platform for NFT creation and trading. Seamlessly launch, mint, and swap non-fungible tokens. Earn digital collectibles. NFTrade places you at the heart of the NFT economy. Create, Buy, Sell, Swap and Farm NFTs. All chains, All NFTs, One Platform.", "id":"nftrade", "tags":[ "NFT Marketplaces", "MOVR Grants" ] }, { "urls":{ "website":"https://www.pipcards.com/", "try":"https://www.pipcards.com/", "twitter":"https://twitter.com/pipcards", "discord":"https://discord.com/invite/hnSC7QjTHj" }, "slug":"pipcards", "createdAt":1699292616371, "logo":{ "small":{ "width":36, "fileName":"pipcards-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"pipcards-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"pipcards-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"PIP Cards", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1651149583000, "shortDescription":"Post-generated NFT playing card decks", "contracts":[ ], "updatedAt":1722498904704, "category":"nfts", "description":"PIPS is a first-of-its-kind NFT generative playing card project that will enable NFT holders to generate an entire deck of custom cards to be used cross-chain.", "id":"pipcards", "tags":[ "NFT", "Gaming" ] }, { "urls":{ "website":"https://bithotel.io/", "twitter":"https://twitter.com/playbithotel", "github":"https://github.com/BitHotelOrg/bithotel-token-contracts", "discord":"https://discord.gg/RFFZNwxY9n", "telegram":"https://t.me/bithotelcommunity", "try":"https://bithotel.io/", "medium":"https://medium.com/@bithotelnftgame" }, "slug":"bit-hotel", "createdAt":1702283710425, "logo":{ "small":{ "width":36, "fileName":"bit-hotel-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":500, "fileName":"bit-hotel-logo-large.jpeg", "mimeType":"image/jpeg", "height":500 }, "full":{ "width":3000, "fileName":"bit-hotel-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Bit Hotel", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1658743551000, "shortDescription":"Bit Hotel is a Social-first Play 2 Earn NFT Gaming Metaverse set in a Pixel-art Hotel.", "contracts":[ { "chain":"moonbeam", "contract":"Not deployed yet" }, { "chain":"moonriver", "contract":"Not deployed yet" } ], "updatedAt":1722498854706, "category":"nfts", "description":"In Bit Hotel users can compete to earn Bit Hotel tokens and acquire native NFTs. These NFTs have in-game utilities and consist of characters, hotel rooms, furniture and other assets that have their own unique perks. With over 250k Hotel Guests cross-channel, this nostalgic Hotel metaverse is taking people back to their 8bit upbringing.", "id":"bit-hotel", "tags":[ "NFT", "Gaming" ] }, { "tvlChange7d":{ "moonriver":0.00190215150271202 }, "urls":{ "website":"https://www.moonbeamdao.com/", "try":"https://www.moonbeamdao.com/", "twitter":"https://twitter.com/moonbeam_dao", "medium":"https://medium.com/@moonbeamdao", "discord":"https://discord.gg/AevrFzwZjk" }, "web3goContracts":[ { "name":"MoonDAO: MDAO Token", "chain":"moonbeam", "contract":"0xc6342eab8b7cc405fc35eba7f7401fc400ac0709" } ], "currentTx":{ "moonbeam":972 }, "slug":"moondao", "web3goIDs":[ "MoonDAO" ], "createdAt":1699292616416, "tvlChange1d":{ "moonriver":-0.0349944884006391 }, "logo":{ "small":{ "width":25, "fileName":"moondao-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":330, "fileName":"moondao-logo-large.png", "mimeType":"image/png", "height":475 }, "full":{ "width":3000, "fileName":"moondao-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"MoonDAO", "chains":[ "moonbeam" ], "currentTVL":{ "moonriver":76.75665 }, "currentUsers":{ "moonbeam":229 }, "projectCreationDate":1648347145000, "shortDescription":"The first & only community art dao on moonbeam", "contracts":[ ], "updatedAt":1722547637377, "category":"nfts", "description":"MoonDao is the first community Art Collection DAO on the Moonbeam network!\n\nWe aim to utilize input from our community to select high-end NFT’s. These NFT’s will be acquired with the MoonDao treasury and stored in the MoonDao Vault.\n\nMoon ownership grants access to DAO voting rights, future events, and additional holder perks outlined below. Welcome to the moon, we hope you stay.\n\n", "id":"moondao", "tags":[ "NFT", "DAO" ] }, { "urls":{ "telegram":"https://t.me/raresama", "website":"https://raresama.com/", "try":"https://raresama.com/", "twitter":"https://twitter.com/RaresamaNFT", "discord":"https://discord.com/channels/938592318380982303/1010237900685840405" }, "slug":"raresama", "createdAt":1699292615958, "logo":{ "small":{ "width":36, "fileName":"raresama-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"raresama-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"raresama-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Raresama", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1662528828000, "shortDescription":"Discover amazing Rare digital artwork", "contracts":[ ], "updatedAt":1722498909462, "category":"nfts", "description":"Raresama brings the magic of owning a piece of artwork to your fingertips. Create or browse NFT art collections and enjoy a diverse mix of artists, genres, styles and movements.", "id":"raresama", "tags":[ "NFT Marketplaces" ] }, { "urls":{ "telegram":"https://gal.xyz/telegram", "website":"https://galxe.com/", "try":"https://galxe.com/", "twitter":"https://twitter.com/Galxe", "medium":"https://blog.galxe.com/", "discord":"https://gal.xyz/discord" }, "slug":"galxe", "createdAt":1699292616277, "logo":{ "small":{ "width":36, "fileName":"galxe-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"galxe-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"galxe-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Galxe", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1659868871000, "shortDescription":"Create Impactful Experiences With #Web3 Credentials. (Formerly Project Galaxy) ", "contracts":[ ], "updatedAt":1722498876438, "category":"nfts", "description":"Galxe is the leading Web3 credential data network in the world. A collaborative credential infrastructure enabling brands and developers to engage communities and build robust products in Web3.", "id":"galxe", "tags":[ "NFT", "Social", "Tool" ] }, { "urls":{ "telegram":"http://t.me/MoonsamaNFT", "website":"https://moonsama.com/", "try":"https://moonsama.com/", "twitter":"https://twitter.com/MoonsamaNFT", "discord":"discord.gg/moonsama" }, "slug":"moonsama", "createdAt":1702283735408, "logo":{ "small":{ "width":36, "fileName":"moonsama-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"moonsama-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"moonsama-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Moonsama", "chains":[ "moonriver", "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1651156798000, "shortDescription":"Let's build the multiverse", "contracts":[ ], "updatedAt":1722498892389, "category":"nfts", "description":"Moonsama’s protocol for bi-directional bridging of on-chain digital assets and off-chain applications. This is how we connect web2.0 games, metaverses and blockchains. It enables new games, development and community fun from across the Kusamaverse and beyond!", "id":"moonsama", "tags":[ "NFT", "Gaming" ] }, { "urls":{ "website":"https://smartstamp.com/", "try":"https://smartstamp.com/", "discord":"https://discord.gg/kajPqvZY" }, "slug":"smartstamp", "createdAt":1699292617058, "logo":{ "small":{ "width":36, "fileName":"smartstamp-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":436, "fileName":"smartstamp-logo-large.jpeg", "mimeType":"image/jpeg", "height":436 }, "full":{ "width":3000, "fileName":"smartstamp-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"SmartStamp", "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1675081766000, "shortDescription":"SmartStamp is the pioneering new standard in identification and authentication for the art world.", "contracts":[ ], "updatedAt":1722498915044, "category":"nfts", "description":"Developed over more than a decade, SmartStamp’s app uses patented AI technology that is designed to read and record artworks’ surface characteristics– offering artists, collectors, institutions, and all arts and culture stakeholders a way to securely and immutably link physical objects to their digital fingerprints on the blockchain. Using the SmartStamp app is as simple as taking a picture, making the groundbreaking security and timestamping power of blockchain technology accessible to anyone who can use a smartphone.", "id":"smartstamp", "tags":[ "NFT" ] }, { "urls":{ "telegram":"https://t.me/yusernetwork", "website":"https://yuser.network/", "try":"https://yuser.network/", "twitter":"https://twitter.com/yuser", "medium":"https://medium.com/yuser", "discord":"https://discord.com/invite/uRRxnfAjhY" }, "slug":"yuser", "createdAt":1699292616605, "logo":{ "small":{ "width":36, "fileName":"yuser-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"yuser-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"yuser-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Yuser", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1644828523000, "shortDescription":"The first NFT social networking app- by creators, for creators", "contracts":[ ], "updatedAt":1722498932483, "category":"nfts", "description":"Yuser’s mission is to build an ecosystem of interconnected applications that put power back into the hands of users by giving them full control over their content, data, and personal networks. Developers can connect via an API to instantly gain access to millions of users and incentivize them to try their product by paying them with a token.", "id":"yuser", "tags":[ "NFT Marketplaces", "GLMR Grants", "MOVR Grants" ] }, { "urls":{ "telegram":"https://t.me/cryptosoots", "website":"https://raregems.io/my#", "try":"https://raregems.io/my#", "twitter":"https://twitter.com/RareGems_io" }, "slug":"rare-gems", "createdAt":1702283745336, "logo":{ "small":{ "width":36, "fileName":"rare-gems-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":360, "fileName":"rare-gems-logo-large.png", "mimeType":"image/png", "height":360 }, "full":{ "width":3000, "fileName":"rare-gems-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"Rare Gems", "chains":[ "moonriver", "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1652705611000, "shortDescription":"Multichain NFT marketplace.", "contracts":[ ], "updatedAt":1722498909205, "category":"nfts", "description":"Multichain NFT marketplace\nCreated by \n@cryptosoots", "id":"rare-gems", "tags":[ "NFT Marketplaces" ] }, { "urls":{ "telegram":"https://t.me/rmrkapp", "website":"https://wizard.rmrk.dev", "try":"https://wizard.rmrk.dev", "twitter":"https://x.com/rmrkapp", "github":"https://github.com/rmrk-team", "medium":"https://medium.com/rmrkapp" }, "slug":"rmrk-wizard", "createdAt":1699292616919, "logo":{ "small":{ "width":36, "fileName":"rmrk-wizard-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"rmrk-wizard-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"rmrk-wizard-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"RMRK Wizard", "chains":[ "moonbeam", "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1692255253000, "shortDescription":"A no-code-but-code wizard UI for building NFTs 2.0", "contracts":[ ], "updatedAt":1722498911520, "category":"nfts", "description":"A simple UI to put together NFT 2.0 legos created by the RMRK.app team. Use this tool to get started developing advanced NFT collections by picking from a set of functions you need, and the tool will compose code for you which only needs final tweaks before being deployed!", "id":"rmrk-wizard", "tags":[ "NFT", "Tool", "Developer Tools" ] }, { "urls":{ "telegram":"https://t.me/evelonapp", "website":"https://platform.evelon.app/", "try":"https://www.evelon.app/", "twitter":"https://twitter.com/EvelonApp" }, "slug":"evelon-app", "createdAt":1699292616145, "logo":{ "small":{ "width":36, "fileName":"evelon-app-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":512, "fileName":"evelon-app-logo-large.jpeg", "mimeType":"image/jpeg", "height":512 }, "full":{ "width":3000, "fileName":"evelon-app-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Evelon.App", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1690486894000, "shortDescription":"Transform the way you create and bring to life your own unique DNFTs, with the revolutionary platform that combines cutting-edge AI technology.", "contracts":[ ], "updatedAt":1722498873048, "category":"nfts", "description":"Evelon is a no code platform that allows you to create and deploy dynamic NFTs with ease. This project is a game changer in the world of NFTs and image generation. Evelon uses AI to generate high-quality images, making it possible to create NFTs with unique visuals that are both dynamic and engaging.", "id":"evelon-app", "tags":[ "NFT", "Tool" ] }, { "urls":{ "website":"https://mintlabz.io/", "try":"https://app.mintlabz.io/", "twitter":"https://twitter.com/mintlabz", "medium":"https://blog.mintlabz.io/", "discord":"https://discord.com/invite/BRF2PEetea" }, "slug":"mintlabz", "createdAt":1712311518649, "logo":{ "small":{ "width":36, "fileName":"mintlabz-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":400, "fileName":"mintlabz-logo-large.png", "mimeType":"image/png", "height":400 }, "full":{ "width":3000, "fileName":"mintlabz-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"Mintlabz", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1712189524, "shortDescription":"MintLabz is a complete crosschain NFT solution at zero cost.", "contracts":[ ], "updatedAt":1722498889042, "category":"nfts", "description":"MintLabz aims to establish a digital NFT minting platform for third party projects to create NFT collections with utilities to reward the NFT holder. Our mission is to become the number one choice for providing complete cross-chain NFT solutions to B2B customers.", "id":"mintlabz", "tags":[ "nfts" ] }, { "urls":{ "telegram":"https://t.me/golempark", "website":"https://golempark.com", "try":"https://golempark.com", "twitter":"https://twitter.com/golempark", "discord":"https://discord.gg/rNvtdHN8q7" }, "slug":"golem-park", "createdAt":1699292617039, "logo":{ "small":{ "width":36, "fileName":"golem-park-logo-small.png", "mimeType":"image/png", "height":36 }, "large":{ "width":512, "fileName":"golem-park-logo-large.png", "mimeType":"image/png", "height":512 }, "full":{ "width":3000, "fileName":"golem-park-logo-full.png", "mimeType":"image/png", "height":3000 } }, "name":"Golem Park", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1676839105000, "shortDescription":"Golem Park is holders friendly NFT collection. P2E blockchain game, $GP Token, Staking Pools & more", "contracts":[ { "chain":"moonbeam", "contract":"0x74746524f5A31F08e0528FaA704C2c5d8d116506" } ], "updatedAt":1722498878088, "category":"nfts", "description":"First Time In Crypto History Token Burning Campaign!\n30% Of Total Token Supply Will Be Burned In 30 Days.\n\nAfter Minting We Are Going To Release Deflationary $GP Token & 50% Of Total Supply Will Be Distributed To All $GP NFT Holders, 1 NFT = 5 000 000 Tokens. Then 30 Days Each Day We'll Burn 1% Of Total Token Supply To Ensure Token Price Will Go UP!\n\nWorld Of Golems is a decentralized Play-To-Earn blockchain game.\nOnce You Become Golem Park NFT Holder You Will Be Able To Participate in the WoG Game, Own Countries And Display Your Message On Them.\n\nThe Leaderboard Shows Of TOP 5 Wealthiest Countries & Every Month Owners Of These Countries Will Be Rewarded With $GLMR.", "id":"golem-park", "tags":[ "NFT" ] }, { "urls":{ "telegram":"https://t.me/rarible", "website":"https://rarible.com/", "try":"https://rarible.com/", "twitter":"https://x.com/rarible", "discord":"https://discord.com/invite/rarible" }, "slug":"rarible", "createdAt":1722498909701, "logo":{ "small":{ "width":429, "fileName":"rarible-small.png", "mimeType":"image/png", "height":121 }, "large":{ "width":858, "fileName":"rarible-medium.png", "mimeType":"image/png", "height":242 }, "full":{ "width":1716, "fileName":"rarible-large.png", "mimeType":"image/png", "height":485 } }, "name":"Rarible", "chains":[ "moonbeam" ], "shortDescription":"Rarible - NFT Marketplace for Brands, Communities and Traders", "projectCreationDate":1721872843, "contracts":[ ], "updatedAt":1722498909701, "category":"nfts", "description":"Discover, sell and buy NFTs on Rarible! Our aggregated NFT marketplace for Ethereum NFTs and Polygon NFTs powers brands, collections and creator marketplaces.", "id":"rarible", "featured":false, "tags":[ "NFT" ] }, { "urls":{ "website":"https://neoncrisis.io/", "try":"https://neoncrisis.io/", "twitter":"https://twitter.com/NeonCrisisNFT", "discord":"https://discord.gg/MVVjT9k9eD" }, "slug":"neoncrisis-io", "createdAt":1702283737907, "logo":{ "small":{ "width":36, "fileName":"neoncrisis-io-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":319, "fileName":"neoncrisis-io-logo-large.jpeg", "mimeType":"image/jpeg", "height":319 }, "full":{ "width":3000, "fileName":"neoncrisis-io-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Neon Crisis", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "projectCreationDate":1654792548000, "shortDescription":"6,008 heroes on the $MOVR network. A $RMRK powered metaverse featuring battle simulations, equipables, and more!", "contracts":[ ], "updatedAt":1722498896060, "category":"nfts", "description":"", "id":"neoncrisis-io", "tags":[ "NFT", "Gaming" ] }, { "urls":{ "telegram":"https://t.me/xp_network", "website":"https://xp.network/", "try":"https://xp.network/", "twitter":"https://twitter.com/xpnetwork_", "discord":"https://discord.com/invite/g3vkcsmd38" }, "slug":"xp-network", "createdAt":1699292615205, "logo":{ "small":{ "width":36, "fileName":"xp-network-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"xp-network-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"xp-network-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"XP Network", "chains":[ "moonbeam" ], "defiLLamaTvlExist":false, "projectCreationDate":1673327644000, "shortDescription":"A powerful NFT bridge trusted by all major blockchains ", "contracts":[ ], "updatedAt":1722498932103, "category":"nfts", "description":"We build software tools that enable experienced developers and non-coding blockchain community members to move their assets seamlessly and intuitively between versatile distributed ledgers. By doing so, we encourage unlimited growth of exchange and trade between otherwise isolated ecosystems. We enable them to enrich each other technologically with insights and discoveries. To gain access to new, previously inaccessible markets with users hungry for fresh ideas and technologies to invest in.", "id":"xp-network", "tags":[ "NFT", "Bridges" ] }, { "urls":{ "website":"https://www.damnedpiratessociety.io/", "try":"https://www.damnedpiratessociety.io/", "twitter":"https://twitter.com/TheDPSproject", "discord":"https://discord.com/invite/TheDamnedPiratesSociety" }, "web3goContracts":[ { "name":"Damned Pirates Society: DPSArtifact Token", "chain":"moonriver", "contract":"0xcd84ddadc45a25b02e1a6a5520171487a98e6155" }, { "name":"Damned Pirates Society: DPS Token", "chain":"moonriver", "contract":"0xb6e9e605aa159017173caa6181c522db455f6661" }, { "name":"Damned Pirates Society: DSPFlagship Token", "chain":"moonriver", "contract":"0x3822063a3f1aad3fd0b894e2a8f238ccca7c2d00" }, { "name":"Damned Pirates Society: DSPVoyage Token", "chain":"moonriver", "contract":"0x7b2e778453ab3a0d946c4620fb38a0530a434e15" }, { "name":"Damned Pirates Society: DOUBLOON Token", "chain":"moonriver", "contract":"0xe413a631e8a9a10958d9b7c64157449eae7c2064" } ], "currentTx":{ "moonriver":20402 }, "slug":"damned-pirates-society", "web3goIDs":[ "Damned Pirates Society" ], "createdAt":1699292616058, "logo":{ "small":{ "width":36, "fileName":"damned-pirates-society-logo-small.jpeg", "mimeType":"image/jpeg", "height":36 }, "large":{ "width":400, "fileName":"damned-pirates-society-logo-large.jpeg", "mimeType":"image/jpeg", "height":400 }, "full":{ "width":3000, "fileName":"damned-pirates-society-logo-full.jpeg", "mimeType":"image/jpeg", "height":3000 } }, "name":"Damned Pirates Society", "chains":[ "moonriver" ], "defiLLamaTvlExist":false, "currentUsers":{ "moonriver":2000 }, "projectCreationDate":1644828523000, "shortDescription":"Eclectic pirate-based NFT project with utility", "contracts":[ ], "updatedAt":1722547421801, "category":"nfts", "description":"A long time ago the Fortune’s Grasp was carrying families to settle on The Islands and start a new life. In the middle of their voyage they encountered a fearsome maelstrom. The Captain and his crew worked tirelessly to keep the ship afloat. Badly damaged, the Ship limped to the edges of the storm. It was taking on water and the cries of terrified children could be heard above the crashing waves. Another ship appeared on the horizon, it’s light glowing brightly against the dark night. The Captain of the Fortune’s Grasp ordered his crew to evacuate the families, but the fifty crew members ignored the Captain, abandoning ship, taking all means of escape with them. The Captain, left on the sinking ship, cursed the cowardly crew for damning those innocent souls to the watery depths. Those Forsaken Fifty were marked with The Black Spot, doomed to row the high seas until the Reaper came to claim his mutinous crew to serve on the Ship Of The Damned. However, if they could convince another soul to take their place at the oars, protection would be offered by those Pirates who’ve cheated the Reaper before. Those who’ve served and survived are welcome in the Damned Pirates Society.\r\n\r\nThe Damned Pirate Society is an Profile Picture NFT with inbuilt utility. Stake your Pirate for Treasure Maps(TMAP) and save these for your Doubloon farming voyages on our upcoming, skill based gamified contracts.", "id":"damned-pirates-society", "tags":[ "NFT", "Gaming", "GLMR Grants" ] } ], "count":40 } ``` Below are all possible categories and their respective parameters for querying the API. Ensure you query the API with the parameter formatted exactly as shown in lowercase. | Category | API Parameter | |:--------:|:-------------:| | Bridges | `bridges` | | DAO | `dao` | | DEX | `dex` | | DeFi | `defi` | | Gaming | `gaming` | | Lending | `lending` | | NFTs | `nfts` | | Other | `other` | | Social | `social` | | Wallets | `wallets` | ### Query a Chain {: #query-a-chain} The following queries can be used to query all of the listed projects on Moonbeam or Moonriver. Note that Moonbase Alpha is not a supported network in the DApp Directory. === "Moonbeam" ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/projects?chain=moonbeam ``` === "Moonriver" ```bash https://apps.moonbeam.network/api/ds/v1/app-dir/projects?chain=moonriver ```
You are responsible for checking and validating the accuracy and truthfulness of all content. You are also responsible for doing your own diligence to understand the applicable risks present, including selection, performance, security, accuracy, or use of any third-party information. All information contained herein is subject to modification without notice.
--- END CONTENT --- Doc-Content: https://docs.moonbeam.network/learn/platform/glossary/ --- BEGIN CONTENT --- --- title: Glossary description: We've compiled a glossary of terms related to Polkadot that'll make it easier to learn more about the ecosystem. categories: Reference --- # Glossary There's a great deal of terminology that's specific to Polkadot, Substrate, and the emerging Parity/Web3 ecosystem. We've compiled a list of terms we think you'll want to know as you review the Moonbeam documentation, plans, and tutorials. ### Collators {: #collators } One of the key network participants needed to support parachains within the Polkadot Network. In Moonbeam, collators are the nodes that are responsible for block production and for submitting produced blocks up to the Polkadot relay chain for finalization. ### Delegators {: #delegators } Moonbeam token holders who stake tokens, vouching for specific collator candidates on the parachain. Any user that holds a minimum amount of tokens as [free balance](https://wiki.polkadot.com/learn/learn-accounts/#balance-types#balance-types){target=\_blank} can become a delegator by staking their tokens. ### Nominators {: #nominators } Relay chain token holders who select to "back" a validator. They can receive part of the validator's reward, but are subject to slashing of their staked tokens in case the validator misbehaves. A nominator can back up to 16 validators, and their bond is fully distributed between the backed validators that were selected for the validator set. ### Nominated Proof of Stake {: #nominated-proof-of-stake } The mechanism used by Polkadot for selecting its block validator set to maximize chain security. At its core, it is a Proof-of-Stake system (PoS) in which nominators back validators. The latter with the highest backing are selected to be part of the validator set for a session. The stake of a validator is slashed in case of misbehavior. Thus, nominators are expected to do due diligence on the validators they nominate. ### Parachains {: #parachains } A blockchain which has a slot and is connected to Polkadot. Parachains receive shared security from Polkadot and the ability to interact with other parachains on the Polkadot network. They must lock DOT, the native relay chain token, to secure a slot for a specific period (up two years). ### Parathreads {: #parathreads } A blockchain which can connect to Polkadot. Parathreads are able to interact with other members of the Polkadot network, but they bid for block finalization (in DOT) on a block-to-block basis. They compete with other parathreads for block finalization, meaning that the block with the highest bid is selected to be finalize in that round. ### Polkadot {: #polkadot } A network of connected blockchains that provides shared security and the ability to interact between chains. Polkadot is built using the Substrate development framework. Chains that connect to Polkadot are called parachains. ### Relay Chain {: #relay-chain } The backbone blockchain supporting the Polkadot network. Parachains connect to the relay chain and use it for shared security and message passing. Validators on the relay chain help secure the parachains. ### Smart Contract {: #smart-contract } A [smart contract](https://en.wikipedia.org/wiki/Smart_contract){target=\_blank} is a computer program or a transaction protocol that is intended to automatically execute, control, or document legally relevant events and actions according to the terms of a contract or an agreement. Smart contracts intend to reduce the need for trusted intermediators, arbitrations, and enforcement costs, as well as reduce fraud losses and malicious and accidental exceptions. ### Substrate {: #substrate } A Rust-based blockchain development framework created by Parity Technologies based on their experience implementing multiple blockchain clients. Substrate comes with many modules and functionalities that are needed when building a blockchain, including P2P networking, consensus mechanisms, staking, cryptocurrency, on-chain governance modules, and more. It dramatically reduces the time and engineering effort required to implement a blockchain. Substrate is now part of the [Polkadot SDK](https://polkadot.com/platform/sdk/){target=\_blank}. ### Substrate Frame Pallets {: #substrate-frame-pallets } Substrate Frame Pallets are a collection of Rust-based modules, providing the functionality required for building a blockchain. ### Validators {: #validators } A node that secures the Polkadot relay chain by staking DOT in the network, which is slashed if they misbehave. They finalize blocks from collators on parachains and also participate on consensus for the next relay chain block with other validators. ### WebAssembly/Wasm {: #webassemblywasm } WebAssembly is an open standard that defines a portable binary code format. It is supported by different programming languages, compilers, and browsers. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/build/historical-updates/ --- BEGIN CONTENT --- --- title: Historical Updates description: An overview of the historical updates made on Moonbeam and Moonriver, such as migrations and bug fixes applied to the Moonbeam source code. categories: Reference --- # Historical Updates ## Introduction {: #introduction } This page overviews historical updates on Moonbeam and Moonriver, such as bug fixes to the Moonbeam source code and data migrations applied. This page aims to provide information about unexpected behaviors or data inconsistencies associated with updates that require forced data migrations. ## Bugs {: #bugs } #### Invalid Transactions Stored {: #invalid-transactions-stored } For invalid transactions where the transaction cost couldn't be paid, the EVM pallet inserted the transaction metadata into storage instead of discarding it because there was no transaction cost validation. As a result, the runtime storage was unnecessarily bloated with invalid transaction data. This bug only impacted Moonriver and Moonbase Alpha and existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:-----:|:--------------------:| | Moonriver | RT49 | RT600 | 0 - 455106 | | Moonbase Alpha | RT40 | RT600 | 0 - 675175 | For more information, you can review the [relative Frontier PR on GitHub](https://github.com/polkadot-evm/frontier/pull/465){target=\_blank}. --- #### Ethereum Fees Weren't Sent to Treasury {: #ethereum-fees-to-treasury } The Moonbeam transaction fee model before Runtime 3401 and the passage of [MB101](https://forum.moonbeam.network/t/proposal-mb101-burn-100-of-transaction-fees-on-moonbeam/2022){target=\_blank} mandated a 20% allocation of fees sent to the on-chain Treasury and 80% burned as a deflationary force. However, before runtime 800, Ethereum transactions did not correctly allocate 20% of the transaction fees to the on-chain Treasury. This bug only impacted Moonriver and Moonbase Alpha and existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:-----:|:--------------------:| | Moonriver | RT49 | RT800 | 0 - 684728 | | Moonbase Alpha | RT40 | RT800 | 0 - 915684 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/732){target=\_blank}. --- #### Missing Refunds {: #missing-refunds } Moonbeam is configured to set the existential deposit to 0, meaning that accounts do not need a minimum balance to be considered active. For Substrate-based chains with this configuration, some refunds were missing from zeroed accounts because the account was interpreted as not existing. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT900 | RT1001 | 0 - 5164 | | Moonriver | RT49 | RT1001 | 0 - 1052241 | | Moonbase Alpha | RT40 | RT1001 | 0 - 1285915 | For more information, you can review the [relative Frontier PR](https://github.com/polkadot-evm/frontier/pull/509){target=\_blank} and the associated [Substrate PR on GitHub](https://github.com/paritytech/substrate/issues/10117){target=\_blank}. --- #### Incorrect Collator Selection {: #incorrect-collator-selection } The total delegations for collator candidates were not correctly updated when a delegation was increased via the `delegatorBondMore` extrinsic. This led to issues where the increased delegation amount wasn't included in the candidates' total amount bonded, which is used to determine which candidates are in the active set of collators. As a result, some candidates may not have been selected to be in the active set when they should have been, impacting their own and their delegators' rewards. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT900 | RT1300 | 0 - 524762 | | Moonriver | RT49 | RT1300 | 0 - 1541735 | | Moonbase Alpha | RT40 | RT1300 | 0 - 1761128 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1291){target=\_blank}. --- #### New Account Event Bug {: #new-account-event } The `System.NewAccount` event is emitted when a new account is created. However, a bug prevented this event from being emitted for some accounts at creation time. A hotfix was applied that patched the impacted accounts and emitted the `System.NewAccount` at a later time. The hotfix was applied in the following block ranges: | Network | Block Range | |:--------------:|:-------------------------------------------------------------------------------------------------------------------------------------:| | Moonbeam | [1041355 - 1041358 and 1100752](https://moonbeam.subscan.io/extrinsic?module=evm&call=hotfix_inc_account_sufficients){target=\_blank} | | Moonriver | [1835760 - 1835769](https://moonriver.subscan.io/extrinsic?module=evm&call=hotfix_inc_account_sufficients){target=\_blank} | | Moonbase Alpha | [2097782 - 2097974](https://moonbase.subscan.io/extrinsic?address=&module=evm&call=hotfix_inc_account_sufficients){target=\_blank} | This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT900 | RT1401 | 0 - 915320 | | Moonriver | RT49 | RT1401 | 0 - 1705939 | | Moonbase Alpha | RT40 | RT1400 | 0 - 1962557 | For more information, you can review the [relative Frontier PR on GitHub](https://github.com/moonbeam-foundation/frontier/pull/46/files){target=\_blank}. --- #### Incorrect Timestamp Units {: #incorrect-timestamp-units } EIP-2612 and Ethereum blocks deal with timestamps in seconds; however, the Substrate timestamp pallet that Moonbeam implements uses milliseconds. This only affected the EIP-2612 implementation, not the `block.timestamp` value. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT900 | RT1606 | 0 - 1326697 | | Moonriver | RT49 | RT1605 | 0 - 2077598 | | Moonbase Alpha | RT40 | RT1603 | 0 - 2285346 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1451){target=\_blank}. --- #### Substrate Tips Missing Treasury Distribution {: #substrate-tips } Tips for Substrate-based transactions weren't handled properly. The entire portion of the tip was burned because it was not handled in the runtime code. A fix was applied so that 20% was paid to the Treasury and 80% was burned, consistent with all other fee behavior at that time. Note that RT3401 introduced a parameters pallet fee configuration allowing governance to adjust how fees are split between the Treasury and burning. After this runtime upgrade combined with the passage of [MB101](https://forum.moonbeam.network/t/proposal-mb101-burn-100-of-transaction-fees-on-moonbeam/2022){target=\_blank}, 100% of all transaction fees on both Moonbeam and Moonriver are now burned. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT900 | RT2403 | 0 - 4163078 | | Moonriver | RT49 | RT2401 | 0 - 4668844 | | Moonbase Alpha | RT40 | RT2401 | 0 - 4591616 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2291){target=\_blank}. --- #### Incorrect Delegation Reward Calculation {: #incorrect-delegation-reward-calculation } The reward payouts for all delegations and collators were underestimated whenever there were pending requests. Delegation rewards are calculated based on the amount of tokens bonded by each delegator with respect to the total stake of the given collator. By counting delegation amounts for pending requests, the rewards to collators and their delegations were less than they should have been. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1001 | RT1802 | 5165 - 1919457 | | Moonriver | RT1001 | RT1801 | 1052242 - 2572555 | | Moonbase Alpha | RT1001 | RT1800 | 1285916 - 2748785 | You can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1719){target=\_blank} for more information. --- #### Block Parent Hash Calculated Incorrectly {: #block-parent-hash-calculated-incorrectly } After EIP-1559 support was introduced, which included the transition to new Ethereum transaction types, the block header parent hash was miscalculated to `H256::default`. This bug only impacted Moonbase Alpha and only impacted the following block: | Network | Introduced | Fixed | Impacted Block | |:--------------:|:----------:|:------:|:--------------:| | Moonbase Alpha | RT1200 | RT1201 | 1648995 | While the root issue was fixed in RT1201, the incorrect hash was corrected in RT2601. For more information on the root fix, you can review the [relative Frontier PR on GitHub](https://github.com/polkadot-evm/frontier/pull/570/){target=\_blank}. To take a look at the correction of the parent hash, check out the corresponding [Moonbeam PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2524){target=\_blank}. --- #### Incorrect Handling of EIP-1559 Gas Fees {: #incorrect-gas-fees-eip1559 } With the introduction of EIP-1559 support, the logic for handling `maxFeePerGas` and `maxPriorityFeePerGas` was implemented incorrectly. As a result, the `maxPriorityFeePerGas` was added to the `baseFee` even if the total amount was over the `maxFeePerGas`. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1201 | RT1401 | 415946 - 915320 | | Moonriver | RT1201 | RT1401 | 1471037 - 1705939 | | Moonbase Alpha | RT1200 | RT1400 | 1648994 - 1962557 | For more information, you can review the [relative Frontier PR](https://github.com/moonbeam-foundation/frontier/pull/45){target=\_blank}. --- #### Transaction Fees Paid to Collators {: #transaction-fees-paid-to-collators } For blocks that included EIP-1559 transactions where a priority fee was applied, the transaction fees were incorrectly calculated and distributed to the block's collator. The fee model on Moonbeam for transactions and smart contract execution was previously handled so that 20% of the fees went to the on-chain Treasury and 80% were burned as a deflationary force. Due to this bug, the transaction fees of the impacted transactions were not burned as expected. Note that RT3401 introduced a parameters pallet fee configuration allowing governance to adjust how fees are split between the Treasury and burning. After this runtime upgrade combined with the passage of [MB101](https://forum.moonbeam.network/t/proposal-mb101-burn-100-of-transaction-fees-on-moonbeam/2022){target=\_blank}, 100% of all transaction fees on both Moonbeam and Moonriver are now burned. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1201 | RT1504 | 415946 - 1117309 | | Moonriver | RT1201 | RT1504 | 1471037 - 1910639 | | Moonbase Alpha | RT1200 | RT1504 | 1648994 - 2221772 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1528){target=\_blank}. --- #### Incorrect State Root Hash {: #incorrect-state-root-hash } The state root hash was miscalculated for non-legacy transactions as the transaction-type byte was not considered. With the support of [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930){target=\_blank} and [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559){target=\_blank}, the transaction types introduced are `0x01` (1) and `0x02` (2), respectively. These transaction types were omitted from the state root hash calculation. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1201 | RT1701 | 415946 - 1581456 | | Moonriver | RT1201 | RT1701 | 1471037 - 2281722 | | Moonbase Alpha | RT1200 | RT1700 | 1648994 - 2529735 | For more information, you can review the [relative Frontier PR](https://github.com/moonbeam-foundation/frontier/pull/86){target=\_blank} and [Moonbeam PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1678/files){target=\_blank}. --- #### Ethereum Transactions Duplicated in Storage {: #ethereum-transactions-duplicated-in-storage } An upstream bug was introduced to Frontier in the Ethereum Pallet, causing pending transactions that existed during a runtime upgrade to be duplicated in storage across two different blocks. This only impacted the first two blocks after the runtime upgrade in which this bug was introduced. Only Moonriver and Moonbase Alpha were impacted. The bug was introduced in the following runtimes and affected the following blocks: | Network | Introduced | Impacted Blocks | |:--------------:|:----------:|:-------------------:| | Moonriver | RT1605 | 2077599 and 2077600 | | Moonbase Alpha | RT1603 | 2285347 and 2285348 | The following transactions were duplicated: === "Moonriver" ```js '0x2cceda1436e32ae3b3a2194a8cb5bc4188259600c714789bae1fedc0bbc5125f', '0x3043660e35e89cafd7b0e0dce9636f5fcc218fce2a57d1104cf21aabbff9a1c0', '0x514411fb5c08f7c5aa6c61c38f33edfa74ff7e160831f6140e8dd3783648dbca', '0xf1647c357d8e1b05c522d11cff1f5090a4df114595d0f4b9e4ac5bb746473eea', '0x4be94803fe7839d5ef13ddd2633a293b4a7dddbe526839c15c1646c72e7b0b23', '0x15fceb009bd49692b598859f9146303ed4d8204b38e35c147fcdb18956679dbe', '0xa7460d23d5c633feec3d8e8f4382240d9b71a0d770f7541c3c32504b5403b70c', '0x1c838b4c4e7796a9db5edfd0377aee6e0d89b623bf1d7803f766f4cf71daefb9', '0xfb233a893e62d717ed627585f14b1ee8b3e300ac4e2c3016eb63e546a60820f0', '0xfaf8908838683ad51894eb3c68196afb99ba2e2bb698a40108960ee55417b56a', '0xa53973acbeac9fe948015dcfad6e0cb28d91b93c8115347c178333e73fd332d3', '0x9df769c96c5fdd505c67fee27eaff3714bf8f3d45a2afc02dd2984884b3cecac', '0x8f912ae91b408f082026992a87060ed245dac6e382a84288bd38fc08dbac30fe', '0xb22af459d24cb25bc53785bdd0ae6a573e24f226c94fd8d2e4663b87d3b07a88', '0x8ab9cd2bde7d679f798528b0c75325787f5fc7997e00589445b35b3954a815aa', '0xd08a1f82f4d3dc553b4b559925f997ef8bb85cb24cb4d0b893f017129fb33b78', '0xa1d40bce7cc607c19ca4b37152b6d8d3a408e3de6b9789c5977fcdef7ef14d97', '0xe442227634db10f5d0e8c1da09f8721c2a57267edbf97c4325c4f8432fd48ade', '0x0b4f5d8338a7c2b1604c1c42e96b12dc2a9d5ab264eb74ff730354e9765de13f', '0x0b00fc907701003aad75560d8b1a33cbf4b75f76c81d776b8b92d20e1d2e9d31', '0x9c18bd783f28427d873970ff9deaf1549db2f9a76e3edd6bdeae11358e447ef4', '0x8b2523f163989969dd0ebcac85d14805756bc0075b89da1274fd2c53ccaa396a', '0x47e80a0c533265974a55ea62131814e31b10f42895709f7e531e3e7b69f1387c' ``` === "Moonbase Alpha" ```js '0x006a6843eb35ad35a9ea9a99affa8d81f1ed500253c98cc9c080d84171a0afb3', '0x64c102f664eb435206ad4fcb49b526722176bcf74801c79473c3b5b2c281a243', '0xf546335453b6e35ce7e236ee873c96ba3a22602b3acc4f45f5d68b33a76d79ca', '0x4ed713ccd474fc33d2022a802f064cc012e3e37cd22891d4a89c7ba3d776f2db', '0xa5355f86844bb23fe666b10b509543fa377a9e324513eb221e0a2c926a64cae4', '0xc14791a3a392018fc3438f39cac1d572e8baadd4ed350e0355d1ca874a169e6a' ``` The duplicated transactions belong to the first block. So, on Moonriver, the transactions belong to block 2077599, and on Moonbase Alpha, the impacted transactions belong to block 2285347. For more information, you can review the [relative Frontier PR on GitHub](https://github.com/polkadot-evm/frontier/pull/638){target=\_blank}. --- #### Gas Limit Too High for Non-Transactional Calls {: #gas-limit-too-high-for-non-transactional-calls } When a non-transactional call, such as `eth_call` or `eth_estimateGas`, is made without specifying a gas limit for a past block, the client defaults to using the gas limit multiplier (10x), which causes the gas limit validation to fail as it is validating against an upper bound of the block gas limit. So, if the gas limit is greater than the block gas limit for a given call, a gas limit too high error is returned. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1701 | RT1802 | 1581457 - 1919457 | | Moonriver | RT1701 | RT1802 | 2281723 - 2616189 | | Moonbase Alpha | RT1700 | RT1802 | 2529736 - 2879402 | You can review the [relative Frontier PR on GitHub](https://github.com/polkadot-evm/frontier/pull/935){target=\_blank} for more information. --- #### Remote EVM Calls Return Identical Transaction Hashes {: #remote-evm-calls-return-identical-tx-hashes } When multiple remote EVM calls were sent from different accounts with the same transaction payload and nonce, the same transaction hash was returned for each call. This was possible because remote EVM calls are executed from a keyless account, so if the senders all had the same nonce and were sending the same transaction object, there was no differentiation in the calculation of the transaction hash. This was fixed by adding a global nonce to the Ethereum XCM Pallet, which is the pallet that makes remote EVM calls possible. This bug only existed on Moonbase Alpha during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbase Alpha | RT1700 | RT1900 | 2529736 - 3069634 | You can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1790){target=\_blank} for more information. --- #### Gas Estimation Discrepancy {: #gas-estimation-discrepancy } There was a difference between estimating the gas for a transaction using a non-transaction call, such as `eth_call`, and the execution of it on-chain. The discrepancy occurred because the non-transactional calls were not properly accounting for `maxFeePerGas` and `maxPriorityFeePerGas`, as such, the ([Proof of Validity](https://wiki.polkadot.com/general/glossary/#proof-of-validity){target=\_blank}) consumed by the Ethereum transaction was counted differently. This was fixed by properly accounting for these fields when estimating the size of the on-chain transaction. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1201 | RT2501 | 415946 - 4543267 | | Moonriver | RT1201 | RT2500 | 1471037 - 5175574 | | Moonbase Alpha | RT1200 | RT2500 | 1648994 - 5053547 | You can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1790/){target=\_blank} for more information. --- #### Incorrect Effective Gas Price In Transaction Receipts {: #incorrect-effective-gas-price } The `effectiveGasPrice` value returned by `eth_getTransactionReceipt` was different from the on-chain value due to an incorrect calculation of the base fee. Specifically, the transaction receipt's value was computed using the `NextFeeMultiplier` from the block in which the transaction was included rather than the previous block, which is the correct source for computing the base fee. This bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbeam | RT1201 | RT2801 | 415946 - 5899847 | | Moonriver | RT1201 | RT2801 | 1471037 - 6411588 | | Moonbase Alpha | RT1200 | RT2801 | 1648994 - 6209638 | You can review the [relative Frontier PR](https://github.com/polkadot-evm/frontier/pull/1280){target=\_blank} and [Moonbeam PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2610){target=\_blank} for more information. --- #### Skipped Ethereum Transaction Traces {: #skipped-ethereum-transaction-traces } Runtimes with the `evm-tracing` feature enabled introduced additional `ref_time` overhead due to special logic that traces Ethereum transactions (emitting events for each component: gasometer, runtime, EVM) used to fill information for RPC calls like `debug_traceTransaction` and `trace_filter`. Since the real `ref_time` in production runtimes is smaller, this could cause the block weight limits to be reached when replaying a block in an EVM-tracing runtime, resulting in skipped transaction traces. This was observed in Moonbeam block [9770044](https://moonbeam.subscan.io/block/9770044){target=\_blank}. The fix consisted of resetting the previously consumed weight before tracing each Ethereum transaction. It's important to note that this issue only affected code under `evm-tracing`, which is not included in any production runtime. This bug was fixed in the following runtime: | Network | Fixed | Impacted Block | |:--------------:|:------:|:--------------:| | Moonbeam | RT3501 | 9770044 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/3210){target=\_blank}. --- #### Notify Inactive Collator Fails for Long-Inactive Collators {: #notify-inactive-collator-fails } The `notifyInactiveCollator` extrinsic, designed to remove collators from the pool if they haven't produced any blocks in the last two rounds, failed for collators who had been inactive for significantly longer than two rounds. The transaction would only succeed within the first few blocks of a new round. The bug existed during the following runtimes and block ranges: | Network | Introduced | Fixed | Impacted Block Range | |:--------------:|:----------:|:------:|:--------------------:| | Moonbase Alpha | RT2601 | RT3500 | 5474345 – 10750816 | | Moonriver | RT2602 | RT3501 | 5638536 – 10665393 | | Moonbeam | RT2602 | RT3501 | 4977160 – 10056989 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/3128){target=\_blank}. --- ## Migrations {: #migrations } Migrations are necessary when a storage item is changed or added and needs to be populated with data. The migrations listed below have been organized by the impacted pallet(s). ### Author Mapping Pallet {: #author-mapping } #### Update the Mapping Storage Item {: #update-mapping-storage-item } This migration updated the now deprecated `Mapping` storage item of the author mapping pallet to use a more secure hasher type. The hasher type was updated to [Blake2_128Concat](https://paritytech.github.io/substrate/master/frame_support/struct.Blake2_128Concat.html){target=\_blank} instead of [Twox64Concat](https://paritytech.github.io/substrate/master/frame_support/struct.Twox64Concat.html){target=\_blank}. This migration was only applied to Moonriver and Moonbase Alpha and was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonriver | RT800 | 684728 | | Moonbase Alpha | RT800 | 915684 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/679){target=\_blank}. --- #### Add Support for VRF Keys {: #add-support-for-vrf-keys } When VRF key support was introduced, the `MappingWithDeposit` storage item of the author mapping pallet was updated to include a `keys` field to support VRF keys that can be looked up via the Nimbus ID. A migration was applied to update the existing storage items with this new field. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1502 | 1107285 | | Moonriver | RT1502 | 1814458 | | Moonbase Alpha | RT1502 | 2112058 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1407){target=\_blank}. --- #### One Nimbus ID per Account ID {: #one-nimbus-id-per-account-id } A migration was applied to ensure that an account ID can have only one Nimbus ID. The migration accepted the first Nimbus ID owned by a given account and cleared any additional Nimbus IDs associated with the account. For any cleared associations, the bond for the association was returned. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1606 | 1326697 | | Moonriver | RT1605 | 2077599 | | Moonbase Alpha | RT1603 | 2285347 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1525){target=\_blank}. --- ### Base Fee Pallet {: #base-fee } #### Set Elasticity Storage Item Value {: #set-elasticity } This migration sets the `Elasticity` storage item of the base fee pallet to zero, which results in a constant `BaseFeePerGas`. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1300 | 524762 | | Moonriver | RT1300 | 1541735 | | Moonbase Alpha | RT1300 | 1761128 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1744){target=\_blank}. --- ### Democracy Pallet {: #democracy } #### Preimage Storage Moved to New Preimage Pallet A migration was applied, which moved preimages stored in the democracy pallet to a new preimage pallet. This migration on Moonbeam was required as a result of an [upstream change to Polkadot](https://github.com/paritytech/substrate/pull/11649/){target=\_blank}. There was one preimage that was affected in Moonbeam, which was dropped from the scheduler queue and never executed: `0x14262a42aa6ccb3cae0a169b939ca5b185bc317bb7c449ca1741a0600008d306`. This preimage was [manually removed](https://moonbeam.subscan.io/extrinsic/2693398-8){target=\_blank} by the account that initially submitted the preimage. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2000 | 3310369 | | Moonriver | RT2000 | 3202604 | | Moonbase Alpha | RT2000 | 2673234 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1962){target=\_blank}. --- #### Remove Governance V1 Collectives {: #remove-gov-v1-collectives } A migration was applied to remove the governance V1 collectives, which included the Council and Technical Committee. The governance V1 collectives were replaced with the OpenGov (governance V2) Technical Committee. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2801 | 5899847 | | Moonriver | RT2801 | 6411588 | | Moonbase Alpha | RT2801 | 6209638 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2643){target=\_blank}. A follow-up migration was required to properly clear the storage entries associated with the governance V1 collectives, which was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2901 | 6197065 | | Moonriver | RT2901 | 6699589 | | Moonbase Alpha | RT2901 | 6710531 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2711){target=\_blank}. --- #### Remove Governance V1 Democracy Pallet {: #remove-gov-v1-collectives } A migration was applied to remove the storage associated with the Democracy Pallet used in governance V1. The Democracy Pallet was replaced with the Preimage, Referenda, and Collective Voting OpenGov (governance V2) pallets. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2901 | 6197065 | | Moonriver | RT2901 | 6699589 | | Moonbase Alpha | RT2901 | 6710531 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2685){target=\_blank}. --- ### EVM Pallet {: evm-pallet } #### EVM Contract Metadata A migration was introduced to automate the manual process of setting EVM contract metadata for contracts deployed more than two years ago that hadn't been interacted with after the introduction of metadata storage item. This migration replaces the need to manually call `createContractMetadata(address)` on these contracts to make them compatible with the current runtime. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:---------:|:----------------:|:-------------:| | Moonbeam | RT3200 | 7985204 | | Moonriver | RT3200 | 8519187 | --- ### Moonbeam Orbiter Pallet {: #moonbeam-orbiter } #### Remove the Minimum Bond Requirement for Orbiter Collators {: #remove-orbiter-minimum-bond } A migration was applied to the Moonbeam Orbiter Pallet that sets the bonds of the existing orbiter collators to zero. This change enabled payouts to be even for future orbiter program expansions. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2602 | 4977160 | | Moonriver | RT2602 | 5638536 | | Moonbase Alpha | RT2601 | 5474345 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2526){target=\_blank}. --- ### Parachain Staking Pallet {: #parachain-staking } #### Update Collator State Storage Item {: #update-collator-state-storage-item } A migration was applied that updated the `Collator` storage item of the parachain staking pallet to the new `Collator2` storage item. This change updated the collator state to include the following items: - The `nominators` set is a list of all of the nominator (delegator) account IDs without their respective balance bonded - A new `top_nominators` storage item that returns a list of all of the top nominators ordered by greatest bond amount to least - A new `bottom_nominators` storage item that returns a list of all of the bottom nominators ordered by least bond amount to greatest - The `total` storage item was replaced with `total_counted` and `total_backing`. The `total_counted` item returns the sum of the top nominations and the collator's self-bond, whereas the `total_backing` item returns the sum of all of the nominations and the collator's self-bond This migration was only applied to Moonriver and Moonbase Alpha and was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonriver | RT53 | 9696 | | Moonbase Alpha | RT52 | 238827 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/505){target=\_blank}. --- #### Patch Total Staked Amount {: #patch-total-staked-amount } A migration was applied to the `total` staked amount of the `CollatorState` storage item in the Parachain Staking Pallet due to a potential bug that may have led to an incorrect amount. This migration was only applied to Moonriver and Moonbase Alpha and was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonriver | RT53 | 9696 | | Moonbase Alpha | RT52 | 238827 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/502){target=\_blank}. --- #### Support Delayed Nominator (Delegator) Exits {: #support-delayed-nominator-exits } The exit queue for handling candidate exits had been updated to include support for delayed nominator (delegator) exits and revocations, which required a migration to update the `ExitQueue` parachain staking pallet storage item to `ExitQueue2`. The `NominatorState` storage item was also migrated to `NominatorState2` to prevent a nominator from performing more nominations when they already have scheduled an exit. These migrations were only applied to Moonriver and Moonbase Alpha and were executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonriver | RT200 | 259002 | | Moonbase Alpha | RT200 | 457614 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/610){target=\_blank}. --- #### Purge Staking Storage Bloat {: #purge-staking-storage-bloat } A migration was applied to purge staking storage bloat for the `Points` and `AtStake` storage items of the parachain staking pallet that are older than two rounds. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1001 | 5165 | | Moonriver | RT1001 | 1052242 | | Moonbase Alpha | RT1001 | 1285916 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/970){target=\_blank}. --- #### Support Manual Exits and DPoS Terminology {: #support-manual-exits-dpos-terminology } The parachain staking pallet was updated to include manual exits. If a candidate or delegator wanted to decrease or revoke their bond or leave the candidate or delegator pool, they would need to schedule a request first, wait for a delay period to pass, and then manually execute the request. As such, a migration was applied to replace the automatic exit queue, including the `ExitQueue2` storage item, with a manual exits API. In addition, a change was made to switch from Nominated Proof of Stake (NPoS) to Delegated Proof of Stake (DPoS) terminology; this marked the sweeping change from "nominate" to "delegate". This required the migration of the following parachain staking pallet storage items: - `CollatorState2` was migrated to `CandidateState` - `NominatorState2` was migrated to `DelegatorState` These migrations were executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1001 | 5165 | | Moonriver | RT1001 | 1052242 | | Moonbase Alpha | RT1001 | 1285916 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/810){target=\_blank}. --- #### Increase Max Delegations per Candidate {: #increase-max-delegations-per-candidate } A migration was applied to increase the maximum number of delegations per candidate in the parachain staking pallet. It increased the delegations from 100 to 500 on Moonbase Alpha and Moonriver and from 100 to 1000 on Moonbeam. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1101 | 171061 | | Moonriver | RT1101 | 1188000 | | Moonbase Alpha | RT1100 | 1426319 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1096){target=\_blank}. --- #### Split Candidate Delegations into Top and Bottom {: #split-candidate-delegations-top-bottom } This migration splits the deprecated `CandidateState` storage item of the parachain staking pallet into the following three new storage items to avoid unnecessary storage reads: - `CandidateInfo` - `TopDelegations` - `BottomDelegations` This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1201 | 415946 | | Moonriver | RT1201 | 1471037 | | Moonbase Alpha | RT1200 | 1648994 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1117){target=\_blank}. --- #### Patch Incorrect Total Delegations {: #patch-incorrect-total-delegations } There was a migration applied to fix the [Incorrect Collator Selection](#incorrect-collator-selection) bug and patch the delegations total for all candidates. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1300 | 524762 | | Moonriver | RT1300 | 1541735 | | Moonbase Alpha | RT1300 | 1761128 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1291){target=\_blank}. --- #### Split Delegator State into Delegation Scheduled Requests {: #split-delegator-state } A migration was applied that moved pending delegator requests from the `DelegatorState` storage item of the parachain staking pallet into a new `DelegationScheduledRequests` storage item. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1502 | 1107285 | | Moonriver | RT1502 | 1814458 | | Moonbase Alpha | RT1502 | 2112058 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1408){target=\_blank}. --- #### Replace Staking Reserves with Locks {: #replace-staking-reserves } A migration was applied that changed users' staking reserved balances to locked balances. The locked balance is the same type as democracy-locked funds, allowing users to use their staked funds to participate in democracy. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1701 | 1581457 | | Moonriver | RT1701 | 2281723 | | Moonbase Alpha | RT1700 | 2529736 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1604){target=\_blank}. --- #### Auto-Compounding Support {: #auto-compounding-support } To support auto-compounding, two migrations were applied to the `AtStake` storage item in the parachain staking pallet: - `RemovePaidRoundsFromAtStake` - to remove any stale `AtStake` entries relating to already paid-out rounds with candidates that didn't produce any blocks. This migration is a prerequisite for the `MigrateAtStakeAutoCompound` migration - `MigrateAtStakeAutoCompound` - migrates the snapshots for unpaid rounds for `AtStake` entries These migrations were executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1901 | 2317683 | | Moonriver | RT1901 | 2911863 | | Moonbase Alpha | RT1900 | 3069635 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1878){target=\_blank}. --- #### Switch to Block-Based Staking Rounds {: #block-based-staking-rounds } A migration was applied to switch from time-based staking rounds to fixed block-based rounds. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2801 | 5899847 | | Moonriver | RT2801 | 6411588 | | Moonbase Alpha | RT2801 | 6209638 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2690){target=\_blank}. --- #### Renaming of Parachain Bond Reserve Events {: #renaming-of-parachain-bond-reserve-events } Prior to Runtime 3300, the `ReservedForParachainBond` event was emitted once per round to indicate parachain bond reserve funding through inflation. In Runtime 3300, this same event was renamed to `InflationDistributed`. This change took effect at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT3300 | 8381443 | | Moonriver | RT3300 | 8894417 | | Moonbase Alpha | RT3300 | 9062316 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2976){target=\_blank}. --- ### Referenda Pallet {: #referenda-pallet } #### Refunds for Submission Deposits {: #refunds-for-submission-deposits } A migration was introduced to support refunds for submission deposits on closed referenda that updated the `ReferendumInfo` type. The following invariants of `ReferendumInfo` were changed so that the second parameter, `Deposit`, is now optional, `Option>`: `Approved`, `Rejected`, `Cancelled`, and `TimedOut`. This stemmed from an upstream change to the [Substrate](https://github.com/paritytech/substrate/pull/12788){target=\_blank} repository. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2302 | 3456477 | | Moonriver | RT2302 | 4133065 | | Moonbase Alpha | RT2301 | 4172407 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2134){target=\_blank}. --- #### Restore Corrupted Referenda Deposits {: restore-corrupted-referenda-deposits } A migration was introduced to support restoring referenda deposits affected by corrupted storage values. The issue arose when a migration was applied twice due to a pallet version error, resulting in invalid values and non-refundable submission deposits. As the number of values to correct was finite and small, this migration created a list to update them by hand. This migration was only applied to Moonbeam and was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------:|:----------------:|:-------------:| | Moonbeam | RT3100 | 7303601 | ### XCM-Related Pallets {: #xcm-related-pallets } #### Update Transact Info Storage Item {: #update-transaction-info } There was a migration applied to the `TransactInfo` storage item of the XCM Transactor Pallet that changed the following items: - `max_weight` is added to prevent transactors from stalling the queue in the destination chain - Removes `fee_per_byte`, `metadata_size`, and `base_weight` as these items are not necessary for XCM transactions - `fee_per_second` replaces `fee_per_weight` to better reflect cases (like Kusama) in which the `fee_per_weight` unit is lower than one This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1201 | 415946 | | Moonriver | RT1201 | 1471037 | | Moonbase Alpha | RT1200 | 1648994 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1114){target=\_blank}. --- #### Add Support for Kusama Asset Hub (Statemine) Prefix Breaking Change {: #add-support-statemine-prefix } The following three migrations were added to the asset manager pallet to avoid issues with Kusama Asset Hub's (previously referred to as Statemine) [breaking change to the way it represents assets](https://github.com/paritytech/cumulus/pull/831){target=\_blank} and possible future breaking changes: - `UnitsWithAssetType` - updates the `AssetTypeUnitsPerSecond` storage item to a mapping of the `AssetType` to `units_per_second`, instead of the mapping `AssetId` to `units_per_second`. This is done to avoid additional migrations whenever a breaking change arises - `PopulateAssetTypeIdStorage` - creates a new `AssetTypeId` storage item that holds the `AssetType` to `AssetId` mapping, which allows the decoupling of `assetIds` and `AssetTypes` - `ChangeStateminePrefixes` - updates already registered Kusama Asset Hub (Statemine) assets to their new form These migrations were executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1201 | 415946 | | Moonriver | RT1201 | 1471037 | | Moonbase Alpha | RT1200 | 1648994 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1159){target=\_blank}. --- #### Add New Supported Fee Payment Assets Storage Item {: #add-supported-fee-payment-assets } A migration was applied to the asset manager pallet, creating a new `SupportedFeePaymentAssets` storage item by reading the supported asset data from the `AssetTypeUnitsPerSecond` storage item. This storage item will hold all the assets we accept for XCM fee payment. It will be read when an incoming XCM message is received, and if the asset is not in storage, the message will not be processed. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1300 | 524762 | | Moonriver | RT1300 | 1541735 | | Moonbase Alpha | RT1300 | 1761128 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1118){target=\_blank}. --- #### Update the XCM Transactor Storage from V2 to V3 {: #update-xcm-transactor } With the support of XCM V3, a migration was applied to update the XCM Transactor pallet's storage from XCM V2 to V3. The `transactInfoWithWeightLimit` and `destinationAssetFeePerSecond` storage items were updated to support XCM V3 multilocations. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2302 | 3456477 | | Moonriver | RT2302 | 4133065 | | Moonbase Alpha | RT2301 | 4172407 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2145){target=\_blank}. --- #### Remove Mintable XC-20s {: #remove-local-assets } Mintable XC-20s were deprecated in favor of XCM-enabled ERC-20s; as such, a migration was applied to remove the local assets pallet and clear the assets in storage. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT2801 | 5899847 | | Moonriver | RT2801 | 6411588 | | Moonbase Alpha | RT2801 | 6209638 | For more information, you can review the [relative PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/2634){target=\_blank}. --- #### Manage Foreign Assets via Smart Contracts {: #foreign-assets-migration } A migration was applied to transition existing foreign assets to a new design that manages XCM derivative assets on Moonbeam through EVM smart contracts instead of the previous implementation using the Asset and Asset Manager pallets. The migration process involved several extrinsics in the Moonbeam Lazy Migration pallet: - **`approve_assets_to_migrate`** - sets the list of asset IDs approved for migration - **`start_foreign_asset_migration`** - initiates migration for a specific foreign asset by freezing the original asset and creating a new EVM smart contract - **`migrate_foreign_asset_balances`** - migrates asset balances in batches from old assets pallet to the new system - **`migrate_foreign_asset_approvals`** - migrates asset approvals in batches while unreserving deposits from the old approval system - **`finish_foreign_asset_migration`** - completes migration after all balances and approvals are migrated and performs final cleanup This migration preserves compatibility with existing foreign assets by identifying each foreign asset with the same AssetID integer as before. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT3501 | 10056989 | | Moonriver | RT3501 | 10665393 | | Moonbase Alpha | RT3500 | 10750816 | For more information, you can review the relative PRs on GitHub: [2869](https://github.com/moonbeam-foundation/moonbeam/pull/2869){target=\_blank} and [3020](https://github.com/moonbeam-foundation/moonbeam/pull/3020){target=\_blank}. --- ### Nimbus Author Filter Pallet {: #nimbus } #### Replace Eligible Ratio with Eligible Count {: #replace-eligible-ratio } A breaking change was applied to the Nimbus repository, deprecating `EligibleRatio` in favor of the `EligibleCount` config. As a result, a migration was applied to the Moonbeam repository, populating the new `EligibleCount` value as a percentage of the potential authors defined at that block height if the `EligibleRatio` value existed. Otherwise, the value was set to a default value of `50`. This migration was executed at the following runtimes and blocks: | Network | Executed Runtime | Block Applied | |:--------------:|:----------------:|:-------------:| | Moonbeam | RT1502 | 1107285 | | Moonriver | RT1502 | 1814458 | | Moonbase Alpha | RT1502 | 2112058 | For more information, you can review the [relative Nimbus PR](https://github.com/moonbeam-foundation/nimbus/pull/45){target=\_blank} and [Moonbeam PR on GitHub](https://github.com/moonbeam-foundation/moonbeam/pull/1400){target=\_blank}. --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/build/runtime-upgrades/ --- BEGIN CONTENT --- --- title: Runtime Upgrades description: A historical record of each runtime upgrade and the block at which the runtime was executed for Moonbeam, Moonriver, and the Moonbase Alpha TestNet. categories: Reference --- # Runtime Upgrades ## Introduction {: #introduction } Moonbeam runtime upgrades allow for the maintenance and evolution of the chain logic without the need for a hard fork. These runtime upgrades can introduce new features, improve performance, fix bugs, and respond to changing requirements. This page provides a historical record of runtime upgrades by block for each of the Moonbeam-based networks. ## Runtime Upgrades by Block {: #runtime-upgrades-by-block } The following table contains a list of the runtime upgrades and the block at which the upgrade occurred for each network. Runtime upgrades occur first on Moonbase Alpha before being released on Moonriver and then on Moonbeam. You can read the release notes for each runtime on the [Moonbeam releases GitHub page](https://github.com/moonbeam-foundation/moonbeam/releases){target=\_blank}. Not all runtime upgrades are released on each network, as sometimes after releasing the initial runtime upgrade, the need for a subsequent upgrade arises. If a runtime upgrade version has been skipped or hasn't been released yet (only applicable to the latest runtime upgrade), you'll see a `-` in that row. | Runtime | Moonbeam | Moonriver | Moonbase Alpha | |:----------------------------------------------------------------------------------------:|:----------------------------------------------------------------------:|:-----------------------------------------------------------------------:|:----------------------------------------------------------------------:| | 40 | - | - | [0](https://moonbase.subscan.io/block/0){target=\_blank} | | 44 | - | - | [142863](https://moonbase.subscan.io/block/142863){target=\_blank} | | 47 | - | - | [209144](https://moonbase.subscan.io/block/209144){target=\_blank} | | 49 | - | [0](https://moonriver.subscan.io/block/0){target=\_blank} | - | | 52 | - | - | [238827](https://moonbase.subscan.io/block/238827){target=\_blank} | | 53 | - | [9696](https://moonriver.subscan.io/block/9696){target=\_blank} | - | | 155 | - | [67938](https://moonriver.subscan.io/block/67938){target=\_blank} | [278703](https://moonbase.subscan.io/block/278703){target=\_blank} | | 159 | - | [166749](https://moonriver.subscan.io/block/166749){target=\_blank} | [383465](https://moonbase.subscan.io/block/383465){target=\_blank} | | 200 | - | [259002](https://moonriver.subscan.io/block/259002){target=\_blank} | [457614](https://moonbase.subscan.io/block/457614){target=\_blank} | | 300 | - | [344698](https://moonriver.subscan.io/block/344698){target=\_blank} | [485543](https://moonbase.subscan.io/block/485543){target=\_blank} | | 400 | - | [400458](https://moonriver.subscan.io/block/400458){target=\_blank} | [610935](https://moonbase.subscan.io/block/610935){target=\_blank} | | 501 | - | [430442](https://moonriver.subscan.io/block/430442){target=\_blank} | [653692](https://moonbase.subscan.io/block/653692){target=\_blank} | | 600 | - | [455107](https://moonriver.subscan.io/block/455107){target=\_blank} | [675176](https://moonbase.subscan.io/block/675176){target=\_blank} | | 701 | - | [581187](https://moonriver.subscan.io/block/581187){target=\_blank} | [797200](https://moonbase.subscan.io/block/797200){target=\_blank} | | 800 | - | [684728](https://moonriver.subscan.io/block/684728){target=\_blank} | [915684](https://moonbase.subscan.io/block/915684){target=\_blank} | | 900 | [0](https://moonbeam.subscan.io/block/0){target=\_blank} | [923864](https://moonriver.subscan.io/block/923864){target=\_blank} | [1075626](https://moonbase.subscan.io/block/1075626){target=\_blank} | | 901 | - | - | [1130271](https://moonbase.subscan.io/block/1130271){target=\_blank} | | 902 | - | - | [1175311](https://moonbase.subscan.io/block/1175311){target=\_blank} | | 1001 | [5165](https://moonbeam.subscan.io/block/5165){target=\_blank} | [1052242](https://moonriver.subscan.io/block/1052242){target=\_blank} | [1285916](https://moonbase.subscan.io/block/1285916){target=\_blank} | | 1002 | [32532](https://moonbeam.subscan.io/block/32532){target=\_blank} | [1141593](https://moonriver.subscan.io/block/1141593){target=\_blank} | [1396972](https://moonbase.subscan.io/block/1396972){target=\_blank} | | 1101 | [171061](https://moonbeam.subscan.io/block/171061){target=\_blank} | [1188000](https://moonriver.subscan.io/block/1188000){target=\_blank} | [1426319](https://moonbase.subscan.io/block/1426319){target=\_blank} | | 1102 | [214641](https://moonbeam.subscan.io/block/214641){target=\_blank} | [1295420](https://moonriver.subscan.io/block/1295420){target=\_blank} | [1517440](https://moonbase.subscan.io/block/1517440){target=\_blank} | | 1103 | [312036](https://moonbeam.subscan.io/block/312036){target=\_blank} | [1389122](https://moonriver.subscan.io/block/1389122){target=\_blank} | [1591913](https://moonbase.subscan.io/block/1591913){target=\_blank} | | 1200 | - | - | [1648994](https://moonbase.subscan.io/block/1648994){target=\_blank} | | 1201 | [415946](https://moonbeam.subscan.io/block/415946){target=\_blank} | [1471037](https://moonriver.subscan.io/block/1471037){target=\_blank} | [1679619](https://moonbase.subscan.io/block/1679619){target=\_blank} | | 1300 | [524762](https://moonbeam.subscan.io/block/524762){target=\_blank} | [1541735](https://moonriver.subscan.io/block/1541735){target=\_blank} | [1761128](https://moonbase.subscan.io/block/1761128){target=\_blank} | | 1400 | - | - | [1962557](https://moonbase.subscan.io/block/1962557){target=\_blank} | | 1401 | [915320](https://moonbeam.subscan.io/block/915320){target=\_blank} | [1705939](https://moonriver.subscan.io/block/1705939){target=\_blank} | [1967358](https://moonbase.subscan.io/block/1967358){target=\_blank} | | 1502 | [1107285](https://moonbeam.subscan.io/block/1107285){target=\_blank} | [1814458](https://moonriver.subscan.io/block/1814458){target=\_blank} | [2112058](https://moonbase.subscan.io/block/2112058){target=\_blank} | | 1503 | [1115896](https://moonbeam.subscan.io/block/1115896){target=\_blank} | [1909326](https://moonriver.subscan.io/block/1909326){target=\_blank} | [2220736](https://moonbase.subscan.io/block/2220736){target=\_blank} | | 1504 | [1117310](https://moonbeam.subscan.io/block/1117310){target=\_blank} | [1910640](https://moonriver.subscan.io/block/1910640){target=\_blank} | [2221773](https://moonbase.subscan.io/block/2221773){target=\_blank} | | 1603 | - | - | [2285347](https://moonbase.subscan.io/block/2285347){target=\_blank} | | 1605 | - | [2077599](https://moonriver.subscan.io/block/2077599){target=\_blank} | [2318567](https://moonbase.subscan.io/block/2318567){target=\_blank} | | 1606 | [1326697](https://moonbeam.subscan.io/block/1326697){target=\_blank} | [2105127](https://moonriver.subscan.io/block/2105127){target=\_blank} | [2379759](https://moonbase.subscan.io/block/2379759){target=\_blank} | | 1700 | - | - | [2529736](https://moonbase.subscan.io/block/2529736){target=\_blank} | | 1701 | [1581457](https://moonbeam.subscan.io/block/1581457){target=\_blank} | [2281723](https://moonriver.subscan.io/block/2281723){target=\_blank} | [2534200](https://moonbase.subscan.io/block/2534200){target=\_blank} | | 1702 | [1821212](https://moonbeam.subscan.io/block/1821212){target=\_blank} | [2524247](https://moonriver.subscan.io/block/2524247){target=\_blank} | - | | 1800 | - | - | [2748786](https://moonbase.subscan.io/block/2748786){target=\_blank} | | 1801 | - | [2572556](https://moonriver.subscan.io/block/2572556){target=\_blank} | [2830542](https://moonbase.subscan.io/block/2830542){target=\_blank} | | 1802 | [1919458](https://moonbeam.subscan.io/block/1919458){target=\_blank} | [2616190](https://moonriver.subscan.io/block/2616190){target=\_blank} | [2879403](https://moonbase.subscan.io/block/2879403){target=\_blank} | | 1803 | [2073477](https://moonbeam.subscan.io/block/2073477){target=\_blank} | [2767174](https://moonriver.subscan.io/block/2767174){target=\_blank} | [3004714](https://moonbase.subscan.io/block/3004714){target=\_blank} | | 1900 | - | - | [3069635](https://moonbase.subscan.io/block/3069635){target=\_blank} | | 1901 | [2317683](https://moonbeam.subscan.io/block/2317683){target=\_blank} | [2911863](https://moonriver.subscan.io/block/2911863){target=\_blank} | [3073562](https://moonbase.subscan.io/block/3073562){target=\_blank} | | 2000 | [2673234](https://moonbeam.subscan.io/block/2673234){target=\_blank} | [3202604](https://moonriver.subscan.io/block/3202604){target=\_blank} | [3310369](https://moonbase.subscan.io/block/3310369){target=\_blank} | | 2100 | [3011798](https://moonbeam.subscan.io/block/3011798){target=\_blank} | [3588831](https://moonriver.subscan.io/block/3588831){target=\_blank} | [3609708](https://moonbase.subscan.io/block/3609708){target=\_blank} | | 2201 | [3290853](https://moonbeam.subscan.io/block/3290853){target=\_blank} | [3858885](https://moonriver.subscan.io/block/3858885){target=\_blank} | [3842850](https://moonbase.subscan.io/block/3842850){target=\_blank} | | 2301 | - | - | [4172407](https://moonbase.subscan.io/block/4172407){target=\_blank} | | 2302 | [3456477](https://moonbeam.subscan.io/block/3456477){target=\_blank} | [4133065](https://moonriver.subscan.io/block/4133065){target=\_blank} | [4193323](https://moonbase.subscan.io/block/4193323){target=\_blank} | | 2401 | - | [4668844](https://moonriver.subscan.io/block/4668844){target=\_blank} | [4591616](https://moonbase.subscan.io/block/4591616){target=\_blank} | | 2402 | - | - | [4772817](https://moonbase.subscan.io/block/4772817){target=\_blank} | | 2403 | [4163078](https://moonbeam.subscan.io/block/4163078){target=\_blank} | [4770488](https://moonriver.subscan.io/block/4770488){target=\_blank} | [4804425](https://moonbase.subscan.io/block/4804425){target=\_blank} | | 2500 | - | [5175574](https://moonriver.subscan.io/block/5175574){target=\_blank} | [5053547](https://moonbase.subscan.io/block/5053547){target=\_blank} | | 2501 | [4543267](https://moonbeam.subscan.io/block/4543267){target=\_blank} | [5211264](https://moonriver.subscan.io/block/5211264){target=\_blank} | [5194594](https://moonbase.subscan.io/block/5194594){target=\_blank} | | [2601](https://forum.moonbeam.network/t/runtime-rt2600-schedule/1372/5){target=\_blank} | - | - | [5474345](https://moonbase.subscan.io/block/5474345){target=\_blank} | | [2602](https://forum.moonbeam.network/t/runtime-rt2600-schedule/1372/13){target=\_blank} | [4977160](https://moonbeam.subscan.io/block/4977160){target=\_blank} | [5638536](https://moonriver.subscan.io/block/5638536){target=\_blank} | [5576588](https://moonbase.subscan.io/block/5576588){target=\_blank} | | [2700](https://forum.moonbeam.network/t/runtime-rt2700-schedule/1441/3){target=\_blank} | [5504531](https://moonbeam.subscan.io/block/5504531){target=\_blank} | [6041969](https://moonriver.subscan.io/block/6041969){target=\_blank} | [5860584](https://moonbase.subscan.io/block/5860584){target=\_blank} | | [2801](https://forum.moonbeam.network/t/runtime-rt2801-schedule/1616/4){target=\_blank} | [5899847](https://moonbeam.subscan.io/block/5899847){target=\_blank} | [6411588](https://moonriver.subscan.io/block/6411588){target=\_blank} | [6209638](https://moonbase.subscan.io/block/6209638){target=\_blank} | | [2901](https://forum.moonbeam.network/t/runtime-rt2901-schedule/1695/3){target=\_blank} | [6197065](https://moonbeam.subscan.io/block/6197065){target=\_blank} | [6699589](https://moonriver.subscan.io/block/6699589){target=\_blank} | [6710531](https://moonbase.subscan.io/block/6710531){target=\_blank} | | 2902 | - | - | [6732678](https://moonbase.subscan.io/block/6732678){target=\_blank} | | [3000](https://forum.moonbeam.network/t/runtime-rt3000-schedule/1752/2){target=\_blank} | - | [7043011](https://moonriver.subscan.io/block/7043011){target=\_blank} | [7299818](https://moonbase.subscan.io/block/7299818){target=\_blank} | | 3001 | [6593037](https://moonbeam.subscan.io/block/6593037){target=\_blank} | - | - | | [3100](https://forum.moonbeam.network/t/runtime-rt3100-schedule/1801){target=\_blank} | [7303601](https://moonbeam.subscan.io/block/7303601){target=\_blank} | [7829527](https://moonriver.subscan.io/block/7829527){target=\_blank} | [8034666](https://moonbase.subscan.io/block/8034666){target=\_blank} | | [3102](https://forum.moonbeam.network/t/runtime-rt3100-schedule/1801/10){target=\_blank} | [7586782](https://moonbeam.subscan.io/block/7586782){target=\_blank} | - | - | | [3200](https://forum.moonbeam.network/t/runtime-rt3200-schedule/1881){target=\_blank} | [7985204](https://moonbeam.subscan.io/block/7985204){target=\_blank} | [8519187](https://moonriver.subscan.io/block/8519187){target=\_blank} | [8722328](https://moonbase.subscan.io/block/8722328){target=\_blank} | | [3300](https://forum.moonbeam.network/t/runtime-rt3300-schedule/1897){target=\_blank} | [8381443](https://moonbeam.subscan.io/block/8381443){target=\_blank} | [8894417](https://moonriver.subscan.io/block/8894417){target=\_blank} | [9062316](https://moonbase.subscan.io/block/9062316){target=\_blank} | | [3400](https://forum.moonbeam.network/t/runtime-rt3400-schedule/1954){target=\_blank} | [9376921](https://moonbeam.subscan.io/block/9376921){target=\_blank} | [9774989](https://moonriver.subscan.io/block/9774989){target=\_blank} | [9830392](https://moonbase.subscan.io/block/9830392){target=\_blank} | | [3401](https://forum.moonbeam.network/t/runtime-rt3400-schedule/1954/6){target=\_blank} | [9661355](https://moonbeam.subscan.io/block/9661355){target=\_blank} | [10269872](https://moonriver.subscan.io/block/10269872){target=\_blank} | [10422450](https://moonbase.subscan.io/block/10422450){target=\_blank} | | [3500](https://forum.moonbeam.network/t/runtime-rt3501-schedule/2010){target=\_blank} | - | - | [10750816](https://moonbase.subscan.io/block/10750816){target=\_blank} | | [3501](https://forum.moonbeam.network/t/runtime-rt3501-schedule/2010){target=\_blank} | [10056989](https://moonbeam.subscan.io/block/10056989){target=\_blank} | [10665393](https://moonriver.subscan.io/block/10665393){target=\_blank} | [10833906](https://moonbase.subscan.io/block/10833906){target=\_blank} | | [3600](https://forum.moonbeam.network/t/runtime-rt3600-schedule/2071){target=\_blank} | [10746745](https://moonbeam.subscan.io/block/10746745){target=\_blank} | [11251274](https://moonriver.subscan.io/block/11251274){target=\_blank} | [11452321](https://moonbase.subscan.io/block/11452321){target=\_blank} | | [3601](https://forum.moonbeam.network/t/proposals-mr77-mb110-whitelisted-authorize-upgrade-to-rt3601-on-moonriver-and-moonbeam/2139){target=\_blank} | [10999397](https://moonbeam.subscan.io/block/10999397){target=\_blank} | [11692212](https://moonriver.subscan.io/block/11692212){target=\_blank} | - | | [3700](https://forum.moonbeam.network/t/runtime-rt3700-schedule/2129){target=\_blank} | - | - | [12152458](https://moonbase.subscan.io/block/12152458){target=\_blank} | | [3701](https://forum.moonbeam.network/t/runtime-rt3700-schedule/2129){target=\_blank} | [11426910](https://moonbeam.subscan.io/block/11426910) | [12003279](https://moonriver.subscan.io/block/12003279){target=\_blank} | [12242104](https://moonbase.subscan.io/block/12242104){target=\_blank} | | [3702](https://forum.moonbeam.network/t/proposals-mr81-mb118-authorize-upgrade-to-rt3702-on-moonriver-and-moonbeam-via-whitelist/2173){target=\_blank} | [11499659](https://moonbeam.subscan.io/block/11499659){target=\_blank} | [12156948](https://moonriver.subscan.io/block/12156948){target=\_blank} | [12683255](https://moonbase.subscan.io/block/12683255){target=\_blank} | | [3800](https://forum.moonbeam.network/t/runtime-rt3800-schedule/2188){target=\_blank} | [12120762](https://moonbeam.subscan.io/block/12120762){target=\_blank} | [12540836](https://moonriver.subscan.io/block/12540836){target=\_blank} | [12853655](https://moonbase.subscan.io/block/12853655){target=\_blank} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/canonical-contracts/ --- BEGIN CONTENT --- --- title: Canonical Contract Addresses on Moonbeam description: Overview of the canonical contracts available on Moonbeam, Moonriver, & Moonbase Alpha, including common-good contracts and precompiles. keywords: canonical, ethereum, moonbeam, precompiled, contracts categories: Reference, Precompiles, Ethereum Toolkit --- # Canonical Contracts ## Common-good Contracts {: #common-goods-contracts } The following contracts addresses have been established: === "Moonbeam" | Contract | Address | |:------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [WGLMR](https://moonbeam.moonscan.io/address/0xAcc15dC74880C9944775448304B263D191c6077F#code){target=\_blank} | 0xAcc15dC74880C9944775448304B263D191c6077F | | [Multicall](https://moonbeam.moonscan.io/address/0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B#code){target=\_blank} | 0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B | | [Multicall2](https://moonbeam.moonscan.io/address/0x6477204E12A7236b9619385ea453F370aD897bb2#code){target=\_blank} | 0x6477204E12A7236b9619385ea453F370aD897bb2 | | [Multicall3](https://moonbeam.moonscan.io/address/0xca11bde05977b3631167028862be2a173976ca11#code){target=\_blank} | 0xcA11bde05977b3631167028862bE2a173976CA11 | | [Multisig Factory](https://moonbeam.moonscan.io/address/0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2#code){target=\_blank} | 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2 | | [EIP-1820](https://eips.ethereum.org/EIPS/eip-1820){target=\_blank} | 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 | === "Moonriver" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [WMOVR](https://moonriver.moonscan.io/token/0x98878b06940ae243284ca214f92bb71a2b032b8a#code){target=\_blank} | 0x98878B06940aE243284CA214f92Bb71a2b032B8A | | [Multicall](https://moonriver.moonscan.io/address/0x30f283Cc0284482e9c29dFB143bd483B5C19954b#code){target=\_blank}* | 0x30f283Cc0284482e9c29dFB143bd483B5C19954b | | [Multicall2](https://moonriver.moonscan.io/address/0xaef00a0cf402d9dedd54092d9ca179be6f9e5ce3#code){target=\_blank} | 0xaef00a0cf402d9dedd54092d9ca179be6f9e5ce3 | | [Multicall3](https://moonriver.moonscan.io/address/0xca11bde05977b3631167028862be2a173976ca11#code){target=\_blank} | 0xcA11bde05977b3631167028862bE2a173976CA11 | | [Multisig Factory](https://moonriver.moonscan.io/address/0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2#code){target=\_blank} | 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2 | | [EIP-1820](https://eips.ethereum.org/EIPS/eip-1820){target=\_blank} | 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 | _*Deployed by SushiSwap_ === "Moonbase Alpha" | Contract | Address | |:------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [WDEV](https://moonbase.moonscan.io/address/0xD909178CC99d318e4D46e7E66a972955859670E1#code){target=\_blank} | 0xD909178CC99d318e4D46e7E66a972955859670E1 | | [Multicall](https://moonbase.moonscan.io/address/0x4E2cfca20580747AdBA58cd677A998f8B261Fc21#code){target=\_blank}* | 0x4E2cfca20580747AdBA58cd677A998f8B261Fc21 | | [Multicall2](https://moonbase.moonscan.io/address/0x37084d0158C68128d6Bc3E5db537Be996f7B6979#code){target=\_blank} | 0x37084d0158C68128d6Bc3E5db537Be996f7B6979 | | [Multicall3](https://moonbase.moonscan.io/address/0xca11bde05977b3631167028862be2a173976ca11#code){target=\_blank} | 0xcA11bde05977b3631167028862bE2a173976CA11 | | [Multisig Factory](https://moonbase.moonscan.io/address/0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2#code){target=\_blank} | 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2 | | [EIP-1820](https://eips.ethereum.org/EIPS/eip-1820){target=\_blank} | 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 | _*Deployed in the [UniswapV2 Demo Repo](https://github.com/papermoonio/moonbeam-uniswap/tree/main/uniswap-contracts-moonbeam){target=\_blank}_ ## Precompiled Contracts {: #precompiled-contracts } There are a set of precompiled contracts included on Moonbeam, Moonriver, and Moonbase Alpha that are categorized by address and based on the origin network. If you were to convert the precompiled addresses to decimal format, and break them into categories by numeric value, the categories are as follows: - **0-1023** - [Ethereum MainNet precompiles](#ethereum-mainnet-precompiles) - **1024-2047** - precompiles that are [not in Ethereum and not Moonbeam specific](#non-moonbeam-specific-nor-ethereum-precomiles) - **2048-4095** - [Moonbeam specific precompiles](#moonbeam-specific-precompiles) ### Ethereum MainNet Precompiles {: #ethereum-mainnet-precompiles } === "Moonbeam" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonriver" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonbase Alpha" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | ### Non-Moonbeam Specific nor Ethereum Precompiles {: #non-moonbeam-specific-nor-ethereum-precompiles } === "Moonbeam" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonriver" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonbase Alpha" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | ### Moonbeam-Specific Precompiles {: #moonbeam-specific-precompiles } === "Moonbeam" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbeam.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbeam.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbeam.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbeam.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbeam.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbeam.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbeam.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbeam.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbeam.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbeam.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbeam.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbeam.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbeam.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v3}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbeam.precompiles.identity}} | | [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_interface}} | === "Moonriver" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonriver.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonriver.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonriver.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonriver.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonriver.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonriver.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonriver.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonriver.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonriver.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonriver.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonriver.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonriver.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonriver.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v3}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonriver.precompiles.identity}} | | [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_interface}} | === "Moonbase Alpha" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbase.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | | [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_interface}} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/json-rpc/eth-rpc/ --- BEGIN CONTENT --- --- title: Standard Ethereum JSON-RPC Methods description: Explore a comprehensive list of standard Ethereum JSON-RPC methods that can be used to interface with Moonbeam nodes programmatically. categories: JSON-RPC APIs, Reference, Ethereum Toolkit --- # Supported Ethereum RPC Methods ## Introduction {: #introduction } The Moonbeam team has collaborated closely with [Parity](https://www.parity.io){target=\_blank} on developing [Frontier](/learn/platform/technology/#frontier){target=\_blank}, an Ethereum compatibility layer for Substrate-based chains. This layer enables developers to run unmodified Ethereum dApps on Moonbeam seamlessly. Nevertheless, not all Ethereum JSON-RPC methods are supported; some of those supported return default values (those related to Ethereum's PoW consensus mechanism in particular). This guide provides a comprehensive list of supported Ethereum JSON-RPC methods on Moonbeam. Developers can quickly reference this list to understand the available functionality for interfacing with Moonbeam's Ethereum-compatible blockchain. ## Standard Ethereum JSON-RPC Methods {: #basic-rpc-methods } The basic JSON-RPC methods from the Ethereum API supported by Moonbeam are: - **[eth_protocolVersion](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_protocolversion){target=\_blank}** — returns `1` by default - **[eth_syncing](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_syncing){target=\_blank}** — returns an object with data about the sync status or `false` - **[eth_hashrate](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_hashrate){target=\_blank}** — returns `"0x0"` by default - **[eth_coinbase](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_coinbase){target=\_blank}** — returns the latest block author. Not necessarily a finalized block - **[eth_mining](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_mining){target=\_blank}** — returns `false` by default - **[eth_chainId](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid){target=\_blank}** — returns the chain ID used for signing at the current block - **[eth_gasPrice](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice){target=\_blank}** — returns the base fee per unit of gas used. This is currently the minimum gas price for each network - **[eth_accounts](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_accounts){target=\_blank}** — returns a list of addresses owned by the client - **[eth_blockNumber](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber){target=\_blank}** — returns the highest available block number - **[eth_getBalance](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance){target=\_blank}** — returns the balance of the given address. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_getStorageAt](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getstorageat){target=\_blank}** — returns the content of the storage at a given address. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_getBlockByHash](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash){target=\_blank}** — returns information about the block of the given hash, including `baseFeePerGas` on post-London blocks - **[eth_getBlockByNumber](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber){target=\_blank}** — returns information about the block specified by block number, including `baseFeePerGas` on post-London blocks. Instead of providing a block number as the first parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_getBlockReceipts](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-get-block-receipts){target=\_blank}** — returns all transaction receipts for a given block - **[eth_getTransactionCount](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount){target=\_blank}** — returns the number of transactions sent from the given address (nonce). Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_getBlockTransactionCountByHash](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash){target=\_blank}** — returns the number of transactions in a block with a given block hash - **[eth_getBlockTransactionCountByNumber](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber){target=\_blank}** — returns the number of transactions in a block with a given block number - **[eth_getUncleCountByBlockHash](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclecountbyblockhash){target=\_blank}** — returns `"0x0"` by default - **[eth_getUncleCountByBlockNumber](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclecountbyblocknumber){target=\_blank}** — returns `"0x0"` by default - **[eth_getCode](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode){target=\_blank}** — returns the code at the given address at the given block number. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_sendTransaction](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction){target=\_blank}** — creates a new message call transaction or a contract creation, if the data field contains code. Returns the transaction hash or the zero hash if the transaction is not yet available - **[eth_sendRawTransaction](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction){target=\_blank}** — creates a new message call transaction or a contract creation for signed transactions. Returns the transaction hash or the zero hash if the transaction is not yet available - **[eth_call](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call){target=\_blank}** — executes a new message call immediately without creating a transaction on the blockchain, returning the value of the executed call - Moonbeam supports the use of the optional _state override set_ object. This address-to-state mapping object allows the user to specify some state to be ephemerally overridden before executing a call to `eth_call`. The state override set is commonly used for tasks like debugging smart contracts. Visit the [go-ethereum](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#:~:text=Object%20%2D%20State%20override%20set){target=\_blank} documentation to learn more - Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_estimateGas](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas){target=\_blank}** — returns an estimated amount of gas necessary for a given transaction to succeed. You can optionally specify a `gasPrice` or `maxFeePerGas` and `maxPriorityFeePerGas`. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_maxPriorityFeePerGas](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-max-priority-fee-per-gas){target=\_blank}** - returns an estimate of how much priority fee, in Wei, is needed for inclusion in a block - **[eth_feeHistory](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-fee-history){target=\_blank}** — returns `baseFeePerGas`, `gasUsedRatio`, `oldestBlock`, and `reward` for a specified range of up to 1024 blocks - **[eth_getTransactionByHash](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyhash){target=\_blank}** — returns the information about a transaction with a given hash. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields - **[eth_getTransactionByBlockHashAndIndex](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyblockhashandindex){target=\_blank}** — returns information about a transaction at a given block hash and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields - **[eth_getTransactionByBlockNumberAndIndex](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyblocknumberandindex){target=\_blank}** — returns information about a transaction at a given block number and a given index position. EIP-1559 transactions have `maxPriorityFeePerGas` and `maxFeePerGas` fields. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_getTransactionReceipt](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt){target=\_blank}** — returns the transaction receipt of a given transaction hash - **[eth_getUncleByBlockHashAndIndex](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclebyblockhashandindex){target=\_blank}** — returns `null` by default - **[eth_getUncleByBlockNumberAndIndex](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclebyblocknumberandindex){target=\_blank}** — returns `null` by default - **[eth_getLogs](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs){target=\_blank}** — returns an array of all logs matching a given filter object. Instead of providing a block number as a parameter, you can provide a [default block parameter](#default-block-parameters) - **[eth_newFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter){target=\_blank}** — creates a filter object based on the input provided. Returns a filter ID - **[eth_newBlockFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newblockfilter){target=\_blank}** — creates a filter in the node to notify when a new block arrives. Returns a filter ID - **[eth_newPendingTransactionFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter){target=\_blank}** - creates a filter in the node to notify when new pending transactions arrive. Returns a filter ID - **[eth_getFilterChanges](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges){target=\_blank}** — polling method for filters (see methods above). Returns an array of logs that occurred since the last poll - **[eth_getFilterLogs](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs){target=\_blank}** — returns an array of all the logs matching the filter with a given ID - **[eth_uninstallFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallfilter){target=\_blank}** — uninstall a filter with a given ID. It should be used when polling is no longer needed. Filters timeout when they are not requested using `eth_getFilterChanges` after some time ## Default Block Parameters {: #default-block-parameters } Moonbeam supports several default block parameters that allow you to query a subset of JSON-RPC methods at significant block heights. Moonbeam supports the following default block parameters: - `finalized` - Refers to the most recent block that Polkadot validators have finalized - `safe` - Synonymous with `finalized` in Moonbeam. In Ethereum, `safe` refers to the most recent block that is considered safe by the network, meaning it is unlikely to be reverted but has not yet been finalized. With Moonbeam's fast and deterministic finality, `finalized` and `safe` refer to the same blocks. - `earliest` - Refers to the genesis block of the blockchain - `pending` - Represents the latest state, including pending transactions that have not yet been mined into a block. This is a live view of the mempool - `latest` - Refers to the latest confirmed block in the blockchain, which may not be finalized ## Unsupported Ethereum JSON-RPC Methods {: #unsupported-rpc-methods } Moonbeam does not support the following Ethereum API JSON-RPC methods: - **[eth_getProof](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-get-proof){target=\_blank}** - returns the account and storage values of the specified account including the Merkle-proof - **[eth_blobBaseFee](https://www.quicknode.com/docs/ethereum/eth_blobBaseFee){target=\_blank}** - returns the expected base fee for blobs in the next block - **[eth_createAccessList](https://www.alchemy.com/docs/node/ethereum/ethereum-api-endpoints/eth-create-access-list){target=\_blank}** - creates an EIP-2930 type `accessList` based on a given transaction object - **[eth_sign](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign){target=\_blank}** - allows the user to sign an arbitrary hash to be sent at a later time. Presents a [security risk](https://support.metamask.io/privacy-and-security/what-is-eth_sign-and-why-is-it-a-risk/){target=\_blank} as the arbitrary hash can be fraudulently applied to other transactions - **[eth_signTransaction](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_signtransaction){target=\_blank}** - allows the user to sign a transaction to be sent at a later time. It is rarely used due to associated security risks ## Additional RPC Methods {: #additional-rpc-methods } Check out some of the non-standard Ethereum and Moonbeam-specific RPC methods: - [Debug and Trace](/builders/ethereum/json-rpc/debug-trace/) - [Event Subscription](/builders/ethereum/json-rpc/pubsub/) - [Custom Moonbeam](/builders/ethereum/json-rpc/moonbeam-custom-api/) --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/json-rpc/moonbeam-custom-api/ --- BEGIN CONTENT --- --- title: Moonbeam-specific RPC Methods description: Discover Moonbeam's specialized API endpoints, featuring custom JSON-RPC methods designed exclusively for Moonbeam functionality. categories: JSON-RPC APIs, Reference --- # Moonbeam Custom API ## Introduction {: #introduction } Moonbeam nodes include support for custom JSON-RPC endpoints: - `moon_isBlockFinalized` - `moon_isTxFinalized` - `moon_getEthSyncBlockRange` These endpoints provide valuable functionality for checking the finality of on-chain events. To begin exploring Moonbeam's custom JSON-RPC endpoints, you can try out the provided curl examples below. These examples demonstrate how to query the public RPC endpoint of Moonbase Alpha. However, you can easily modify them to use with your own Moonbeam or Moonriver endpoint by changing the URL and API key. If you haven't already, you can obtain your endpoint and API key from one of our supported [Endpoint Providers](/builders/get-started/endpoints/){target=\_blank}. ## Supported Custom RPC Methods {: #rpc-methods } ???+ function "moon_isBlockFinalized" Checks for the finality of the block given by its block hash. === "Parameters" - `block_hash` *string* - the hash of the block, accepts either Substrate-style or Ethereum-style block hash as its input === "Returns" Returns a boolean: `true` if the block is finalized, `false` if the block is not finalized or not found. === "Example" ```bash curl -H "Content-Type: application/json" -X POST --data '{ "jsonrpc": "2.0", "id": "1", "method": "moon_isBlockFinalized", "params": ["INSERT_BLOCK_HASH"] }' {{ networks.moonbase.rpc_url }} ``` ???+ function "moon_isTxFinalized" Checks for the finality of a transaction given its EVM transaction hash. === "Parameters" - `tx_hash` *string* - the EVM transaction hash of the transaction === "Returns" Returns a boolean: `true` if the transaction is finalized, `false` if the transaction is not finalized or not found. === "Example" ```bash curl -H "Content-Type: application/json" -X POST --data '{ "jsonrpc": "2.0", "id": "1", "method": "moon_isTxFinalized", "params": ["INSERT_TRANSACTION_HASH"] }' {{ networks.moonbase.rpc_url }} ``` ???+ function "moon_getEthSyncBlockRange" Returns the range of blocks that are fully indexed in Frontier's backend. === "Parameters" None === "Returns" Returns the range of blocks that are fully indexed in Frontier's backend. An example response below includes the Substrate block hashes of block `0` and the latest fully indexed block: ```[ "0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527", "0xb1b49bd709ca9fe0e751b8648951ffbb2173e1258b8de8228cfa0ab27003f612" ]``` === "Example" ```bash curl -H "Content-Type: application/json" -X POST --data '{ "jsonrpc": "2.0", "id": "1", "method": "moon_getEthSyncBlockRange", "params": [] }' {{ networks.moonbase.rpc_url }} ``` --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/ethereum/precompiles/overview/ --- BEGIN CONTENT --- --- title: Solidity Precompiles description: An overview of the available Solidity precompiles on Moonbeam. Precompiles enable you to interact with Substrate features using the Ethereum API. categories: Reference, Basics --- # Overview of the Precompiled Contracts on Moonbeam ## Overview {: #introduction } On Moonbeam, a precompiled contract is native Substrate code that has an Ethereum-style address and can be called using the Ethereum API, like any other smart contract. The precompiles allow you to call the Substrate runtime directly which is not normally accessible from the Ethereum side of Moonbeam. The Substrate code responsible for implementing precompiles can be found in the [EVM pallet](/learn/platform/technology/#evm-pallet){target=\_blank}. The EVM pallet includes the [standard precompiles found on Ethereum and some additional precompiles that are not specific to Ethereum](https://github.com/polkadot-evm/frontier/tree/master/frame/evm/precompile){target=\_blank}. It also provides the ability to create and execute custom precompiles through the generic [`Precompiles` trait](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm/trait.Precompile.html){target=\_blank}. There are several custom Moonbeam-specific precompiles that have been created, all of which can be found in the [Moonbeam codebase](https://github.com/moonbeam-foundation/moonbeam/tree/master/precompiles){target=\_blank}. It is important to highlight that the precompiles from this list with the `CallableByContract` check are not callable inside the contract constructor. The Ethereum precompiled contracts contain complex functionality that is computationally intensive, such as hashing and encryption. The custom precompiled contracts on Moonbeam provide access to Substrate-based functionality such as staking, governance, XCM-related functions, and more. The Moonbeam-specific precompiles can be interacted with through familiar and easy-to-use Solidity interfaces using the Ethereum API, which are ultimately used to interact with the underlying Substrate interface. This flow is depicted in the following diagram: ![Precompiled Contracts Diagram](/images/builders/ethereum/precompiles/overview/overview-1.webp) !!! note There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security/){target=\_blank} page for more information. ## Precompiled Contract Addresses {: #precompiled-contract-addresses } The precompiled contracts are categorized by address and based on the origin network. If you were to convert the precompiled addresses to decimal format, and break them into categories by numeric value, the categories are as follows: - **0-1023** - [Ethereum MainNet precompiles](#ethereum-mainnet-precompiles) - **1024-2047** - precompiles that are [not in Ethereum and not Moonbeam specific](#non-moonbeam-specific-nor-ethereum-precomiles) - **2048-4095** - [Moonbeam specific precompiles](#moonbeam-specific-precompiles) ### Ethereum MainNet Precompiles {: #ethereum-mainnet-precompiles } === "Moonbeam" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonriver" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | === "Moonbase Alpha" | Contract | Address | |:---------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [ECRECOVER](/builders/ethereum/precompiles/utility/eth-mainnet/#verify-signatures-with-ecrecover){target=\_blank} | 0x0000000000000000000000000000000000000001 | | [SHA256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha256){target=\_blank} | 0x0000000000000000000000000000000000000002 | | [RIPEMD160](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-ripemd-160){target=\_blank} | 0x0000000000000000000000000000000000000003 | | [Identity](/builders/ethereum/precompiles/utility/eth-mainnet/#the-identity-function){target=\_blank} | 0x0000000000000000000000000000000000000004 | | [Modular Exponentiation](/builders/ethereum/precompiles/utility/eth-mainnet/#modular-exponentiation){target=\_blank} | 0x0000000000000000000000000000000000000005 | | [BN128Add](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128add){target=\_blank} | 0x0000000000000000000000000000000000000006 | | [BN128Mul](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128mul){target=\_blank} | 0x0000000000000000000000000000000000000007 | | [BN128Pairing](/builders/ethereum/precompiles/utility/eth-mainnet/#bn128pairing){target=\_blank} | 0x0000000000000000000000000000000000000008 | | [Blake2](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_blake2/struct.Blake2F.html){target=\_blank} | 0x0000000000000000000000000000000000000009 | | [P256Verify](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md){target=\_blank} | 0x0000000000000000000000000000000000000100 | ### Non-Moonbeam Specific nor Ethereum Precompiles {: #non-moonbeam-specific-nor-ethereum-precompiles } === "Moonbeam" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonriver" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | === "Moonbase Alpha" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:| | [SHA3FIPS256](/builders/ethereum/precompiles/utility/eth-mainnet/#hashing-with-sha3fips256){target=\_blank} | 0x0000000000000000000000000000000000000400 | | Dispatch [Removed] | 0x0000000000000000000000000000000000000401 | | [ECRecoverPublicKey](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm_precompile_simple/struct.ECRecoverPublicKey.html){target=\_blank} | 0x0000000000000000000000000000000000000402 | ### Moonbeam Specific Precompiles {: #moonbeam-specific-precompiles } === "Moonbeam" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbeam.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbeam.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbeam.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbeam.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbeam.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbeam.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbeam.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbeam.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbeam.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbeam.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbeam.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbeam.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbeam.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbeam.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_transactor_v3}} | | [XCM interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbeam.precompiles.identity}} | === "Moonriver" | Contract | Address | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonriver.precompiles.erc20}} | | Democracy [Disabled] | {{networks.moonriver.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonriver.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonriver.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonriver.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonriver.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonriver.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonriver.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonriver.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonriver.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonriver.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonriver.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonriver.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonriver.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_transactor_v3}} | | [XCM interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonriver.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonriver.precompiles.identity}} | === "Moonbase Alpha" | Contract | Address | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:| | [Parachain Staking](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.staking}} | | [Crowdloan Rewards](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/crowdloan-rewards/CrowdloanInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.crowdloan}} | | [ERC-20 Interface](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/ERC20.sol){target=\_blank} | {{networks.moonbase.precompiles.erc20}} | | Democracy [Removed] | {{networks.moonbase.precompiles.democracy}} | | [X-Tokens](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xtokens/Xtokens.sol){target=\_blank} | {{networks.moonbase.precompiles.xtokens}} | | [Relay Encoder](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/relay-encoder/RelayEncoder.sol){target=\_blank} | {{networks.moonbase.precompiles.relay_encoder}} | | [XCM Transactor V1](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v1/XcmTransactorV1.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v1}} | | [Author Mapping](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/author-mapping/AuthorMappingInterface.sol){target=\_blank} | {{networks.moonbase.precompiles.author_mapping}} | | [Batch](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/batch/Batch.sol){target=\_blank} | {{networks.moonbase.precompiles.batch}} | | [Randomness](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/randomness/Randomness.sol){target=\_blank} | {{networks.moonbase.precompiles.randomness}} | | [Call Permit](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/call-permit/CallPermit.sol){target=\_blank} | {{networks.moonbase.precompiles.call_permit}} | | [Proxy](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/proxy/Proxy.sol){target=\_blank} | {{networks.moonbase.precompiles.proxy}} | | [XCM Utilities](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-utils/XcmUtils.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_utils}} | | [XCM Transactor V2](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v2/XcmTransactorV2.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v2}} | | [Council Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_council}} | | [Technical Committee Collective [Removed]](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_tech_committee}} | | [Treasury Council Collective](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_treasury}} | | [Referenda](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/referenda/Referenda.sol){target=\_blank} | {{networks.moonbase.precompiles.referenda}} | | [Conviction Voting](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/conviction-voting/ConvictionVoting.sol){target=\_blank} | {{networks.moonbase.precompiles.conviction_voting}} | | [Preimage](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/preimage/Preimage.sol){target=\_blank} | {{networks.moonbase.precompiles.preimage}} | | [OpenGov Tech Committee](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/collective/Collective.sol){target=\_blank} | {{networks.moonbase.precompiles.collective_opengov_tech_committee}} | | [Precompile Registry](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/precompile-registry/PrecompileRegistry.sol){target=\_blank} | {{networks.moonbase.precompiles.registry}} | | [GMP](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/gmp/Gmp.sol){target=\_blank} | {{networks.moonbase.precompiles.gmp}} | | [XCM Transactor V3](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/xcm-transactor/src/v3/XcmTransactorV3.sol){target=\_blank} | {{networks.moonbase.precompiles.xcm_transactor_v3}} | | [XCM Interface](https://github.com/Moonsong-Labs/moonkit/blob/main/precompiles/pallet-xcm/XcmInterface.sol){target=\_blank} | {{networks.moonbeam.precompiles.xcm_interface}} | | [Identity](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/identity/Identity.sol){target=\_blank} | {{networks.moonbase.precompiles.identity}} | --- END CONTENT --- Doc-Content: https://docs.moonbeam.network/builders/get-started/endpoints/ --- BEGIN CONTENT --- --- title: Moonbeam API Providers and Endpoints description: Use one of the supported API providers to connect to a public endpoint or create custom JSON-RPC and WSS endpoints for Moonbeam-based networks. categories: JSON-RPC APIs, Reference --- # Network Endpoints ## Public Endpoints {: #public-endpoints } Moonbeam-based networks have two endpoints available for users to connect to: one for HTTPS and one for WSS. The endpoints in this section are for development purposes only and are not meant to be used in production applications. If you are looking for an API provider suitable for production use, you can check out the [Endpoint Providers](#endpoint-providers) section of this guide. ### Moonbeam {: #moonbeam } === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbeam.public.curie.radiumblock.co/http```
| 200 req/sec | | 1RPC |
```https://1rpc.io/glmr```
| 10k req/day | | Grove |
```https://moonbeam.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:--------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbeam-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonbeam.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbeam.public.curie.radiumblock.co/ws```
| 200 req/sec | | 1RPC |
```wss://1rpc.io/glmr```
| 10k req/day | ### Moonriver {: #moonriver } === "HTTPS" | Provider | RPC URL | Limits | |:-----------:|:-------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonriver.api.onfinality.io/public```
| 40 req/sec | | UnitedBloc |
```https://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonriver.public.curie.radiumblock.co/http```
| 200 req/sec | | Grove |
```https://moonriver.rpc.grove.city/v1/01fdb492```
| 5k req/day | === "WSS" | Provider | RPC URL | Limits | |:-----------:|:---------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonriver-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonriver.api.onfinality.io/public-ws```
| 40 req/sec | | UnitedBloc |
```wss://moonriver.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonriver.public.curie.radiumblock.co/ws```
| 200 req/sec | ### Moonbase Alpha {: #moonbase-alpha } === "HTTPS" | Provider | RPC URL | Limits | |:-------------------:|:------------------------------------------------------------------:|:-----------:| | Dwellir |
```https://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```https://moonbeam-alpha.api.onfinality.io/public```
| 40 req/sec | | Moonbeam Foundation |
```https://rpc.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```https://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```https://moonbase.public.curie.radiumblock.co/http```
| 200 req/sec | === "WSS" | Provider | RPC URL | Limits | |:-------------------:|:-----------------------------------------------------------------:|:-----------:| | Dwellir |
```wss://moonbase-rpc.dwellir.com```
| 20 req/sec | | OnFinality |
```wss://moonbeam-alpha.api.onfinality.io/public-ws```
| 40 req/sec | | Moonbeam Foundation |
```wss://wss.api.moonbase.moonbeam.network```
| 25 req/sec | | UnitedBloc |
```wss://moonbase.unitedbloc.com```
| 32 req/sec | | RadiumBlock |
```wss://moonbase.public.curie.radiumblock.co/ws```
| 200 req/sec | #### Relay Chain {: #relay-chain } To connect to the Moonbase Alpha relay chain, you can use the following WS Endpoint: | Provider | RPC URL | |:--------:|:----------------------------------------------------------:| | OpsLayer |
```wss://relay.api.moonbase.moonbeam.network```
| ## RPC Endpoint Providers {: #endpoint-providers } You can create your own endpoint suitable for development or production use using any of the following API providers: - [1RPC](#1rpc) - [Blast](#blast) - [Chainstack](#chainstack) - [dRPC](#drpc) - [Dwellir](#dwellir) - [GetBlock](#getblock) - [Grove](#grove) - [OnFinality](#onfinality) - [UnitedBloc](#unitedbloc) ### 1RPC {: #1rpc} [1RPC](https://www.1rpc.io){target=_blank} is a free and private RPC relay that protects user privacy by preventing data collection, user tracking, phishing attempts from other parties. It tunnels user requests via distributed relays to other RPC providers whilst preventing the tracking of user metadata such as IP address, device information and wallet linkability with secure enclave technology. 1RPC is created to be an open initiative from the blockchain infrastructure community. They are motivated by a common good mission to help build a better Web3 and encourage anyone who values user privacy to join this open collaboration. Head over to [1RPC](https://www.1rpc.io){target=_blank} official site to set it up! ![1RPC](/images/builders/get-started/endpoints/endpoints-1.webp) ### Blast {: #blast} As a user of [Blast](https://blastapi.io){target=_blank} powered by Bware Labs, you will be able to obtain your own free endpoint allowing you to interact with Moonbeam, just by performing a few simple clicks within a user-friendly interface. To get started, you'll need to head to [Blast](https://blastapi.io){target=_blank}, and launch the app, and connect your wallet. Once your wallet is connected you will be able to create a project and then generate your own custom endpoint. To generate an endpoint: 1. Create a new project 2. Click on **Available Endpoints** 3. Select Moonbeam network for your endpoint 4. Confirm the selected network and Press **Activate** 5. You'll now see Moonbeam under **Active Endpoints**. Click on the network and you'll see your custom RPC and WSS endpoints on the next page ![Bware Labs](/images/builders/get-started/endpoints/endpoints-2.webp) ### Chainstack {: #chainstack } [Chainstack](https://chainstack.com/){target=_blank}, the Web3 infrastructure provider, offers free and paid endpoints for Moonbeam. The free Developer plan starts with 3 million monthly requests and 25 requests per second (RPS). You can easily scale with the paid plans. To start with a free Developer plan endpoint, sign up using an email or any social account, like GitHub or X (Twitter). 1. Visit [Chainstack](https://console.chainstack.com/){target=_blank} 2. Sign up 3. Deploy a Moonbeam node ![Chainstack](/images/builders/get-started/endpoints/endpoints-3.webp) ### dRPC.org {: #drpc } dRPC.org offers public and paid [Moonbeam RPC](https://drpc.org/chainlist/moonbeam){target=_blank} endpoints, providing an efficient, low-latency connection to blockchain nodes. The paid tiers include higher request limits, lower latency, and advanced analytics for optimized performance. How to use dRPC: 1. Sign up or log in at [dRPC.org](https://drpc.org/){target=_blank} 2. In the dashboard, create an API key 3. Click the key and select the desired endpoint For 24/7 support, join dRPC's [Discord](https://drpc.org/discord){target=_blank}. ### Dwellir {: #dwellir } [Dwellir](https://www.dwellir.com){target=_blank} is a blockchain operation service that ensures global scalability, low latency, and a 99.99% uptime guarantee, providing fast and reliable node operations wherever your business stands. The public endpoint service is geographically distributed bare metal servers globally. As the service is public, there are no sign-up or API keys to manage. To get started with a developer endpoint or dedicated node, you'll need to contact us: 1. Visit [Dwellir](https://www.dwellir.com/contact){target=_blank} 2. Submit your **email** and your node request ![Dwellir](/images/builders/get-started/endpoints/endpoints-4.webp) ### GetBlock {: #getblock } [GetBlock](https://getblock.io){target=_blank} is a service that provides instant API access to Moonbeam and Moonriver and is available through shared and dedicated nodes. [Dedicated nodes](https://docs.getblock.io/getting-started/plans-and-limits/choosing-your-plan#dedicated-nodes){target=_blank} provide access to a private server with fast speeds and without rate limits. [Shared nodes](https://docs.getblock.io/getting-started/plans-and-limits/choosing-your-plan#shared-nodes){target=_blank} provide a free API/add-on based endpoint for you to get started quickly. To get started with GetBlock, you can go to the [GetBlock registration page](https://account.getblock.io/sign-up){target=_blank} and sign up for a new account. Then, from your account **Dashboard**, you can view and manage your existing endpoints for multiple protocols, and also create new ones. Creating a new API/add-on based endpoint is simple, all you have to do is: 1. Fill the information for the desired protocol from the list of available blockchains 2. Choose the network you want your endpoint to point to (**Mainnet**, **Testnet**, etc) 3. Select **JSON-RPC** from the **API/Add-on** dropdown 4. Click the **Get** button at the far right and you're all set to go! ![GetBlock](/images/builders/get-started/endpoints/endpoints-5.webp) ### Grove {: #grove } [Grove](https://grove.city){target=_blank} is a decentralized RPC network that provides reliable Web3 infrastructure with enterprise-grade performance and security. Grove offers both free and paid tiers, with the free tier providing generous limits for development use, while paid plans offer higher throughput, dedicated support, and advanced features for production applications. Grove's decentralized approach ensures high availability and censorship resistance by distributing requests across multiple node operators. The network supports both JSON-RPC and WebSocket connections for real-time applications. To get started with Grove: 1. Visit the [Grove Portal](https://portal.grove.city/){target=_blank} and sign up for an account 2. From your dashboard, create a new application 3. Copy your Moonbeam or Moonriver endpoints 4. Start making requests to your custom Grove endpoint Grove provides detailed analytics, request monitoring, and flexible rate limiting to help you optimize your application's performance. ![Grove](/images/builders/get-started/endpoints/endpoints-6.webp) ### OnFinality {: #onfinality } [OnFinality](https://onfinality.io){target=_blank} provides a free API key based endpoint for customers in place of a public endpoint. Additionally, OnFinality offers paid tiers of service that offer increased rate limits and higher performance than those offered by the free tier. You also receive more in depth analytics of the usage of your application. To create a custom OnFinality endpoint, go to [OnFinality](https://onfinality.io){target=_blank} and sign up, or if you already have signed up you can go ahead and log in. From the OnFinality **Dashboard**, you can: 1. Click on **API Service** 2. Select the network from the dropdown 3. Your custom API endpoint will be generated automatically ![OnFinality](/images/builders/get-started/endpoints/endpoints-7.webp) ### UnitedBloc {: #unitedbloc } [UnitedBloc](https://medium.com/unitedbloc/unitedbloc-rpc-c84972f69457){target=_blank} is a collective of community collators from both Moonbeam and Moonriver. To provide value for the community, they offer public RPC services for the Moonbeam, Moonriver, and Moonbase Alpha networks. The public endpoint service is served by eight geographically distributed bare metal servers globally balanced via GeoDNS and regionally load balanced with NGINX. As the service is public, there are no sign-up or API keys to manage. The collators involved in this initiative are: - Blockshard (CH) - BloClick (ES) - BrightlyStake (IN) - CertHum (US) - GPValidator (PT) - Hetavalidation (AU) - Legend (AE) - PathrockNetwork (DE) - Polkadotters (CZ) - SIK | crifferent.de (DE) - StakeBaby (GR) - StakeSquid (GE) - TrueStaking (US) They also provide a [public Grafana dashboard](https://monitoring.unitedbloc.com:3030/public-dashboards/7444d2ab76ee45eda181618b0f0ecb98?orgId=1){target=_blank} with some cool metrics. Check the [public endpoints section](#public-endpoints) to get the relevant URL. You can contact them via their [Telegram channel](https://t.me/+tRvy3z5-Kp1mMGMx){target=_blank}, or read more about their initiative on their [blogpost page](https://medium.com/unitedbloc/unitedbloc-rpc-c84972f69457){target=_blank}. ## Lazy Loading with RPC Endpoint Providers {: #lazy-loading-with-RPC-Endpoint-Providers } Lazy loading lets a Moonbeam node operate while downloading network state in the background, eliminating the need to wait for full synchronization before use. To spin up a Moonbeam node with lazy loading, you'll need to either [download the Moonbeam release binary](/node-operators/networks/run-a-node/systemd/#the-release-binary){target=_blank} or [compile the binary](/node-operators/networks/run-a-node/compile-binary/#compile-the-binary){target=_blank}. You can activate lazy loading with the following flag: `--lazy-loading-remote-rpc 'INSERT-RPC-URL'` Lazy loading is highly resource-intensive, requiring many RPC requests to function. To avoid being throttled, it's recommended that you use a [dedicated endpoint](#endpoint-providers) (i.e., an endpoint with an API key) rather than a public endpoint. You will likely be rate-limited if you use lazy loading with a public endpoint. Upon spooling up a node with this feature, you'll see output like the following:
[Lazy loading 🌗]
You are now running the Moonbeam client in lazy loading mode, where data is retrieved
from a live RPC node on demand.
Using remote state from: https://moonbeam.unitedbloc.com
Forking from block: 8482853
To ensure the client works properly, please note the following:
1. *Avoid Throttling*: Ensure that the backing RPC node is not limiting the number of
requests, as this can prevent the lazy loading client from functioning correctly;
2. *Be Patient*: As the client may take approximately 20 times longer than normal to
retrieve and process the necessary data for the requested operation.
The service will start in 10 seconds...
### Overriding State with Lazy Loading By default, you won't see detailed logging in the terminal. To override this setting and show lazy loading logs, you can add the following flag to your command to start the Moonbeam node: `-l debug`. You can further customize your use of the lazy loading functionality with the following optional parameters: - **`--lazy-loading-block`** - specifies a block hash from which to start loading data. If not provided, the latest block will be used - **`--lazy-loading-delay-between-requests`** - the delay (in milliseconds) between RPC requests when using lazy loading. This parameter controls the amount of time to wait between consecutive RPC requests. This can help manage request rate and avoid overwhelming the server. Default value is `100` milliseconds - **`--lazy-loading-max-retries-per-request`** - the maximum number of retries for an RPC request when using lazy loading. Default value is `10` retries - **`--lazy-loading-runtime-override`** - path to a WASM file to override the runtime when forking. If not provided, it will fetch the runtime from the block being forked - **`--lazy-loading-state-overrides`** - path to a JSON file containing state overrides to be applied when forking #### Simple Storage Item Override The state overrides file should define the respective pallet, storage item, and value that you seek to override as follows: ```json [ { "pallet": "System", "storage": "SelectedCandidates", "value": "0x04f24ff3a9cf04c71dbc94d0b566f7a27b94566cac" } ] ``` #### Override an Account's Free Balance To override the balance of a particular account, you can override the account storage item of the system pallet for the respective account as follows: ```json [ { "pallet": "System", "storage": "Account", "key": "TARGET_ADDRESS", "value": "0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080" } ] ``` ??? note "Details about overriding account balances" Overriding an account balance, as shown above, can be a complex process. However, this guide will break it down into steps that are easy to follow. Before making any changes, you should obtain the existing value corresponding to the key (i.e., the account in this case). You can go to [**Chain State** on Polkadot.js Apps](https://polkadot.js.org/apps/?rpc=wss://wss.api.moonbeam.network#/chainstate){target=_blank} and query the System pallet by providing the account you'd like to query. Upon submitting the query, you'll get back a readable account structure like so: ```text { nonce: 3,142 consumers: 2 providers: 1 sufficients: 6 data: { free: 1,278,606,392,142,175,328,676 reserved: 348,052,500,000,000,000,000 frozen: 20,413,910,106,633,175,872 flags: 170,141,183,460,469,231,731,687,303,715,884,105,728 } } ``` While this is useful as a reference, the information you're looking for is the encoded storage key, which is accessible even without submitting the chain state query. In this instance, the encoded storage key corresponding to the system pallet and the selected account `0x3B939FeaD1557C741Ff06492FD0127bd287A421e` is: ```text 0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9b882fedb4f75b055c709ec5b66b5d9933b939fead1557c741ff06492fd0127bd287a421e ``` Note that this encoded storage key will change alongside any input changes, such as a different account being queried. Then, head over the **Raw Storage** tab on [Polkadot.js Apps](https://polkadot.js.org/apps/#/chainstate/raw){target=_blank}. Input the above storage key and submit the query. The response is the SCALE encoded account struct, a part of which contains the free balance information to be modified as part of this example: ```text 0x460c0000020000000100000006000000a4d92a6a4e6b3a5045000000000000000040a556b0e032de12000000000000004083a09e15c74c1b010000000000000000000000000000000000000000000080 ``` There is quite a bit of data encoded in the value field because it is a complex struct comprised of multiple values. The struct is comprised of: ```text struct AccountInfo { nonce: u32, // Transaction count consumers: u32, // Number of consumers providers: u32, // Number of providers sufficients: u32, // Number of sufficients data: AccountData { // The balance info free: u128, // Free balance reserved: u128, // Reserved balance frozen: u128, // Frozen balance flags: u128 // Account flags } } ``` You can associate each part of the SCALE encoded struct with the corresponding piece of Alice's account information that it represents: ```text 0x460c0000 // nonce (u32): 3,142 02000000 // consumers (u32): 2 01000000 // providers (u32): 1 06000000 // sufficients (u32): 6 a4d92a6a4e6b3a5045000000000000000 // free (u128): 1,278,606,392,142,175,328,676 40a556b0e032de1200000000000000000 // reserved (u128): 348,052,500,000,000,000,000 4083a09e15c74c1b01000000000000000 // frozen (u128): 20,413,910,106,633,175,872 00000000000000000000000000000080 // flags (u128): 170,141,183,460,469,231,731,687,303,715,884,105,728 ``` Remember that the values are little endian encoded. To convert the hexadecimal little endian encoded values to decimal, you can use [Substrate Utilities converter](https://www.shawntabrizi.com/substrate-js-utilities/){target=_blank}, using the **Balance to Hex (Little Endian)** converter. In this example, the existing free balance of `1,278,606,392,142,175,328,676` Wei or approximately `1278.60` DEV is `a4d92a6a4e6b3a5045`. The following example will change the value to `500,000` DEV, which is `500,000,000,000,000,000,000,000` Wei or `0x000080d07666e70de169` encoded as a hexadecimal little endian value. When properly padded to fit into the SCALE encoded storage value, it becomes `69e10de76676d08000000000000000000`, such that the table now looks like: ```text 0x460c0000 // nonce (u32): 3,142 02000000 // consumers (u32): 2 01000000 // providers (u32): 1 06000000 // sufficients (u32): 6 69e10de76676d08000000000000000000 // free (u128): 500,000,000,000,000,000,000,000 40a556b0e032de1200000000000000000 // reserved (u128): 348,052,500,000,000,000,000 4083a09e15c74c1b01000000000000000 // frozen (u128): 20,413,910,106,633,175,872 00000000000000000000000000000080 // flags (u128): 170,141,183,460,469,231,731,687,303,715,884,105,728 ``` Therefore, the SCALE encoded override value is as follows: ```text 0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080 ``` You can now specify the SCALE encoded override value in your `state-overrides.json` file as follows: ```json [ { "pallet": "System", "storage": "Account", "key": "0x3b939fead1557c741ff06492fd0127bd287a421e", "value": "0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080" } ] ``` To run lazy loading with the balance state override, you can use the following command: ```bash --lazy-loading-remote-rpc 'INSERT_RPC_URL' --lazy-loading-state-overrides ./state-overrides.json ``` #### Override an ERC-20 Token Balance To override an ERC-20 token balance, identify the storage slot in the EVM’s AccountStorages where the `balanceOf` data for the given token contract and account is stored. This storage slot is determined by the token contract’s H160 address and the corresponding H256 storage key. Once you have this slot, specify the new balance value in the `state-overrides.json` file to implement the override. In the example below, we override the token balance of the [Wormhole USDC Contract (`0x931715FEE2d06333043d11F658C8CE934aC61D0c`)](https://moonscan.io/address/0x931715FEE2d06333043d11F658C8CE934aC61D0c){target=_blank} for the account `0x3b939fead1557c741ff06492fd0127bd287a421e` to $5,000 USDC. Since Wormhole USDC uses 6 decimal places, $5,000 corresponds to `5000000000` in integer form, which is `0x12a05f200` in hexadecimal. ```json [ { "pallet": "EVM", "storage": "AccountStorages", "key": [ "0x931715FEE2d06333043d11F658C8CE934aC61D0c", "0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342" ], "value": "0x000000000000000000000000000000000000000000000000000000012a05f200" } ] ``` You can calculate the exact storage slot to override for your own account with the following script: ```js import { ethers } from 'ethers'; function getBalanceSlot(accountAddress) { // Convert address to bytes32 and normalize const addr = ethers.zeroPadValue(accountAddress, 32); // CAUTION! The storage slot used here is 5, which // is specific to Wormhole contracts // The storage slot index for other tokens may vary const packedData = ethers.concat([ addr, ethers.zeroPadValue(ethers.toBeHex(5), 32), ]); // Calculate keccak256 return ethers.keccak256(packedData); } // Example usage const address = 'INSERT_ADDRESS'; console.log(getBalanceSlot(address)); ``` You can apply the same process for other ERC-20 token contracts. The following sections demonstrate overrides for the `0x3B939FeaD1557C741Ff06492FD0127bd287A421e` account with various ERC-20 tokens. Remember to update the H160 token contract address whenever you switch to a different token. Also, you will need to recalculate the H256 storage slot for each distinct account whose balance you want to override. ??? code "Example: Override Wormhole BTC Token Balance" ```json [ { "pallet": "EVM", "storage": "AccountStorages", "key": [ "0xE57eBd2d67B462E9926e04a8e33f01cD0D64346D", "0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342" ], "value": "0x000000000000000000000000000000000000000000000000000000012a05f200" } ] ``` ??? code "Example: Override Wormhole ETH Token Balance" ```json [ { "pallet": "EVM", "storage": "AccountStorages", "key": [ "0xab3f0245B83feB11d15AAffeFD7AD465a59817eD", "0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342" ], "value": "0x000000000000000000000000000000000000000000000000000000012a05f200" } ] ``` ??? code "Example: Override WELL Token Balance" Because the [WELL token](https://moonbeam.moonscan.io/token/0x511ab53f793683763e5a8829738301368a2411e3){target=_blank} does not use a proxy implementation contract, the storage slot calculation differs. Instead of slot `5`, the balance mapping resides at slot `1`. You can determine the exact storage slot to override the WELL token balance for your own account using the following script: ```js import { ethers } from 'ethers'; function getBalanceSlot(accountAddress) { // Convert address to bytes32 and normalize const addr = ethers.zeroPadValue(accountAddress, 32); // Caution! The storage slot index used here is 1 // The storage slot index for other tokens may vary const packedData = ethers.concat([ addr, ethers.zeroPadValue(ethers.toBeHex(1), 32), ]); // Calculate keccak256 return ethers.keccak256(packedData); } // Example usage const address = 'INSERT_ADDRESS'; console.log(getBalanceSlot(address)); ``` Thus, the storage override would be: ```json [ { "pallet": "EVM", "storage": "AccountStorages", "key": [ "0x511aB53F793683763E5a8829738301368a2411E3", "0x728d3daf4878939a6bb58cbc263f39655bb57ea15db7daa0b306f3bf2c3f1227" ], "value": "0x000000000000000000000000000000000000000000000000000000012a05f200" } ] ``` ## Tracing RPC Endpoint Providers {: #tracing-providers } Tracing RPC endpoints allow you to access non-standard RPC methods, such as those that belong to Geth's `debug` and `txpool` APIs and OpenEthereum's `trace` module. To see a list of the supported non-standard RPC methods on Moonbeam for debugging and tracing, please refer to the [Debug API & Trace Module](/builders/ethereum/json-rpc/debug-trace/){target=_blank} guide. The following providers provide tracing RPC endpoints: - [OnFinality](#onfinality-tracing) ### OnFinality {: #onfinality-tracing } [OnFinality](https://onfinality.io){target=_blank}'s Trace API can be used to quickly get started tracing and debugging transactions on Moonbeam and Moonriver. It is only available to users on their [Growth and Ultimate plans](https://onfinality.io/pricing){target=_blank}. To use the Trace API, you simply call the trace method of your choice from your [private RPC endpoint](#onfinality). For a list of the supported networks and trace methods, please check out [OnFinality's Trace API documentation](https://documentation.onfinality.io/support/trace-api#TraceAPI-SupportedNetworks){target=_blank}. Please note that if you are tracing historic blocks, it is recommended to use your own dedicated trace node to backfill any data, and then once you're caught up, you can switch to using the Trace API. You can check out the [How to Deploy a Trace Node for Moonbeam on OnFinality](https://onfinality.medium.com/how-to-deploy-a-trace-node-for-moonbeam-on-onfinality-85683181d290){target=-_blank} post for more information on how to spin up your own dedicated trace node. --- END CONTENT ---