# 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: Dev Environments ## 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/builders/ethereum/dev-env/ape.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/foundry.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/hardhat.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/openzeppelin/contracts.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/remix.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/scaffold-eth.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/tenderly.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/thirdweb.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/ethereum/dev-env/waffle-mars.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/builders/substrate/dev-env/chopsticks.md [type: builders] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/tutorials/eth-api/foundry-start-to-end.md [type: tutorials] Doc-Page: https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-docs/refs/heads/master/tutorials/eth-api/hardhat-start-to-end.md [type: tutorials] ## Full content for each doc page Doc-Content: https://docs.moonbeam.network/builders/ethereum/dev-env/ape/ --- BEGIN CONTENT --- --- title: Deploy Contracts with Ape description: Use Ape, a Python framework, to compile, deploy, and debug smart contracts using Python on Moonbeam, thanks to its Ethereum compatibility. categories: Dev Environments, Ethereum Toolkit --- # Using Ape to Deploy To Moonbeam ## Introduction {: #introduction } [Ape](https://docs.apeworx.io/ape/stable){target=\_blank} is an Ethereum development environment that helps Python developers manage and automate the recurring tasks inherent to building smart contracts and DApps. Ape can directly interact with Moonbeam's Ethereum API, so you can also use Ape to deploy smart contracts on Moonbeam. This guide will walk you through using Ape to compile, deploy, and interact with Ethereum smart contracts on the Moonbase Alpha TestNet. You can adapt this guide for Moonbeam, Moonriver, or a Moonbeam development node. ## Checking Prerequisites {: #checking-prerequisites } To get started, ensure you have the following: - MetaMask installed and [connected to Moonbase Alpha](/tokens/connect/metamask/){target=\_blank} - An account with funds. 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} - 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} ## Creating an Ape Project {: #creating-an-ape-project } If you don't already have an Ape project, you must install Ape and create a new one. You can follow the steps below to get started and create an empty project: 1. Create a directory for your project ```bash mkdir ape && cd ape ``` 2. If you don't have `pipx` installed, install it ```bash python3 -m pip install --user pipx python3 -m pipx ensurepath ``` 3. [Install Ape using `pipx`](https://ape.readthedocs.io/en/stable/install.html){target=\_blank} ```bash pipx install eth-ape ``` 4. Create a project ```bash ape init ``` 5. Enter a name for your project
ape init Please enter project name: ape-demo
SUCCESS: ape-demo is written in ape-config.yaml
ls ape-config.yaml contracts scripts tests
Your Ape project contains a bare-bones `ape-config.yaml` file for customizing specific settings and the following empty directories: - `contracts` - an empty directory for storing smart contracts - `scripts` - an empty directory for storing Python scripts, such as deployment scripts and scripts to interact with your deployed contracts - `tests` - an empty directory for pytest testing scripts ## Configure Accounts {: #configure-accounts } You'll need to import an account before you can deploy smart contracts or interact with previously deployed contracts from your Ape project. You can run the following command, which will import your account and give it a name: ```bash ape accounts import INSERT_ACCOUNT_NAME ``` You'll then be prompted to enter your private key and add a password to encrypt your account.
ape accounts import alice Enter Private Key: Create Passphrase to encrypt account: Repeat for confirmation: SUCCESS: A new account '0x097D9Eea23DE2D3081169e0225173d0C55768338' has been added with the id 'alice'
!!! note If you wish to use a mnemonic instead, you can append the `--use-mnemonic` option to the import command. ## Create Smart Contracts {: #the-contract-file } Now that you have set up your account, you can start writing smart contracts. As a basic example, you can use the following `Box` contract to store a value you can retrieve later. Start by creating a file named `Box.sol` inside the contracts directory: ```bash touch contracts/Box.sol ``` Open the file and add the following contract to it: ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.1; contract Box { uint256 private value; event ValueChanged(uint256 newValue); function store(uint256 newValue) public { value = newValue; emit ValueChanged(newValue); } function retrieve() public view returns (uint256) { return value; } } ``` You can store any additional contracts in the `contracts` directory. ## Compile the Solidity Contract {: #compiling-solidity } Before compiling the Solidity, you must install the Solidity compiler plugin. Running the following command will install the latest version of the plugin: ```bash ape plugins install solidity ``` To use a specific version of Solidity or a specific EVM version, you can modify your `ape-config.yaml` file as follows: ```yaml solidity: version: INSERT_VERSION evm_version: INSERT_VERSION ``` For more information on the Solidity plugin, please refer to the [README of the `ape-solidity` repository on GitHub](https://github.com/ApeWorX/ape-solidity/blob/main/README.md){target=_blank}. With the Solidity plugin installed, the next step is to compile the smart contract: ```bash ape compile ```
ape compile INFO: Compiling 'Box.sol'. INFO: Compiling using Solidity compiler '0.8.23+commit.f704f362'.
After compilation, you can find the bytecode and ABI for your contracts in the `.build` directory. ## Test the Contract {: #test-the-contract } Before you deploy your contract, you can test it out directly inside your Ape project using the [pytest framework](https://docs.pytest.org/en/latest){target=\_blank} to make sure it works as you expect. You should already have a `tests` directory where you'll create your tests, but if not, please create one, as all tests must be located in a directory named `tests`. Additionally, each test file name must start with `test_` and end with `.py`. So, first, you can create a test file for the `Box.sol` contract: ```bash touch tests/test_box.py ``` In addition to the test file, you can create a `conftest.py` file that will define a couple of essential [fixtures](https://docs.pytest.org/en/stable/explanation/fixtures.html){target=\_blank}. Fixtures allow you to define functions that set up the necessary environment or resources to run your tests. Note that while the `Box.sol` contract is simple, incorporating fixtures into your testing process is good practice. To create the file, you can run the following command: ```bash touch tests/conftest.py ``` Since your tests will rely on the injection of the fixtures, you must define the fixtures first. When defining fixtures, you need to apply the `pytest.fixture` decorator above each function. For this example, you'll create two fixtures: one that defines the owner of the contract and one that deploys the contract from the owner's account. The `owner` fixture will use the built-in `accounts` fixture to take the first account in the list of test accounts provided by Ape and return it. The `box` fixture will deploy the `Box` contract type using the built-in `project` fixture, you simply have to provide the name of the contract and use the `owner` fixture to deploy it. ```python title="tests/conftest.py" import pytest @pytest.fixture def owner(accounts): return accounts[0] @pytest.fixture def box(owner, project): return owner.deploy(project.Box) ``` Now that you've created the fixtures, you can start creating your tests. Each test function name must start with `test_` and describe what the test does. For this example, you can use `test_store_value`, as you'll create a test for the `store` function. The test will store a value and then retrieve it, asserting that the retrieved value is equal to the value passed into the `store` function. To use the `owner` and `box` fixtures, you must pass them into your test function, which will inject the fixtures automatically for you to use. The `owner` account will be used to call the `store` function of the `box` contract instance. ```py title="tests/test_box.py" def test_store_value(box, owner): new_value = 5 box.store(new_value, sender=owner) assert box.retrieve() == new_value ``` And that's it! That's all you'll need inside your test file. You can use the following command to run the test: ```bash ape test ``` The results of running the test will be printed to the terminal.
ape test ===================== test session starts ====================== platform darwin -- Python 3.10.4, pytest-7.2.1, pluggy-1.4.0 rootdir: /Users/moonbeam/ape plugins: eth-ape-0.7.7, web3-6.15.1 collected 1 item
tests/test_box.py . [100%]
====================== 1 passed in 0.70s =======================
Now that you have confidence in your contract, the next step is to deploy it. ## Deploy the Contract {: #deploy-the-contract } To deploy your contracts, create a deployment script named `deploy.py` inside of the `scripts` directory: ```bash touch scripts/deploy.py ``` Next, you'll need to write the deployment script. You'll need to load the account you will use to deploy the contract and access it by its name using the project manager. ```python title="scripts/deploy.py" from ape import project, accounts def main(): # Load your account by its name account = accounts.load("alice") # Deploy the contract using your account return account.deploy(project.Box) ``` Now you're ready to deploy the `Box` contract! To configure your project for 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}. Take the following steps to initiate and send the deployment transaction. Note that there are some nuances associated with [using Ape with a local Moonbeam node](#using-ape-with-a-local-node). 1. Run the deployment script using the `ape run deploy` command === "Moonbeam" ```bash ape run deploy --network moonbeam:mainnet ``` === "Moonriver" ```bash ape run deploy --network moonbeam:moonriver ``` === "Moonbase Alpha" ```bash ape run deploy --network moonbeam:moonbase ``` === "Moonbeam Dev Node" ```bash ape run deploy --network ethereum:local_moonbeam:http://127.0.0.1:9944 ``` !!! note For the `ape run deploy` command to work as intended, the deployment script must be named `deploy.py` and stored in the `scripts` directory, and the script must define a `main()` method. 2. Review the transaction details and enter **y** to sign the transaction 3. Enter your passphrase for your account 4. Enter **y** to leave your account unlocked or **n** to lock it After you follow the prompts and submit the transaction, the transaction hash, total fees paid, and contract address will be displayed in the terminal.
ape run deploy --network https://rpc.api.moonbase.moonbeam.network INFO: Connecting to a 'moonbase' node.
DynamicFeeTransaction: chainId: 1287 from: 0x097D9Eea23DE2D3081169e0225173d0C55768338 gas: 123964 nonce: 372 value: 0 data: 0x307836...303333 type: 2 maxFeePerGas: 125000000 maxPriorityFeePerGas: 0 accessList: []
Sign: [y/N]: y Enter passphrase to unlock 'alice' []: Leave 'alice' unlocked? [y/N]: n INFO: Confirmed 0x365cd903e7fac5ad1f815d7a6f211b1aa32bd7d78630c2e81d67514cfb9e55bb (total fees paid = 15326250000000) SUCCESS: Contract 'Box' deployed to: 0x68039277300E8B104dDf848029dCA04C2EFe8610
Congratulations! Your contract is live! Save the address to interact with your contract in the following section. ## Interact with the Contract {: #interact-with-the-contract } You can interact with contracts using the Ape console for quick debugging and testing, or write a script. ### Using The Ape Console {: #using-ape-console } To interact with your newly deployed contract, you can launch the Ape console by running: === "Moonbeam" ```bash ape console --network moonbeam:mainnet ``` === "Moonriver" ```bash ape console --network moonbeam:moonriver ``` === "Moonbase Alpha" ```bash ape console --network moonbeam:moonbase ``` === "Moonbeam Dev Node" ```bash ape console --network ethereum:local_moonbeam:http://127.0.0.1:9944 ``` Next, you'll need to create a contract instance using the contract's address: ```bash box = Contract("INSERT_CONTRACT_ADDRESS") ```
ape console --network https://rpc.api.moonbase.moonbeam.network INFO: Connecting to a 'moonbase' node.
alice = accounts.load("alice") box = Contract("0x68039277300E8B104dDf848029dCA04C2EFe8610")
Now, you can interact with your contract instance! For example, you can set the variable to be stored in the `Box` contract using the following commands: 1. Call the `store` method by passing in a value to store and the account you want to use to send the transaction: ```bash box.store(5, sender=alice) ``` 2. Review the transaction details and enter **y** to sign the transaction 3. If you previously locked your account, you must enter your passphrase to unlock it. Otherwise, Ape will use the cached key for your account 4. If you unlocked your account in the previous step, you'll be asked if you want to leave your account unlocked. You can enter **y** to leave it unlocked or **n** to lock it After you follow the prompts and submit the transaction, the transaction hash and total fees paid will be displayed in the terminal.
box.store(4, sender=alice) DynamicFeeTransaction: chainId: 1287 to: 0x68039277300E8B104dDf848029dCA04C2EFe8610 from: 0x097D9Eea23DE2D3081169e0225173d0C55768338 gas: 45668 nonce: 373 value: 0 data: 0x307836...303034 type: 2 maxFeePerGas: 125000000 maxPriorityFeePerGas: 0 accessList: []
Sign: [y/N]: y Enter passphrase to unlock 'alice' []: Leave 'alice' unlocked? [y/N]: n INFO: Confirmed 0xd2e8305f22f33c1ab8ccaaef94252a93ff0f69c9bf98503fc2744bf257f1ef67 (total fees paid = 5573750000000) Receipt 0xd2e8305f22f33c1ab8ccaaef94252a93ff0f69c9bf98503fc2744bf257f1ef67
Then, you can retrieve the stored value by calling the `retrieve` method: ```bash box.retrieve() ``` The number you just stored in the previous steps will be printed to the console.
contract.retrieve() 5
### Using a Script {: #using-a-script } You can also write a script to interact with your newly deployed contract. To get started, you can create a new file in the `scripts` directory: ```bash touch scripts/store-and-retrieve.py ``` Next, you can write a script that stores and retrieves a value. Note that when creating a contract instance to interact with, you must pass in the address of the deployed contract. ```python title="scripts/store-and-retrieve.py" from ape import Contract, accounts def main(): account = accounts.load("alice") box = Contract("INSERT_CONTRACT_ADDRESS") store = box.store(4, sender=account) print("Transaction hash for updating the stored value:", store.txn_hash) retrieve = box.retrieve() print("Stored value:", retrieve) ``` Now, you can run the script to set the stored value and retrieve it: 1. Run the script === "Moonbeam" ```bash ape run store-and-retrieve --network moonbeam:mainnet ``` === "Moonriver" ```bash ape run store-and-retrieve --network moonbeam:moonriver ``` === "Moonbase Alpha" ```bash ape run store-and-retrieve --network moonbeam:moonbase ``` === "Moonbeam Dev Node" ```bash ape run store-and-retrieve --network ethereum:local_moonbeam:http://127.0.0.1:9944 ``` 2. Review the transaction details and enter **y** to sign the transaction 3. If you previously locked your account, you must enter your passphrase to unlock it. Otherwise, Ape will use the cached key for your account 4. If you unlocked your account in the previous step, you'll be asked if you want to leave your account unlocked. You can enter **y** to leave it unlocked or **n** to lock it Once completed, you should see a transaction hash and a value of `5` printed to the console.
ape run store-and-retrieve --network https://rpc.api.moonbase.moonbeam.network DynamicFeeTransaction: chainId: 1287 to: 0x68039277300E8B104dDf848029dCA04C2EFe8610 from: 0x097D9Eea23DE2D3081169e0225173d0C55768338 gas: 25974 nonce: 374 value: 0 data: 0x307836...303035 type: 2 maxFeePerGas: 125000000 maxPriorityFeePerGas: 0 accessList: []
Sign: [y/N]: y Enter passphrase to unlock 'alice' []: Leave 'alice' unlocked? [y/N]: n INFO: Confirmed 0x6d74e48c23fd48438bf48baad34e235693c737bd880ef0077c0fb996f3896f5f (total fees paid = 3086250000000) Transaction hash for updating the stored value: 0x6d74e48c23fd48438bf48baad34e235693c737bd880ef0077c0fb996f3896f5f Stored value: 5
Congratulations! You have successfully deployed and interacted with a contract using Ape! ## Using Ape with a Local Node {: #using-ape-with-a-local-node } There are some nuances associated with using Ape with a local Moonbeam node. As a Moonbeam local node is not included as a preset network with Ape, you'll need to customize your `ape-config.yaml` before using Ape with a local Moonbeam node. Adjust your `ape-config.yaml` as follows: ```bash # ape-config.yaml name: ape-demo default_ecosystem: ethereum ethereum: default_network: local_moonbeam local_moonbeam: default_transaction_type: 0 gas_limit: "auto" block_time: 6 transaction_acceptance_timeout: 60 max_receipt_retries: 10 networks: custom: - name: local_moonbeam chain_id: 1281 ecosystem: ethereum base_ecosystem_plugin: ethereum default_provider: node node: ethereum: local_moonbeam: uri: http://127.0.0.1:9944 ``` After configuring your `ape-config.yaml`, you can target your local Moonbeam node by appending the following network configuration flag to your Ape command: ```bash --network ethereum:local_moonbeam:http://127.0.0.1:9944 ``` Additionally, when deploying or interacting with contracts on a local Moonbeam node using Ape, the CLI will, by default, wait for two block confirmations before allowing you to proceed. However, because a local Moonbeam node employs instant sealing, only producing blocks when new transactions occur, this can lead to a stalemate situation that may lead you to think something is wrong. To circumvent this, you can run your local Moonbeam node with a sealing flag to produce blocks at a set interval, such as every `6` seconds, with the command: `--sealing 6000`. Alternatively, you can submit dummy transactions to your local Moonbeam node to force new blocks to be authored.
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/dev-env/foundry/ --- BEGIN CONTENT --- --- title: Deploy Contracts with Foundry description: Learn how to use Foundry, an Ethereum development environment, to compile, deploy, and debug Solidity smart contracts on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using Foundry to Deploy To Moonbeam ## Introduction {: #introduction } [Foundry](https://github.com/foundry-rs/foundry){target=\_blank} is an Ethereum development environment written in Rust that helps developers manage dependencies, compile projects, run tests, deploy contracts, and interact with blockchains from the command line. Foundry can directly interact with Moonbeam's Ethereum API so it can be used to deploy smart contracts into Moonbeam. Four tools make up Foundry: - **[Forge](https://getfoundry.sh/forge/overview/){target=\_blank}** - compiles, tests, and deploys contracts - **[Cast](https://getfoundry.sh/cast/overview/){target=\_blank}** - a command line interface for interacting with contracts - **[Anvil](https://getfoundry.sh/anvil/overview/){target=\_blank}** - a local TestNet node for development purposes that can fork preexisting networks - **[Chisel](https://getfoundry.sh/chisel/overview/){target=\_blank}** - a Solidity REPL for quickly testing Solidity snippets This guide will cover how to use Foundry to compile, deploy, and debug Ethereum smart contracts on the Moonbase Alpha TestNet. This guide can also be adapted for Moonbeam, Moonriver, or a Moonbeam development node. ## Checking Prerequisites {: #checking-prerequisites } To get started, you will need the following: - Have an account with funds. 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} - 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} - Have [Foundry installed](https://getfoundry.sh/introduction/installation/){target=\_blank} ## Creating a Foundry Project {: #creating-a-foundry-project } You will need to create a Foundry project if you don't already have one. You can create one by completing the following steps: 1. Install Foundry if you haven't already. If on Linux or MacOS, you can run these commands: ```bash curl -L https://foundry.paradigm.xyz | bash foundryup ``` If on Windows, you'll have to install Rust and then build Foundry from source: ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil --bins --locked ``` 2. Create the project, which will create a folder with three folders within it, and open it: ```bash forge init foundry && cd foundry ``` With the default project created, you should see three folders. - `lib` - all of the project's dependencies in the form of git submodules - `src` - where to put your smart contracts (with functionality) - `test` - where to put the forge tests for your project, which are written in Solidity In addition to these three folders, a git project will also be created along with a prewritten `.gitignore` file with relevant file types and folders ignored. ## The Source Folder {: #the-src-folder } The `src` folder may already contain `Counter.sol`, a minimal Solidity contract. Feel free to delete it. To avoid errors, you should also delete the `Counter.s.sol` file in the `scripts` folder and the `Counter.t.sol` file in the `test` folder. In the following steps, you will be deploying an ERC-20 contract. In the contracts directory, you can create the `MyToken.sol` file: ```bash cd src touch MyToken.sol ``` Open the file and add the following contract to it: ```solidity pragma solidity ^0.8.0; // Import OpenZeppelin Contract import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // This ERC-20 contract mints the specified amount of tokens to the contract creator contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") { _mint(msg.sender, initialSupply); } } ``` Before you attempt to compile, install OpenZeppelin contracts as a dependency. You may have to commit previous changes to git beforehand. By default, Foundry uses git submodules instead of npm packages, so the traditional npm import path and command are not used. Instead, use the name of OpenZeppelin's GitHub repository: ```bash forge install OpenZeppelin/openzeppelin-contracts ``` ## Compiling Solidity {: #compiling-solidity } Once all dependencies have been installed, you can compile the contract: ```bash forge build ```
forge build [⠒] Compiling... [⠰] Compiling 30 files with 0.8.23 [⠔] Solc 0.8.23 finished in 2.29s Compiler run successful!
After compilation, two folders will be created: `out` and `cache`. The ABI and bytecode for your contracts will be contained within the `out` folder. These two folders are already ignored by the `.gitignore` included in the default Foundry project initialization. ## Deploying the Contract {: #deploying-the-contract } There are two primary ways to deploy contracts using Foundry. The first is the straightforward command `forge create`. There's also the more flexible and powerful option of foundry scripting, which runs simulations before any deployments. In the following sections, `forge create` and foundry scripting will both be covered. ### Using Forge Create {: #using-forge-create } Before deploying, you'll need to set up your keystore by importing your private key. You can do this using the `cast wallet import` command as follows: ```bash cast wallet import deployer --interactive ``` This will prompt you to: 1. Enter your private key 2. Enter a password to encrypt the keystore The account will be saved as "deployer" in your keystore. You can then use this account name in the deployment commands. You'll be prompted for your keystore password when deploying contracts or sending transactions. Deploying the contract with `forge create` takes a single command, but you must include an RPC endpoint and constructor arguments. `MyToken.sol` asks for an initial supply of tokens in its constructor, so each of the following commands includes 100 as a constructor argument. You can deploy the `MyToken.sol` contract using the following command for the correct network: === "Moonbeam" ```bash forge create src/MyToken.sol:MyToken \ --rpc-url {{ networks.moonbeam.rpc_url }} \ --account deployer \ --constructor-args 100 ``` === "Moonriver" ```bash forge create src/MyToken.sol:MyToken \ --rpc-url {{ networks.moonriver.rpc_url }} \ --account deployer \ --constructor-args 100 ``` === "Moonbase Alpha" ```bash forge create src/MyToken.sol:MyToken \ --rpc-url {{ networks.moonbase.rpc_url }} \ --account deployer \ --constructor-args 100 ``` === "Moonbeam Dev Node" ```bash forge create src/MyToken.sol:MyToken \ --rpc-url {{ networks.development.rpc_url }} \ --account deployer \ --constructor-args 100 ``` After you've deployed the contract and a few seconds have passed, you should see the address in the terminal.
forge create src/MyToken.sol:MyToken \ --rpc-url https://rpc.api.moonbase.moonbeam.network \ --account deployer \ --constructor-args 100
[⠒] Compiling... No files changed, compilation skipped Deployer: 0x3B939FeaD1557C741Ff06492FD0127bd287A421e Deployed to: 0xc111402Aa1136ff6224106709ae51864512eC68f Transaction hash: 0xd77fc26aa296e81f35718b5878cda98e8371f6bf33b0f57e7d92997a36cf6465
Congratulations! Your contract is live! Save the address, as you will use it to interact with this contract instance in the next step. ### Deploying via Solidity Scripting {: #deploying-via-solidity-scripting } Solidity scripting is a more powerful and flexible way to deploy contracts than [`forge create`](#deploying-the-contract). Writing a Solidity script is identical to writing a typical Solidity smart contract, though you won't ever deploy this contract. You can tailor the behavior of `forge script` with various parameters. All components are optional except for local simulation, which is a required part of every run. The `forge script` command will attempt to execute all applicable steps in the following order: 1. **Local simulation** - simulate the transaction(s) in a local EVM 2. **Onchain simulation** - simulate the transaction(s) via the provided RPC URL 3. **Broadcasting** - when the `--broadcast` flag is provided, and simulations succeed, the transaction(s) are dispatched 4. **Verification** - API-based smart contract verification when the `--verify` flag and a valid API key are provided Now, go ahead and write the script. In the script folder, create a file named `MyToken.s.sol`. Copy and paste the contents of the below file. ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; import "forge-std/Script.sol"; import "../src/MyToken.sol"; contract MyScript is Script { function run() external { vm.startBroadcast(); MyToken mytoken = new MyToken(1000000000); vm.stopBroadcast(); } } ``` Notice that even though the above script is not being deployed, it still requires all the typical formatting for a Solidity contract, such as the pragma statement. For this example, Foundry will first attempt a local simulation and a simulation against the provided RPC before deploying the contract. Remember that it will execute all relevant steps in order. Foundry won't proceed with the deployment if any of the simulations fail. You can deploy the `MyToken.sol` contract with this command. ```bash forge script script/MyToken.s.sol --rpc-url {{ networks.moonbase.rpc_url }} --broadcast --account deployer ``` If your script's execution succeeds, your terminal should resemble the output below.
forge script script/MyToken.s.sol --rpc-url https://rpc.api.moonbase.moonbeam.network --broadcast --account deployer --sender 0x3b939fead1557c741ff06492fd0127bd287a421e [⠒] Compiling... No files changed, compilation skipped EIP-3855 is not supported in one or more of the RPCs used. Unsupported Chain IDs: 1287. Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly. For more information, please see https://eips.ethereum.org/EIPS/eip-3855 Script ran successfully. ## Setting up 1 EVM. ==========================
Chain 1287 Estimated gas price: 0.0625 gwei Estimated total gas used for script: 1196500 Estimated amount required: 0.00007478125 ETH ==========================
Enter keystore password: ## Sending transactions [0 - 0]. ⠁ [00:00:00] [########################################################################################################] 1/1 txes (0.0s)## Waiting for receipts. ⠉ [00:00:07] [#########################################################################################################################] 1/1 receipts (0.0s) ##### moonbase
✅ [Success]Hash: 0xb70942942d731486872e7faba8a800e86809f44c2c3bd3f6306373562712e9d3 Contract Address: 0x98c3fC51d3487c1689e39ee63Ba110cfD8e1F552 Block: 11847291 Paid: 0.000027472875 ETH (879132 gas * 0.03125 gwei) ========================== ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. Total Paid: 0.000027472875 ETH (879132 gas * avg 0.03125 gwei) Transactions saved to: /Users/ubuntu-jammy/foundry/foundry/broadcast/MyToken.s.sol/1287/run-latest.json Sensitive values saved to: /Users/ubuntu-jammy/foundry/foundry/cache/MyToken.s.sol/1287/run-latest.json
And that's it! For more information about Solidity scripting with Foundry, be sure to check out [Foundry's documentation site](https://getfoundry.sh/guides/scripting-with-solidity/){target=\_blank}. ## Interacting with the Contract {: #interacting-with-the-contract } Foundry includes cast, a CLI for performing Ethereum RPC calls. Try to retrieve your token's name using Cast, where `INSERT_YOUR_CONTRACT_ADDRESS` is the address of the contract that you deployed in the previous section: === "Moonbeam" ```bash cast call INSERT_YOUR_CONTRACT_ADDRESS "name()" --rpc-url {{ networks.moonbeam.rpc_url }} ``` === "Moonriver" ```bash cast call INSERT_YOUR_CONTRACT_ADDRESS "name()" --rpc-url {{ networks.moonriver.rpc_url }} ``` === "Moonbase Alpha" ```bash cast call INSERT_YOUR_CONTRACT_ADDRESS "name()" --rpc-url {{ networks.moonbase.rpc_url }} ``` === "Moonbeam Dev Node" ```bash cast call INSERT_YOUR_CONTRACT_ADDRESS "name()" --rpc-url {{ networks.development.rpc_url }} ``` You should get this data in hexadecimal format: ```text 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000074d79546f6b656e00000000000000000000000000000000000000000000000000 ``` This is far from readable, but you can use Cast to convert it into your desired format. In this case, the data is text, so you can convert it into ASCII characters to see "My Token":
cast --to-ascii 0x000000000000000000000000000000000000000000000000000000000000002000 000000000000000000000000000000000000000000000000000000000000074d7954 6f6b656e00000000000000000000000000000000000000000000000000
MyToken
```bash cast --to-ascii 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000074d79546f6b656e00000000000000000000000000000000000000000000000000 ``` You can also mutate data with cast as well. Try burning tokens by sending them to the zero address. === "Moonbeam" ```bash cast send --private-key INSERT_YOUR_PRIVATE_KEY \ --rpc-url {{ networks.moonbeam.rpc_url }} \ --chain {{ networks.moonbeam.chain_id }} \ INSERT_YOUR_CONTRACT_ADDRESS \ "transfer(address,uint256)" 0x0000000000000000000000000000000000000001 1 ``` === "Moonriver" ```bash cast send --private-key INSERT_YOUR_PRIVATE_KEY \ --rpc-url {{ networks.moonriver.rpc_url }} \ --chain {{ networks.moonriver.chain_id }} \ INSERT_YOUR_CONTRACT_ADDRESS \ "transfer(address,uint256)" 0x0000000000000000000000000000000000000001 1 ``` === "Moonbase Alpha" ```bash cast send --private-key INSERT_YOUR_PRIVATE_KEY \ --rpc-url {{ networks.moonbase.rpc_url }} \ --chain {{ networks.moonbase.chain_id }} \ INSERT_YOUR_CONTRACT_ADDRESS \ "transfer(address,uint256)" 0x0000000000000000000000000000000000000001 1 ``` === "Moonbeam Dev Node" ```bash cast send --private-key INSERT_YOUR_PRIVATE_KEY \ --rpc-url {{ networks.development.rpc_url }} \ --chain {{ networks.development.chain_id }} \ INSERT_YOUR_CONTRACT_ADDRESS \ "transfer(address,uint256)" 0x0000000000000000000000000000000000000001 1 ``` The transaction will be signed by your Moonbase account and be broadcast to the network. The output should look similar to:
cast send --private-key INSERT_PRIVATE_KEY \ --rpc-url https://rpc.api.moonbase.moonbeam.network \ --chain 1287 \ INSERT_CONTRACT_ADDRESS \ "transfer(address,uint256)" 0x0000000000000000000000000000000000000001 1

blockHash 0x6f99fac1bb49feccb7b0476e0ffcd3cef4c456aa9111e193ce11c7a1ab62314e blockNumber 5892860 contractAddress cumulativeGasUsed 51332 effectiveGasPrice 3125000000 gasUsed 51332 logs [{"address":"0xc111402aa1136ff6224106709ae51864512ec68f","topics":["0xddf252ad1be2c89b69 c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x0000000000000000000000003b939fead155 7c741ff06492fd0127bd287a421e", "0x0000000000000000000000000000000000000000000000000000000000000001"], "data":"0x0000000000000000000000000000000000000 000000000000000000000000001", "blockHash":"0x6f99fac1bb49feccb7b0476e0ffcd3cef4c4 56aa9111e193ce11c7a1ab62314e", "blockNumber":"0x59eafc", "transactionHash":"0xdd5f11be68d5 2967356ccf34b9a4b2632d0d5ac8932ff27e72c544320dec33e3", "transactionIndex":"0x0","logIndex":"0x0","transactionLogIndex":"0x0","removed":false}] logsBloom 0x000000000000000000000000000000000000000000000000000000000000000000000000000000004 00000000000000000000000000000000000000000040000000000000000000000000008000000000000 00000004000000000000000000000000000000000000000100000000000000000000000000000000001 00000010000000000000000000000000000000000000000000000000000000002000000040000000000 00000000000000000000000000000000000000000000000000000000002000000000000000000000000 00000000000000000000000000004000000000000000000000000000000000000000000000000000000 0001000000 root status 1 transactionHash 0xdd5f11be68d52967356ccf34b9a4b2632d0d5ac8932ff27e72c544320dec33e3 transactionIndex 0 type 2
Congratulations, you have successfully deployed and interacted with a contract using Foundry! ## Forking with Anvil {: #forking-with-cast-anvil } As previously mentioned, [Anvil](https://getfoundry.sh/anvil/overview/#anvil){target=\_blank} is a local TestNet node for development purposes that can fork preexisting networks. Forking Moonbeam allows you to interact with live contracts deployed on the network. There are some limitations to be aware of when forking with Anvil. Since Anvil is based on an EVM implementation, you cannot interact with any of the Moonbeam precompiled contracts and their functions. Precompiles are a part of the Substrate implementation and therefore cannot be replicated in the simulated EVM environment. This prohibits you from interacting with cross-chain assets on Moonbeam and Substrate-based functionality such as staking and governance. To fork 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}. To fork Moonbeam from the command line, you can run the following command from within your Foundry project directory: === "Moonbeam" ```bash anvil --fork-url {{ networks.moonbeam.rpc_url }} ``` === "Moonriver" ```bash anvil --fork-url {{ networks.moonriver.rpc_url }} ``` === "Moonbase Alpha" ```bash anvil --fork-url {{ networks.moonbase.rpc_url }} ``` Your forked instance will have 10 development accounts that are pre-funded with 10,000 test tokens. The forked instance is available at `http://127.0.0.1:8545/`. The output in your terminal should resemble the following:
anvil --fork-url https://rpc.api.moonbase.moonbeam.network

Available Accounts ================== (0) "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" (10000.000000000000000000 ETH) (1) "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" (10000.000000000000000000 ETH) (2) "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" (10000.000000000000000000 ETH) (3) "0x90F79bf6EB2c4f870365E785982E1f101E93b906" (10000.000000000000000000 ETH) (4) "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65" (10000.000000000000000000 ETH) (5) "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc" (10000.000000000000000000 ETH) (6) "0x976EA74026E726554dB657fA54763abd0C3a0aa9" (10000.000000000000000000 ETH) (7) "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955" (10000.000000000000000000 ETH) (8) "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" (10000.000000000000000000 ETH) (9) "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720" (10000.000000000000000000 ETH)
Private Keys ================== (0) 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 (1) 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d (2) 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a (3) 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 (4) 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a (5) 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba (6) 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e (7) 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 (8) 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 (9) 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
Wallet ================== Mnemonic: test test test test test test test test test test test junk Derivation path: m/44'/60'/0'/0/
Fork ================== Endpoint: https://rpc.api.moonbase.moonbeam.network Block number: 5892944 Block hash: 0xc9579299f55d507c305d5357d4c1b9d9c550788ddb471b0231d8d0146e7144b7 Chain ID: 1287
Base Fee ================== 125000000
Gas Limit ================== 30000000
Genesis Timestamp ================== 1705278817
Listening on 127.0.0.1:8545
To verify you have forked the network, you can query the latest block number: ```bash curl --data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 ``` If you convert the `result` from [hex to decimal](https://www.rapidtables.com/convert/number/hex-to-decimal.html){target=\_blank}, you should get the latest block number from the time you forked the network. You can cross reference the block number using a [block explorer](/builders/get-started/explorers/){target=\_blank}. From here you can deploy new contracts to your forked instance of Moonbeam or interact with contracts already deployed. Building off of the previous example in this guide, you can make a call using Cast to check the balance of the minted MYTOK tokens in the account you deployed the contract with: ```bash cast call INSERT_CONTRACT_ADDRESS "balanceOf(address)(uint256)" INSERT_YOUR_ADDRESS --rpc-url http://localhost:8545 ``` ## Using Chisel {: #using-chisel } Chisel is a Solidity REPL or shell. It allows a developer to write Solidity directly in the console for testing small snippets of code, letting developers skip the project setup and contract deployment steps for what should be a quick process. Since Chisel is mainly useful for quick testing, it can be used outside of a Foundry project. But, if executed within a Foundry project, it will keep the configurations within `foundry.toml` when running. For this example, you will be testing out some of the features of `abi` within Solidity because it is complex enough to demonstrate how Chisel could be useful. To get started using Chisel, run the following in the command line to start the shell: ```bash chisel ``` In the shell, you can write Solidity code as if it were running within a function: ```solidity bytes memory myData = abi.encode(100, true, "Develop on Moonbeam"); ``` Let's say you were interested in how `abi` encoded data because you're looking into how to most efficiently store data on the blockchain and thus save gas. To view how the `myData` is stored in memory, you can use the following command while in the Chisel shell: ```bash !memdump ``` `memdump` will dump all of the data in your current session. You'll likely see something like this below. If you aren't good at reading hexadecimal or if you don't know how ABI encoding works, then you might not be able to find where the `myData` variable has been stored.
chisel
Welcome to Chisel! Type `!help` to show available commands. bytes memory myData = abi.encode(100, true, "Develop on Moonbeam");
!memdump [0x00:0x20]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x20:0x40]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x40:0x60]: 0x0000000000000000000000000000000000000000000000000000000000000140 [0x60:0x80]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x80:0xa0]: 0x00000000000000000000000000000000000000000000000000000000000000a0 [0xa0:0xc0]: 0x0000000000000000000000000000000000000000000000000000000000000064 [0xc0:0xe0]: 0x0000000000000000000000000000000000000000000000000000000000000001 [0xe0:0x100]: 0x0000000000000000000000000000000000000000000000000000000000000060 [0x100:0x120]: 0x0000000000000000000000000000000000000000000000000000000000000013 [0x120:0x140]: 0x446576656c6f70206f6e204d6f6f6e6265616d00000000000000000000000000
Fortunately, Chisel lets you easily figure out where this information is stored. Using the `!rawstack` command, you can find the location in the stack where the value of a variable: ```bash !rawstack myData ``` In this situation, since bytes is over 32 bytes in length, the memory pointer is displayed instead. But that's exactly what's needed since you already know the entirety of the stack from the `!memdump` command.
chisel
Welcome to Chisel! Type `!help` to show available commands. bytes memory myData = abi.encode(100, true, "Develop on Moonbeam");
!memdump [0x00:0x20]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x20:0x40]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x40:0x60]: 0x0000000000000000000000000000000000000000000000000000000000000140 [0x60:0x80]: 0x0000000000000000000000000000000000000000000000000000000000000000 [0x80:0xa0]: 0x00000000000000000000000000000000000000000000000000000000000000a0 [0xa0:0xc0]: 0x0000000000000000000000000000000000000000000000000000000000000064 [0xc0:0xe0]: 0x0000000000000000000000000000000000000000000000000000000000000001 [0xe0:0x100]: 0x0000000000000000000000000000000000000000000000000000000000000060 [0x100:0x120]: 0x0000000000000000000000000000000000000000000000000000000000000013 [0x120:0x140]: 0x446576656c6f70206f6e204d6f6f6e6265616d00000000000000000000000000 !rawstack myData
Type: bytes32 └ Data: 0x0000000000000000000000000000000000000000000000000000000000000080
The `!rawstack` command shows that the `myData` variable is stored at `0x80`, so when comparing this with the memory dump retrieved from the `!memdump` command, it looks like `myData` is stored like this: ```text [0x80:0xa0]: 0x00000000000000000000000000000000000000000000000000000000000000a0 [0xa0:0xc0]: 0x0000000000000000000000000000000000000000000000000000000000000064 [0xc0:0xe0]: 0x0000000000000000000000000000000000000000000000000000000000000001 [0xe0:0x100]: 0x0000000000000000000000000000000000000000000000000000000000000060 [0x100:0x120]: 0x0000000000000000000000000000000000000000000000000000000000000013 [0x120:0x140]: 0x446576656c6f70206f6e204d6f6f6e6265616d00000000000000000000000000 ``` At first glance, this makes sense, since `0xa0` has a value of `0x64` which is equal to 100, and `0xc0` has a value of `0x01` which is equal to true. If you want to learn more about how ABI-encoding works, the [Solidity documentation for ABI is helpful](https://docs.soliditylang.org/en/v0.8.18/abi-spec.html){target=\_blank}. In this case, there are a lot of zeros in this method of data packing, so as a smart contract developer you might instead try to use structs or pack the data together more efficiently with bitwise code. Since you're done with this code, you can clear the state of Chisel so that it doesn't mess with any future logic that you want to try out (while running the same instance of Chisel): ```bash !clear ``` There's an even easier way to test with Chisel. When writing code that ends with a semicolon (`;`), Chisel will run it as a statement, storing its value in Chisel's runtime state. But if you only needed to see how the ABI-encoded data was represented, then you could get away with running the code as an expression. To try this out with the same `abi` example, write the following in the Chisel shell: ```bash abi.encode(100, true, "Develop on Moonbeam") ``` You should see something like the following:
!clear Cleared session! abi.encode(100, true, "Develop on Moonbeam") Type: dynamic bytes ├ Hex (Memory): ├─ Length ([0x00:0x20]): 0x00000000000000000000000000000000000000000000000000000000000000a0 ├─ Contents ([0x20:..]): 0x0000000000000000000000000000000000000000000000000000000000000064 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000060 0000000000000000000000000000000000000000000000000000000000000001 34446576656c6f70206f6e204d6f6f6e6265616d00000000000000000000000000 ├ Hex (Tuple Encoded): ├─ Pointer ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000020 ├─ Length ([0x20:0x40]): 0x00000000000000000000000000000000000000000000000000000000000000a0 └─ Contents ([0x40:..]): 0x0000000000000000000000000000000000000000000000000000000000000064 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000060 0000000000000000000000000000000000000000000000000000000000000001 34446576656c6f70206f6e204d6f6f6e6265616d00000000000000000000000000
While it doesn't display the data in the same way, you still get the contents of the data, and it also further breaks down how the information is coded, such as letting you know that the `0xa0` value defines the length of the data. By default, when you leave the Chisel shell, none of the data is persisted. But you can instruct chisel to do so. For example, you can take the following steps to store a variable: 1. Store a `uint256` in Chisel ```bash uint256 myNumber = 101; ``` 2. Store the session with `!save`. For this example, you can use the number `1` as a save ID ```bash !save 1 ``` 3. Quit the session ```bash !quit ``` Then to view and interact with your stored Chisel states, you can take the following steps: 1. View a list of saved Chisel states ```bash chisel list ``` 2. Load your stored states ```bash chisel load 1 ``` 3. View the `uint256` saved in Chisel from the previous set of steps ```bash !rawstack myNumber ```
uint256 myNumber = 101; !save 1 Saved session to cache with ID = 1 !quit chisel list ⚒️ Chisel Sessions ├─ "2024-01-15 01:17:34" - chisel-1.json chisel load 1 Welcome to Chisel! Type `!help` to show available commands. !rawstack myNumber Type: bytes32 └ Data: 0x0000000000000000000000000000000000000000000000000000000000000065
You can even fork networks while using Chisel: ```bash !fork {{ networks.moonbase.rpc_url }} ``` Then, for example, you can query the balance of one of Moonbase Alpha's collators: ```text {{ networks.moonbase.staking.candidates.address1 }}.balance ```
!fork https://rpc.api.moonbase.moonbeam.network Set fork URL to https://rpc.api.moonbase.moonbeam.network 0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5.balance Type: uint ├ Hex: 0x000000000000000000000000000000000000000000000358affd3d76ebb78555 └ Decimal: 15803094286802091476309
If you want to learn more about Chisel, download Foundry and refer to its [official reference page](https://getfoundry.sh/chisel/reference/){target=\_blank}. ## Foundry With Hardhat {: #foundry-with-hardhat } Often, there will be the case where a project that you wish to integrate with has all of its setup within [Hardhat](/builders/ethereum/dev-env/hardhat/){target=\_blank}, making it an arduous task to convert the entirety of the project into Foundry. This additional work is avoidable by creating a hybrid project that uses both Hardhat and Foundry features together. This is possible with Hardhat's [hardhat-foundry plugin](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-foundry){target=\_blank}. To convert your preexisting Foundry project to a hybrid project, you will essentially have to install a Hardhat project into the same folder: ```bash npm init npm install --save-dev hardhat @nomicfoundation/hardhat-foundry npx hardhat init ``` For more information, please refer to our documentation on [Creating a Hardhat Project](/builders/ethereum/dev-env/hardhat/#creating-a-hardhat-project){target=\_blank}. After initializing the new Hardhat project, a few new folders and files should appear: `contracts`, `hardhat.config.js`, `scripts`, and `test/Lock.js`. You'll need to make a few modifications to create a hybrid project: 1. Edit the `hardhat.config.js` file within your repository. Open it up, and at the top, add the following: ```javascript require("@nomicfoundation/hardhat-foundry"); ``` After adding the `hardhat-foundry` plugin, the typical `contracts` folders for Hardhat will not work because now Hardhat expects all smart contracts to be stored within Foundry's `src` folder 2. Move all smart contracts within the `contracts` folder into the `src` folder, and then delete the `contracts` folder 3. Edit the `foundry.toml` file to ensure that dependencies installed via Git submodules and npm can be compiled by the Forge tool. Edit the `profile.default` to ensure that the `libs` entry has both `lib` and `node_modules`: ```toml [profile.default] src = 'src' out = 'out' libs = ['lib', 'node_modules'] solc = '0.8.20' evm_version = 'london' ``` Now both `forge build` and `npx hardhat compile` should work regardless of the dependencies. Both `forge test` and `npx hardhat test` should now be able to access all smart contracts and dependencies. `forge test` will only test the Solidity tests, whereas `npx hardhat test` will only test the JavaScript tests. If you would like to use them in conjunction, then you can create a new script within your `package.json` file: ```json "scripts": { "test": "npx hardhat test && forge test" } ``` You can run this command with: ```bash npm run test ``` Finally, while not necessary, it could be worthwhile to move all JavaScript scripts from the `scripts` folder into Foundry's `script` folder and delete the `scripts` folder so that you don't have two folders that serve the same purpose.
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/dev-env/hardhat/ --- BEGIN CONTENT --- --- title: Deploy Contracts with Hardhat description: Learn how to use Hardhat, an Ethereum development environment, to compile, deploy, and debug Solidity smart contracts on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using Hardhat to Deploy To Moonbeam ## Introduction {: #introduction } [Hardhat](https://hardhat.org){target=\_blank} is a flexible and extensible Ethereum development environment that streamlines the smart contract development process. Since Moonbeam is Ethereum-compatible, you can use Hardhat to develop and deploy smart contracts on Moonbeam. Hardhat takes a task-based approach to development, where you can define and execute [tasks](https://hardhat.org/hardhat-runner/docs/advanced/create-task){target=\_blank} that perform specific actions. These actions include compiling and deploying contracts, running tests, and more. Tasks are highly configurable, so you can create, customize, and execute tasks that are tailored to meet your needs. You can also extend Hardhat's functionality through the use of [plugins](https://hardhat.org/hardhat-runner/plugins){target=\_blank}. Plugins are external extensions that integrate with Hardhat to provide additional features and tools for your workflow. For example, there are plugins for common Ethereum libraries, like [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank} and [viem](/builders/ethereum/libraries/viem/){target=\_blank}, a plugin that extends the Chai assertion library to include Ethereum-specific functionality, and more. All of these plugins can be used to extend your Hardhat project on Moonbeam. This guide will provide a brief introduction to Hardhat and show you how to use Hardhat to compile, deploy, and debug Ethereum smart contracts on the Moonbase Alpha TestNet. This guide can also be adapted for Moonbeam, Moonriver, or a Moonbeam development node. Please note that although Hardhat comes with a [Hardhat Network](https://hardhat.org/docs#hardhat-network){target=\_blank} component, which provides a local development environment, you should use a [local Moonbeam development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} instead. You can connect a Moonbeam development node to Hardhat just like you would with any other network. ## Checking Prerequisites {: #checking-prerequisites } To get started, you will need the following: - Have [MetaMask installed](/tokens/connect/metamask/#install-the-metamask-extension){target=\_blank} and [connected to Moonbase Alpha](/tokens/connect/metamask/#connect-metamask-to-moonbeam){target=\_blank} - Have an account with funds. 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} - 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} ## Create a Hardhat Project {: #creating-a-hardhat-project } You will need to create a Hardhat project if you don't already have one. You can create one by completing the following steps: 1. Create a directory for your project ```sh mkdir hardhat && cd hardhat ``` 2. Initialize the project, which will create a `package.json` file ```sh npm init -y ``` 3. Install Hardhat ```sh npm install hardhat@3.0.0-next.5 ``` 4. Create a Hardhat project ```sh npx hardhat --init ``` !!! note `npx` is used to run executables installed locally in your project. Although Hardhat can be installed globally, installing it locally in each project is recommended so you can control the version on a project-by-project basis. 5. You'll be prompted with a series of questions to set up your project: - Choose where to initialize the project (default is current directory) - Confirm converting to ESM (required for Hardhat v3) - Select the type of project to initialize: - A TypeScript Hardhat project using Node Test Runner and Viem - A TypeScript Hardhat project using Mocha and Ethers.js For this example, you can choose either option based on your preference. If you choose the Mocha and Ethers.js option, you'll get a project structure with: - A sample contract in `contracts/Counter.sol` - A test file in `test/Counter.ts` - TypeScript configuration - Mocha and Ethers.js dependencies The project will be set up with all necessary dependencies and configurations for you to start developing.
npx hardhat init 888    888                      888 888               888 888    888                      888 888               888 888    888                      888 888               888 8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888 888    888     "88b 888P"  d88" 888 888 "88b     "88b 888 888    888 .d888888 888    888  888 888  888 .d888888 888 888    888 888  888 888    Y88b 888 888  888 888  888 Y88b. 888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888
👷 Welcome to Hardhat v3.0.0-next.5 👷‍
 Where would you like to initialize the project?  .  Hardhat only supports ESM projects. Would you like to change "package.json" to turn your project into ESM? (Y/n) · true  What type of project would you like to initialize? …   A TypeScript Hardhat project using Node Test Runner and Viem  A TypeScript Hardhat project using Mocha and Ethers.js
## Hardhat Configuration File {: #hardhat-configuration-file } The Hardhat configuration file is the entry point into your Hardhat project. It defines various settings and options for your Hardhat project, such as the Solidity compiler version to use and the networks you can deploy your contracts to. To start, your `hardhat.config.js` should resemble the following: ```js /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { solidity: '0.8.28', }; ``` For this example, you can leave the Solidity compiler version to `0.8.28`; however, if you are using a different contract that requires a newer version, don't forget to update the version here. Next, you'll need to modify your configuration file to add the network configurations for the network you want to deploy your contract to. For Moonbeam networks, you'll need to specify the following: - `url` - the [RPC endpoint](/builders/get-started/endpoints/){target=\_blank} of the node - `chainId` - the chain ID, which is used to validate the network - `accounts` - the accounts that can be used to deploy and interact with contracts. You can either enter an array of the private keys for your accounts or use an [HD Wallet](https://github.com/ethereumbook/ethereumbook/blob/develop/05wallets.asciidoc#hierarchical-deterministic-wallets-bip-32bip-44){target=\_blank} Hardhat 3 includes an encrypted secrets manager that makes it easier to handle sensitive information like private keys. This ensures you don't have to hardcode secrets in your source code or store them in plain text. !!! note The encrypted secrets manager is only available in Hardhat 3 or higher. As of writing this guide, Hardhat 3 is in alpha. You can install the latest alpha version with: ```bash npm install hardhat@3.0.0-next.5 ``` For the latest releases and updates, check the [Hardhat releases page](https://github.com/NomicFoundation/hardhat/releases/). To use encrypted secrets, you'll need to: 1. Install Hardhat 3 or later: ```bash npm install hardhat@3.0.0-next.5 ``` 2. Set up your secrets using the keystore: === "Moonbeam" ```bash npx hardhat keystore set MOONBEAM_RPC_URL npx hardhat keystore set MOONBEAM_PRIVATE_KEY ``` === "Moonriver" ```bash npx hardhat keystore set MOONRIVER_RPC_URL npx hardhat keystore set MOONRIVER_PRIVATE_KEY ``` === "Moonbase Alpha" ```bash npx hardhat keystore set MOONBASE_RPC_URL npx hardhat keystore set MOONBASE_PRIVATE_KEY ``` === "Moonbeam Dev Node" ```bash npx hardhat keystore set DEV_RPC_URL npx hardhat keystore set DEV_PRIVATE_KEY ``` Then, update your configuration file to use the encrypted secrets: === "Moonbeam" ```js module.exports = { solidity: '0.8.28', networks: { moonbeam: { type: "http", chainType: "generic", url: configVariable("MOONBEAM_RPC_URL"), chainId: {{ networks.moonbeam.chain_id }}, // (hex: {{ networks.moonbeam.hex_chain_id }}), accounts: [configVariable("MOONBEAM_PRIVATE_KEY")], }, }, }; ``` === "Moonriver" ```js module.exports = { solidity: '0.8.28', networks: { moonriver: { type: "http", chainType: "generic", url: configVariable("MOONRIVER_RPC_URL"), chainId: {{ networks.moonriver.chain_id }}, // (hex: {{ networks.moonriver.hex_chain_id }}), accounts: [configVariable("MOONRIVER_PRIVATE_KEY")], }, }, }; ``` === "Moonbase Alpha" ```js module.exports = { solidity: '0.8.28', networks: { moonbase: { type: "http", chainType: "generic", url: configVariable("MOONBASE_RPC_URL"), chainId: {{ networks.moonbase.chain_id }}, // (hex: {{ networks.moonbase.hex_chain_id }}), accounts: [configVariable("MOONBASE_PRIVATE_KEY")], }, }, }; ``` === "Moonbeam Dev Node" ```js module.exports = { solidity: '0.8.28', networks: { dev: { type: "http", chainType: "generic", url: configVariable("DEV_RPC_URL"), chainId: {{ networks.development.chain_id }}, // (hex: {{ networks.development.hex_chain_id }}), accounts: [configVariable("DEV_PRIVATE_KEY")], }, }, }; ``` When you run tasks that require these secrets, Hardhat will prompt you for the password to decrypt them. The secrets are only decrypted when needed, meaning you only need to enter the password if a Hardhat task uses a secret. If you are planning on using any plugins with your project, you'll need to install the plugin and import it into the `hardhat.config.js` file. Once a plugin has been imported, it becomes part of the [Hardhat Runtime Environment](https://hardhat.org/hardhat-runner/docs/advanced/hardhat-runtime-environment){target=\_blank}, and you can leverage the plugin's functionality within tasks, scripts, and more. For this example, you can install the `hardhat-ethers` plugin and import it into the configuration file. This plugin provides a convenient way to use the [Ethers.js](/builders/ethereum/libraries/ethersjs/){target=\_blank} library to interact with the network. ```bash npm install @nomicfoundation/hardhat-ethers ethers ``` Additionally, you'll need to install the `hardhat-ignition-ethers` plugin to enable deployment of smart contracts with Hardhat Ignition. You can install it with the following command: ```sh npm install --save-dev @nomicfoundation/hardhat-ignition-ethers ``` To import both plugins, add the following `require` statements to the top of the Hardhat configuration file: ```js hl_lines="2 3" /** @type import('hardhat/config').HardhatUserConfig */ require('@nomicfoundation/hardhat-ethers'); require('@nomicfoundation/hardhat-ignition-ethers'); module.exports = { solidity: '0.8.28', networks: { moonbase: { url: configVariable("MOONBASE_RPC_URL"), chainId: 1287, // 0x507 in hex, accounts: [configVariable("MOONBASE_PRIVATE_KEY")] } } }; ``` For more information on the available configuration options, please refer to Hardhat's documentation on [Configuration](https://hardhat.org/hardhat-runner/docs/config#networks-configuration){target=\_blank}. ## The Contract File {: #the-contract-file } Now that you've configured your project, you can begin the development process by creating your smart contract. The contract will be a simple one that will let you store a value that can be retrieved later, called `Box`. To add the contract, you'll take the following steps: 1. Change into the `contracts` directory ```sh cd contracts ``` 2. Create a `Box.sol` file ```sh touch Box.sol ``` 3. Open the file and add the following contract to it: ```solidity // contracts/Box.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.1; contract Box { uint256 private value; // Emitted when the stored value changes event ValueChanged(uint256 newValue); // Stores a new value in the contract function store(uint256 newValue) public { value = newValue; emit ValueChanged(newValue); } // Reads the last stored value function retrieve() public view returns (uint256) { return value; } } ``` ## Compile the Contract {: #compiling-solidity } The next step is to compile the `Box.sol` smart contract. For this, you can use the built-in `compile` task, which will look for Solidity files in the `contracts` directory and compile them using the version and compiler settings defined in the `hardhat.config.js` file. To use the `compile` task, all you have to do is run: ```sh npx hardhat compile ```
npx hardhat compile Compiled 1 Solidity files successfully (evm target: paris). ls -l artifacts cache contracts hardhat.config.js node_modules package.json package-lock.json
After compilation, an `artifacts` directory is created that holds the bytecode and metadata of the contract, which are `.json` files. It's a good idea to add this directory to a `.gitignore` file. If you make changes to the contract after you've compiled it, you can compile it again using the same command. Hardhat will look for any changes and recompile the contract. If no changes are found, nothing will be compiled. If needed, you can force a compilation using the `clean` task, which will clear the cache and delete the old artifacts. ## Deploy the Contract {: #deploying-the-contract } To deploy the contract, you'll use Hardhat Ignition, a declarative framework for deploying smart contracts. Hardhat Ignition is designed to make it easy to manage recurring tasks surrounding smart contract deployment and testing. For more information, be sure to check out the [Hardhat Ignition docs](https://hardhat.org/ignition/docs/getting-started#overview){target=\_blank}. To set up the proper file structure for your Ignition module, create a folder named `ignition` and a subdirectory called `modules`. Then add a new file to it called `Box.js`. You can take all three of these steps with the following command: ```sh cd ignition/modules && touch Box.js ``` Next, you can write your Hardhat Ignition module. To get started, take the following steps: 1. Import the `buildModule` function from the Hardhat Ignition module 2. Export a module using `buildModule` 3. Use the `getAccount` method to select the deployer account 4. Deploy the `Box` contract 5. Return an object from the module. This makes the `Box` contract accessible for interaction in Hardhat tests and scripts ```js // 1. Import the `buildModule` function from the Hardhat Ignition module import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; // 2. Export a module using `buildModule` // Use `export default` instead of `module.exports` export default buildModule("BoxModule", (m) => { // 3. Use the `getAccount` method to select the deployer account const deployer = m.getAccount(0); // 4. Deploy the `Box` contract const box = m.contract("Box", [], { from: deployer, }); // 5. Return an object from the module return { box }; }); ``` To run the script and deploy the `Box.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, hardhat will deploy the contract to a local Hardhat network by default. ```sh npx hardhat ignition deploy ./Box.js --network moonbase ``` !!! note If you're using another Moonbeam network, make sure that you specify the correct network. The network name needs to match the one defined in the `hardhat.config.js` file. You'll be prompted to enter your password for the Hardhat secrets manager. Next, you'll be prompted to confirm the network you wish to deploy to. A few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal.
npx hardhat ignition deploy ./Box.js --network moonbase
✅ Confirm deploy to network moonbase (1287)? … yes Hardhat Ignition 🚀
Deploying [ BoxModule ]
Batch #1 Executed BoxModule#Box
[ BoxModule ] successfully deployed 🚀
Deployed Addresses
BoxModule#Box - 0xfBD78CE8C9E1169851119754C4Ea2f70AB159289
Congratulations, your contract is live! Save the address, as you will use it to interact with this contract instance in the next step. ## Interact with the Contract {: #interacting-with-the-contract } There are a couple of ways that you can interact with your newly deployed contract using Hardhat: you can use the `console` task, which spins up an interactive JavaScript console, or you can create another script and use the `run` task to execute it. ### Using the Hardhat Console {: #hardhat-console } The [Hardhat console](https://hardhat.org/hardhat-runner/docs/guides/hardhat-console){target=\_blank} uses the same execution environment as the tasks and scripts, so it automatically uses the configurations and plugins defined in the `hardhat.config.js`. To launch the Hardhat `console`, you can run: ```sh npx hardhat console --network moonbase ``` Next, you can take the following steps, entering one line at a time: 1. Create a local instance of the `Box.sol` contract ```js const Box = await ethers.getContractFactory('Box'); ``` 2. Connect the local instance to the deployed contract, using the address of the contract shown in the prior step under **Deployed Addresses** ```js const box = await Box.attach('INSERT-CONTRACT-ADDRESS'); ``` 3. Interact with the attached contract. For this example, you can call the `store` method and store a simple value ```js await box.store(5); ``` The transaction will be signed by your account configured in the `hardhat.config.js` file and broadcasted to the network. The output should look similar to:
npx hardhat console --network moonbase
Welcome to Node.js v20.9.0. Type ".help" for more information. const Box = await ethers.getContractFactory('Box'); undefined
const box = await Box.attach('0xfBD78CE8C9E1169851119754C4Ea2f70AB159289'); undefined
await box.store(5); ContractTransactionResponse {
provider: HardhatEthersProvider { ... },
blockNumber: null,
blockHash: null,
index: undefined,
hash: '0x1c49a64a601fc5dd184f0a368a91130cb49203ec0f533c6fcf20445c68e20264',
type: 2,
to: '0xa84caB60db6541573a091e5C622fB79e175E17be',
from: '0x3B939FeaD1557C741Ff06492FD0127bd287A421e',
nonce: 87,
gasLimit: 45881n,
gasPrice: 1107421875n,
maxPriorityFeePerGas: 1n,
maxFeePerGas: 1107421875n,
data: '0x6057361d0000000000000000000000000000000000000000000000000000000000000005',
value: 0n,
chainId: 5678n,
signature: Signature { r: "0x9233b9cc4ae6879b7e08b9f1a4bfb175c8216eee0099966eca4a305c7f369ecc", s: "0x7663688633006b5a449d02cb08311569fadf2f9696bd7fe65417860a3b5fc57d", yParity: 0, networkV: null },
accessList: [],
blobVersionedHashes: null
}
await box.retrieve(); 5n
Notice your address labeled `from`, the address of the contract, and the `data` that is being passed. Now, you can retrieve the value by running: ```js await box.retrieve(); ``` You should see `5`, or the value you initially stored. ### Using a Script {: #using-a-script } Similarly to the deployment script, you can create a script to interact with your deployed contract, store it in the `scripts` directory, and run it using the built-in `run` task. To get started, create a `set-value.js` file in the `scripts` directory: ```sh cd scripts && touch set-value.js ``` Now paste the following contract into the `set-value.js` file: ```js // scripts/set-value.js async function main() { // Create instance of the Box contract const Box = await ethers.getContractFactory('Box'); // Connect the instance to the deployed contract const box = await Box.attach('INSERT-CONTRACT-ADDRESS'); // Store a new value await box.store(2); // Retrieve the value const value = await box.retrieve(); console.log(`The new value is: ${value}`); } main() .then(() => process.exit(0)) .catch(error => { console.error(error); process.exit(1); }); ``` To run the script, you can use the following command: ```sh npx hardhat run --network moonbase set-value.js ``` The script should return `2` as the value.
npx hardhat run --network moonbase scripts/set-value.js
The new value is: 2
## Hardhat Forking {: #hardhat-forking } You can [fork](https://hardhat.org/hardhat-network/docs/guides/forking-other-networks){target=\_blank} any EVM-compatible chain using Hardhat, including Moonbeam. Forking simulates the live Moonbeam network locally, enabling you to interact with deployed contracts on Moonbeam in a local test environment. Since Hardhat forking is based on an EVM implementation, you can interact with the fork using standard [Ethereum JSON-RPC methods supported by Moonbeam](/builders/ethereum/json-rpc/eth-rpc/){target=\_blank} and [Hardhat](https://hardhat.org/hardhat-network/docs/reference#json-rpc-methods-support){target=\_blank}. There are some limitations to be aware of when using Hardhat forking. You cannot interact with any of the Moonbeam precompiled contracts or their functions. Precompiles are a part of the Substrate implementation and therefore cannot be replicated in the simulated EVM environment. This prohibits you from interacting with cross-chain assets on Moonbeam and Substrate-based functionality such as staking and governance. There is currently an issue related to forking Moonbeam, so in order to fix the issue, you'll need to manually patch Hardhat first. You can find out more information by following the [issue on GitHub](https://github.com/NomicFoundation/hardhat/issues/2395#issuecomment-1043838164){target=\_blank} as well as the related [PR](https://github.com/NomicFoundation/hardhat/pull/2313){target=\_blank}. ### Patching Hardhat {: #patching-hardhat } Before getting started, you'll need to apply a temporary patch to workaround an RPC error until Hardhat fixes the root issue. The error is as follows: ```sh Error HH604: Error running JSON-RPC server: Invalid JSON-RPC response's result. Errors: Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/0: RpcTransaction/accessList: Array<{ address: DATA, storageKeys: Array | null }> | undefined, Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/1: RpcTransaction/accessList: Array<{ address: DATA, storageKeys: Array | null }> | undefined, Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/2: RpcTransaction/accessList: Array<{ address: DATA, storageKeys: Array | null }> | undefined ``` To patch Hardhat, you'll need to open the `node_modules/hardhat/internal/hardhat-network/jsonrpc/client.js` file of your project. Next, you'll add an `addAccessList` function and update the `_perform` and `_performBatch` functions. To get started, you can remove the preexisting `_perform` and `_performBatch` functions and, in their place, add the following code snippet: ```js addAccessList(method, rawResult) { if ( method.startsWith('eth_getBlock') && rawResult && rawResult.transactions?.length ) { rawResult.transactions.forEach((t) => { if (t.accessList == null) t.accessList = []; }); } } async _perform(method, params, tType, getMaxAffectedBlockNumber) { const cacheKey = this._getCacheKey(method, params); const cachedResult = this._getFromCache(cacheKey); if (cachedResult !== undefined) { return cachedResult; } if (this._forkCachePath !== undefined) { const diskCachedResult = await this._getFromDiskCache( this._forkCachePath, cacheKey, tType ); if (diskCachedResult !== undefined) { this._storeInCache(cacheKey, diskCachedResult); return diskCachedResult; } } const rawResult = await this._send(method, params); this.addAccessList(method, rawResult); const decodedResult = (0, decodeJsonRpcResponse_1.decodeJsonRpcResponse)( rawResult, tType ); const blockNumber = getMaxAffectedBlockNumber(decodedResult); if (this._canBeCached(blockNumber)) { this._storeInCache(cacheKey, decodedResult); if (this._forkCachePath !== undefined) { await this._storeInDiskCache(this._forkCachePath, cacheKey, rawResult); } } return decodedResult; } async _performBatch(batch, getMaxAffectedBlockNumber) { // Perform Batch caches the entire batch at once. // It could implement something more clever, like caching per request // but it's only used in one place, and those other requests aren't // used anywhere else. const cacheKey = this._getBatchCacheKey(batch); const cachedResult = this._getFromCache(cacheKey); if (cachedResult !== undefined) { return cachedResult; } if (this._forkCachePath !== undefined) { const diskCachedResult = await this._getBatchFromDiskCache( this._forkCachePath, cacheKey, batch.map((b) => b.tType) ); if (diskCachedResult !== undefined) { this._storeInCache(cacheKey, diskCachedResult); return diskCachedResult; } } const rawResults = await this._sendBatch(batch); const decodedResults = rawResults.map((result, i) => { this.addAccessList(batch[i].method, result); return (0, decodeJsonRpcResponse_1.decodeJsonRpcResponse)( result, batch[i].tType ); }); const blockNumber = getMaxAffectedBlockNumber(decodedResults); if (this._canBeCached(blockNumber)) { this._storeInCache(cacheKey, decodedResults); if (this._forkCachePath !== undefined) { await this._storeInDiskCache(this._forkCachePath, cacheKey, rawResults); } } return decodedResults; } ``` Then you can use [patch-package](https://www.npmjs.com/package/patch-package){target=\_blank} to automatically patch the package by running the following command: ```sh npx patch-package hardhat ``` A `patches` directory will be created, and now you should be all set to fork Moonbeam without running into any errors. ### Forking Moonbeam {: #forking-moonbeam } You can fork Moonbeam from the command line or configure your Hardhat project to always run the fork from your `hardhat.config.js` file. To fork 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}. To fork Moonbeam from the command line, you can run the following command from within your Hardhat project directory: === "Moonbeam" ```sh npx hardhat node --fork {{ networks.moonbeam.rpc_url }} ``` === "Moonriver" ```sh npx hardhat node --fork {{ networks.moonriver.rpc_url }} ``` === "Moonbase Alpha" ```sh npx hardhat node --fork {{ networks.moonbase.rpc_url }} ``` If you prefer to configure your Hardhat project, you can update your `hardhat.config.js` file with the following configurations: === "Moonbeam" ```js ... networks: { hardhat: { forking: { url: '{{ networks.moonbeam.rpc_url }}', }, }, }, ... ``` === "Moonriver" ```js ... networks: { hardhat: { forking: { url: '{{ networks.moonriver.rpc_url }}', }, }, }, ... ``` === "Moonbase Alpha" ```js ... networks: { hardhat: { forking: { url: '{{ networks.moonbase.rpc_url }}', }, }, }, ... ``` When you spin up the Hardhat fork, you'll have 20 development accounts that are pre-funded with 10,000 test tokens. The forked instance is available at `http://127.0.0.1:8545/`. The output in your terminal should resemble the following:
Private Key: Oxdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 Account #9: Oxa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000 ETH) Private Key: 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 Account #10: OxBcd4042DE499D14e55001CcbB24a551F3b954096 (10000 ETH) Private Key: Oxf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897 Account #11: 0x71bE63f3384f5fb98995898A86B02Fb2426c5788 (10000 ETH) Private Key: 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82 Account #12: OxFABBOac9d68B0B445fB7357272F202C5651694a (10000 ETH) Private Key: Oxa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1 Account #13: 0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec (10000 ETH) Private Key: 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd Account #14: OxdF3e18d64BC6A983f673Ab319CCaE4f1a5707097 (10000 ETH) Private Key: Oxc526ee95bf44d8fc405a158bb884d9d1238d990612e9f33d006bb0789009aaa Account #15: Oxcd3B766CCDd6AE721141F452C550Ca635964ce71 (10000 ETH) Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61 Account #16: 0×2546BcD3c84621e976D8185a91A922aE77ECEc30 (10000 ETH) Private Key: Oxea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0 Account #17: OxbDA5747bFD65F08deb54cb465eB87D40e51B197E (10000 ETH) Private Key: 0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b06166765a93e037fd Account #18: OxdD2FD4581271e230360230F9337D5c0430Bf44C0 (10000 ETH) Private Key: Oxde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0 Account #19: 0×8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 (10000 ETH) Private Key: Oxdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e WARNING: These accounts, and their private keys, are publicly known.
Any funds sent to them on Mainnet or any other live network WILL BE LOST.
To verify you have forked the network, you can query the latest block number: ```sh curl --data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 ``` If you convert the `result` from [hex to decimal](https://www.rapidtables.com/convert/number/hex-to-decimal.html){target=\_blank}, you should get the latest block number from the time you forked the network. You can cross-reference the block number using a [block explorer](/builders/get-started/explorers/){target=\_blank}. From here, you can deploy new contracts to your forked instance of Moonbeam or interact with contracts already deployed by creating a local instance of the deployed contract. To interact with an already deployed contract, you can create a new script in the `scripts` directory using `ethers`. Because you'll be running it with Hardhat, you don't need to import any libraries. Inside the script, you can access a live contract on the network using the following snippet: ```js const hre = require('hardhat'); async function main() { const provider = new ethers.JsonRpcProvider( 'http://127.0.0.1:8545/' ); const contract = new ethers.Contract( 'INSERT_CONTRACT_ADDRESS', 'INSERT_CONTRACT_ABI', provider ); } main().catch((error) => { console.error(error); process.exitCode = 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/builders/ethereum/dev-env/openzeppelin/contracts/ --- BEGIN CONTENT --- --- title: Deploy OpenZeppelin Contracts description: Learn how to create common OpenZeppelin contracts such as ERC-20, ERC-721, & ERC-1155 tokens with the OpenZeppelin Contracts Wizard and deploy them on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using OpenZeppelin Contracts and Remix To Deploy To Moonbeam ## Introduction {: #introduction } [OpenZeppelin](https://www.openzeppelin.com){target=\_blank} contracts and libraries have become a standard in the industry. They help developers minimize risk, as their open-source code templates are battle-tested for Ethereum and other blockchains. Their code includes the most used implementations of ERC standards and add-ons and often appears in guides and tutorials around the community. Because Moonbeam is fully Ethereum compatible, all of OpenZeppelin's contracts and libraries can be implemented without any changes. This guide is divided into two sections. The first part describes the OpenZeppelin Contracts Wizard, a great online tool to help you create smart contracts using OpenZeppelin code. The second section provides a step-by-step guide on how you can deploy these contracts using [Remix](https://remix.ethereum.org){target=\_blank} on Moonbeam. ## OpenZeppelin Contract Wizard {: #openzeppelin-contract-wizard } OpenZeppelin has developed an online web-based interactive contract generator tool that is probably the easiest and fastest way to write your smart contract using OpenZeppelin code, called [Contracts Wizard](https://docs.openzeppelin.com/contracts/5.x/wizard){target=\_blank}.
In this video, Open Zeppelin Wizard is used to deploy an ERC-20 token to Moonbase Alpha
Currently, the Contracts Wizard support the following ERC standards: - [**ERC-20**](https://ethereum.org/en/developers/docs/standards/tokens/erc-20){target=\_blank} — a fungible token standard that follows [EIP-20](https://eips.ethereum.org/EIPS/eip-20){target=\_blank}. Fungible means that all tokens are equivalent and interchangeable that is, of equal value. One typical example of fungible tokens is fiat currencies, where each equal-denomination bill has the same value - [**ERC-721**](https://ethereum.org/en/developers/docs/standards/tokens/erc-721){target=\_blank} — a non-fungible token contract that follows [EIP-721](https://eips.ethereum.org/EIPS/eip-721){target=\_blank}. Non-fungible means that each token is different, and therefore, unique. An ERC-721 token can represent ownership of that unique item, whether it is a collectible item in a game, real estate, and so on - [**ERC-1155**](https://docs.openzeppelin.com/contracts/5.x/erc1155){target=\_blank} — also known as the multi-token contract, because it can represent both fungible and non-fungible tokens in a single smart contract. It follows [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155){target=\_blank} The wizard is comprised of the following sections: 1. **Token standard selection** — shows all the different standards supported by the wizard 2. **Settings** — provides the baseline settings for each token standard, such as token name, symbol, pre-mint (token supply when the contract is deployed), and URI (for non-fungible tokens) 3. **Features** — list of all features available for each token standard. You can find more information about the different features in the following links: - [ERC-20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20){target=\_blank} - [ERC-721](https://docs.openzeppelin.com/contracts/5.x/api/token/erc721){target=\_blank} - [ERC-1155](https://docs.openzeppelin.com/contracts/5.x/api/token/erc1155){target=\_blank} 4. **Access Control** — list of all the available [access control mechanisms](https://docs.openzeppelin.com/contracts/5.x/access-control){target=\_blank} for each token standard 5. **Interactive code display** — shows the smart contract code with the configuration as set by the user ![OpenZeppelin Contracts Wizard](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-wizard-1.webp) Once you have set up your contract with all the settings and features, it is just as easy as copying and pasting the code into your contract file. ## Deploying OpenZeppelin Contracts on Moonbeam {: #deploying-openzeppelin-contracts-on-moonbeam } This section goes through the steps for deploying OpenZeppelin contracts on Moonbeam. It covers the following contracts: - ERC-20 (fungible tokens) - ERC-721 (non-fungible tokens) - ERC-1155 (multi-token standard) All the code of the contracts was obtained using OpenZeppelin [Contract Wizard](https://docs.openzeppelin.com/contracts/5.x/wizard){target=\_blank}. ### Checking Prerequisites {: #checking-prerequisites } The steps described in this section assume you have [MetaMask](https://metamask.io){target=\_blank} installed and connected to the Moonbase Alpha TestNet. If you're adapting this guide for Moonbeam or Moonriver, make sure you're connected to the correct network. Contract deployment is done using the [Remix IDE](https://remix.ethereum.org){target=\_blank} via the **Injected Provider** environment. You can find corresponding tutorials in the following links: - [Interacting with Moonbeam using MetaMask](/tokens/connect/metamask/){target=\_blank} - [Interacting with Moonbeam using Remix](/builders/ethereum/dev-env/remix/){target=\_blank} ### Deploying an ERC-20 Token {: #deploying-an-erc-20-token } For this example, an ERC-20 token will be deployed to Moonbase Alpha. The final code used combines different contracts from OpenZeppelin: - **`ERC20.sol`** — ERC-20 token implementation with the optional features from the base interface. Includes the supply mechanism with a `mint` function but needs to be explicitly called from within the main contract - **`Ownable.sol`** — extension to restrict access to certain functions The mintable ERC-20 OpenZeppelin token contract provides a `mint` function that the owner of the contract can only call. By default, the owner is the contract's deployer address. There is also a premint of `1000` tokens sent to the contract's deployer configured in the `constructor` function. The first step is to go to [Remix](https://remix.ethereum.org) and take the following steps: 1. Click on the **Create New File** icon and set a file name. For this example, it was set to `ERC20.sol` 2. Make sure the file was created successfully. Click on the file to open it up in the text editor 3. Write your smart contract using the file editor. For this example, the following code was used: ```solidity // SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; contract MyToken is ERC20, Ownable, ERC20Permit { constructor(address initialOwner) ERC20("MyToken", "MTK") Ownable(initialOwner) ERC20Permit("MyToken") { _mint(msg.sender, 1000 * 10 ** decimals()); } function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); } } ``` This ERC-20 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting a premint of `1000` tokens and activating the `Mintable` and `Permit` features. ![Getting Started with Remix](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-contracts-2.webp) Once your smart contract is written, you can compile it by taking the following steps: 1. Head to the **Solidity Compiler** 2. Click on the compile button 3. Alternatively, you can check the **Auto compile** feature ![Compile ERC-20 Contract with Remix](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-contracts-3.webp) With the contract compiled, you are ready to deploy it taking the following steps: 1. Head to the **Deploy & Run Transactions** tab 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC20.sol` file 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** ![Deploy ERC-20 Contract with Remix](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-contracts-4.webp) And that is it! You've deployed an ERC-20 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix, or add it to MetaMask. ### Deploying an ERC-721 Token {: #deploying-an-erc-721-token } For this example, an ERC-721 token will be deployed to Moonbase Alpha. The final code used combines different contracts from OpenZeppelin: - **`ERC721.sol`** — ERC-721 token implementation with the optional features from the base interface. Includes the supply mechanism with a `_mint` function but needs to be explicitly called from within the main contract - **`ERC721Burnable.sol`** — extension to allow tokens to be destroyed by their owners (or approved addresses) - **`ERC721Enumerable.sol`** — extension to allow on-chain enumeration of tokens - **`Ownable.sol`** — extension to restrict access to certain functions The mintable ERC-721 OpenZeppelin token contract provides a `mint` function that can only be called by the owner of the contract. By default, the owner is the contract's deployer address. As with the [ERC-20 contract](#deploying-an-erc-20-token), the first step is to go to [Remix](https://remix.ethereum.org){target=\_blank} and create a new file. For this example, the file name will be `ERC721.sol`. Next, you'll need to write the smart contract and compile it. For this example, the following code is used: ```solidity // SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract MyToken is ERC721, ERC721Enumerable, ERC721Burnable, Ownable { constructor(address initialOwner) ERC721("MyToken", "MTK") Ownable(initialOwner) {} function _baseURI() internal pure override returns (string memory) { return "Test"; } function safeMint(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } // The following functions are overrides required by Solidity function _update(address to, uint256 tokenId, address auth) internal override(ERC721, ERC721Enumerable) returns (address) { return super._update(to, tokenId, auth); } function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) { super._increaseBalance(account, value); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } ``` This ERC-721 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting the `Base URI` as `Test` and activating the `Mintable`, `Burnable`, and `Enumerable` features. With the contract compiled, next you will need to: 1. Head to the **Deploy & Run Transactions** tab 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC721.sol` file 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** ![Deploy ERC-721 Contract with Remix](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-contracts-5.webp) And that is it! You've deployed an ERC-721 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix, or add it to MetaMask. ### Deploying an ERC-1155 Token {: #deploying-an-erc-1155-token } For this example, an ERC-1155 token will be deployed to Moonbase Alpha. The final code used combines different contracts from OpenZeppelin: - **`ERC1155.sol`** — ERC-1155 token implementation with the optional features from the base interface. Includes the supply mechanism with a `_mint` function but needs to be explicitly called from within the main contract - **`Pausable.sol`** — extension to allows pausing tokens transfer, mintings and burnings - **`Ownable.sol`** — extension to restrict access to certain functions OpenZeppelin's ERC-1155 token contract provides a `_mint` function that can only be called in the `constructor` function. Therefore, this example creates 1000 tokens with an ID of `0`, and 1 unique token with an ID of `1`. The first step is to go to [Remix](https://remix.ethereum.org){target=\_blank} and create a new file. For this example, the file name will be `ERC1155.sol`. As shown for the [ERC-20 token](#deploying-an-erc-20-token), you'll need to write the smart contract and compile it. For this example, the following code is used: ```solidity // SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; contract MyToken is ERC1155, Ownable, ERC1155Pausable { constructor() ERC1155("") Ownable() { _mint(msg.sender, 0, 1000 * 10 ** 18, ""); _mint(msg.sender, 1, 1, ""); } function setURI(string memory newuri) public onlyOwner { _setURI(newuri); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } // The following function is an override required by Solidity function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal override(ERC1155, ERC1155Pausable) { super._update(from, to, ids, values); } } ``` This ERC-1155 token smart contract was extracted from the [Contract Wizard](#openzeppelin-contract-wizard), setting no `Base URI` and activating `Pausable` feature. The constructor function was modified to include the minting of both a fungible and a non-fungible token. With the contract compiled, next you will need to: 1. Head to the **Deploy & Run Transactions** tab 2. Change the environment to **Injected Provider**. This will use MetaMask's injected provider. Consequently, the contract will be deployed to whatever network MetaMask is connected to. MetaMask might show a pop-up outlining that Remix is trying to connect to your wallet 3. Select the proper contract to deploy. In this example, it is the `MyToken` contract inside the `ERC1155.sol` file 4. Enter the address of the initial owner and click on the **Deploy** button. Review the transaction information in MetaMask and confirm it 5. After a few seconds, the transaction should get confirmed, and you should see your contract under **Deployed Contracts** ![Deploy ERC-1155 Contract with Remix](/images/builders/ethereum/dev-env/openzeppelin/contracts/oz-contracts-6.webp) And that is it! You've deployed an ERC-1155 token contract using OpenZeppelin's contracts and libraries. Next, you can interact with your token contract via Remix.
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/dev-env/remix/ --- BEGIN CONTENT --- --- title: Deploy Smart Contracts with Remix description: Discover how to deploy and interact with Solidity smart contracts on Moonbeam using the Remix IDE, one of the most widely used Ethereum development tools. categories: Dev Environments, Ethereum Toolkit --- # Using Remix to Deploy to Moonbeam
## Introduction {: #introduction } [Remix](https://remix.ethereum.org){target=\_blank} is an integrated development environment (IDE) for developing smart contracts on Ethereum and Ethereum-compatible chains. It provides an easy-to-use interface for writing, compiling, and deploying smart contracts. Given Moonbeam’s Ethereum compatibility features, you can use Remix directly with any Moonbeam network. This guide walks through the process of creating and deploying a Solidity smart contract to a [Moonbeam development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} using the Remix IDE. This guide can be adapted for [Moonbeam](/builders/get-started/networks/moonbeam/){target=\_blank}, [Moonriver](/builders/get-started/networks/moonriver/){target=\_blank}, or [Moonbase Alpha](/builders/get-started/networks/moonbase/){target=\_blank}. If you're familiar with Remix, you can skip ahead to the [Connect Remix to Moonbeam](#connect-remix-to-moonbeam){target=\_blank} section to learn how to use Remix with Moonbeam. ## Checking Prerequisites {: #checking-prerequisites } For the purposes of this guide, you'll need to have the following: - A locally running [Moonbeam development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} - [MetaMask installed and connected](/tokens/connect/metamask/){target=\_blank} to your development node If you followed the guides above, you should have a local Moonbeam node, which will begin to author blocks as transactions arrive. ![The terminal logs of for a local Moonbeam development node that is producing blocks.](/images/builders/ethereum/dev-env/remix/remix-1.webp) Your development node comes with 10 pre-funded accounts. You should have MetaMask connected to your Moonbeam development node and have imported at least one of the pre-funded accounts. You can refer to the [Import Accounts](/tokens/connect/metamask/#import-accounts){target=\_blank} section of the MetaMask docs for step-by-step instructions on how to import a development account. ![The main screen of MetaMask, which shows an account connected to a Moonbeam development node and its balance.](/images/builders/ethereum/dev-env/remix/remix-2.webp) If you're adapting this guide for Moonbeam, Moonriver, or Moonbase Alpha, make sure you are connected to the correct network and have an account with funds. 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}. ## Get Familiar with Remix {: #get-familiar-with-remix } If you navigate to [https://remix.ethereum.org/](https://remix.ethereum.org){target=\_blank}, you'll see that the layout of Remix is split into four sections: 1. The plugin panel 2. The side panel 3. The main panel 4. The terminal ![The layout of Remix IDE and its four sections.](/images/builders/ethereum/dev-env/remix/remix-3.webp) The plugin panel displays icons for each of the preloaded plugins, the plugin manager, and the settings menu. You'll see a few icons there for each of the preloaded plugins, which are the **File explorer**, **Search in files**, **Solidity compiler**, and **Deploy and run transactions** plugins. As additional plugins are activated, their icons will appear in this panel. The side panel displays the content of the plugin that is currently being viewed. By default, you'll see the File explorer plugin, which displays the default workspace and some preloaded files and folders. However, if you select one of the other icons from the plugin panel, you'll see the content for the selected plugin. The main panel is automatically loaded with the **Home** tab, which contains links to a variety of resources. You can close this tab at any time and reopen it by clicking on the blue Remix icon in the top left corner of the plugin panel. The main panel is where you'll be able to see each of the files you're working with. For example, you can double-click on any file in the **File explorer** side panel and it will appear as a tab in the main panel. The terminal panel is similar to a standard terminal that you have on your OS; you can execute scripts from it, and logs are printed to it. All transactions and contract interactions are automatically logged to the terminal. You can also interact with the [Ethers](https://docs.ethers.org/v6){target=\_blank} and [Web3](https://web3js.org/#){target=\_blank} JavaScript libraries directly from the terminal. ## Add a Smart Contract to the File Explorer {: #add-a-smart-contract-to-the-file-explorer } For this example, you will create a new file that contains an ERC-20 token contract. This will be a simple ERC-20 contract based on the current [OpenZeppelin ERC-20 template](https://docs.openzeppelin.com/contracts/4.x/erc20){target=\_blank}. The contract will create a `MyToken` token with the `MYTOK` symbol that mints the entirety of the initial supply to the creator of the contract. From the **File explorer** tab on the plugin panel, you can create a new file by taking the following steps: 1. Click on the file icon 2. Enter the name of the contract: `MyToken.sol` ![Create a new file using the File explorer plugin in Remix.](/images/builders/ethereum/dev-env/remix/remix-4.webp) The main panel will switch to an empty file where you can add the Solidity code for the contract. Paste the `MyToken.sol` smart contract into the new file: ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") { _mint(msg.sender, initialSupply); } } ``` ![Add the contract code to the newly created file in the main panel of Remix.](/images/builders/ethereum/dev-env/remix/remix-5.webp) ## Compile a Solidity Smart Contract {: #compile-a-solidity-smart-contract } Before you compile a contract, make sure you've selected the file of the contract from the **File explorer** tab. Then, select the **Solidity Compiler** option from the plugin panel. Make sure that the compiler version in the top-left corner meets the version defined in your contract and the version defined in [OpenZeppelin's `ERC20.sol` contract](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol){target=\_blank}. For example, the `MyToken.sol` contract requires Solidity ^0.8.0, but at the time of writing, OpenZeppelin's `ERC20.sol` contract requires ^0.8.20, so the compiler needs to be set to version 0.8.20 or newer. The Solidity compiler plugin also lets you change some settings and apply advanced configurations for the compiler. If you're planning on iterating over the smart contract, you can check the **Auto compile** box, and whenever you make a change, the contract will automatically be recompiled. Additionally, from the **Advanced Configurations** menu, you can change the EVM version, enable optimizations, and set the number of times the bytecode is expected to be run throughout the contract's lifetime; the default is set to 200 times. For more information on contract optimization, please refer to the [Solidity docs on The Optimizer](https://docs.soliditylang.org/en/latest/using-the-compiler.html#optimizer-options){target=\_blank}. For this example, no additional configurations are needed. To compile the `MyToken.sol` contract, simply click on the **Compile MyToken.sol** contract. If the compilation was successful, you'll see a green check mark appear on the plugin panel next to the **Solidity compiler** plugin. ![The Solidity compiler plugin shown in the side panel in Remix.](/images/builders/ethereum/dev-env/remix/remix-6.webp) ### Debug Compilation Errors {: #debug-compilation-errors } If you tried to compile your smart contract but there was an error or warning, you can easily debug the issue with the help of ChatGPT directly from the Solidity compiler plugin in Remix. For example, if you only provided the token name to the ERC-20 constructor but forgot the token symbol and tried to compile the contract, an error would appear in the side panel. You can scroll down to read the error, and you'll see that there is also an **ASK GPT** button. To get help debugging the issue, you can click on **ASK GPT**, and a response will be returned in the Remix terminal that will guide you in the right direction to try and fix the issue. If you need additional help, you can go straight to the source and ask [ChatGPT](https://chatgpt.com/){target=\_blank} directly. ![An error message shown in the side panel for the Solidity compiler plugin with an ASK GPT button for debugging.](/images/builders/ethereum/dev-env/remix/remix-7.webp) Once you successfully fix the issue and recompile the contract, you'll see a green check mark appear on the plugin panel next to the **Solidity compiler** plugin. ![The green check mark next to the Solidity compiler plugin in the plugin panel.](/images/builders/ethereum/dev-env/remix/remix-8.webp) ## Deploy a Solidity Smart Contract {: #deploy-a-solidity-smart-contract } The **Deploy and run transactions** plugin enables you to configure contract deployment options, deploy contracts, and interact with deployed contracts. The side panel consists of the following deployment options: - Environment - allows you to choose the execution environment for deployment - Account - the account from which the deployment transaction will be sent - Gas Limit - the maximum amount of gas that the deployment transaction can consume - Value - the amount of the native asset to send along with the deployment transaction - Contract - the contract to deploy - Deploy - sends the deployment transaction to the specified environment using the selected account, gas limit, value, and the values for any constructor arguments - At Address - allows you to interact with an existing contract by specifying its address The following section will cover how to configure the environment for deployment to be Moonbeam. ### Connect Remix to Moonbeam {: #connect-remix-to-moonbeam } To deploy the smart contract to Moonbeam, you'll need to make sure that you've connected your wallet to your Moonbeam development node or the Moonbeam network of your choice. Then, from the **Deploy and run transactions** tab, you can connect Remix to your wallet by selecting your wallet from the **ENVIRONMENT** dropdown. For example, if you have Trust Wallet installed, you'll see **Injected Provider - TrustWallet** from the dropdown. Aside from injected providers, you can also connect to Moonbeam via WalletConnect. For this example, MetaMask will be used. You should already have MetaMask installed and connected to your local Moonbeam development node. If not, please refer to the [Interacting with Moonbeam Using MetaMask](/tokens/connect/metamask/){target=\_blank} guide for step-by-step instructions. From the **ENVIRONMENT** dropdown, select **Injected Provider - MetaMask**. ![The environment dropdown on the Deploy and run transactions side panel expanded to reveal all of the available options.](/images/builders/ethereum/dev-env/remix/remix-9.webp) MetaMask will pop up automatically and prompt you to connect to Remix. You'll need to: 1. Select the account you want to connect to Remix 2. Click **Next** 3. Click **Connect** to connect your account to Remix ![Two MetaMask screens that you must go through to connect to Remix: one that prompts you to choose an account to connect to and another that grants Remix permissions.](/images/builders/ethereum/dev-env/remix/remix-10.webp) Once you've connected MetaMask to Remix, the side panel will update to reveal the network and account you're connected to. For a Moonbeam development node, you should see **Custom (1281) network**. ![The Deploy and run transactions side panel in Remix showing the environment connected to MetaMask, the connected network as 1281, and the connected account address.](/images/builders/ethereum/dev-env/remix/remix-11.webp) ### Deploy the Contract to Moonbeam {: #deploy-the-contract-to-moonbeam } Now that you've connected your wallet, you're ready to deploy the contract. Since you're deploying a simple ERC-20 token smart contract, the default gas limit set by Remix of 3 million is more than enough, and you don't need to specify a value to send along with the deployment. As such, you can take the following steps to deploy the contract: 1. Make sure the **ENVIRONMENT** is set to **Injected Provider - MetaMask** 2. Make sure the connected account is the one you want to deploy the transaction from 3. Use the default **GAS LIMIT** of `3000000` 4. Leave the **VALUE** as `0` 5. Make sure `MyToken.sol` is the selected contract 6. Expand the **DEPLOY** dropdown 7. Specify the initial supply. For this example, you can set it to 8 million tokens. Since this contract uses the default of 18 decimals, the value to put in the box is `8000000000000000000000000` 8. Click **transact** to send the deployment transaction 9. MetaMask will pop up, and you can click **Confirm** to deploy the contract ![The Deploy and run transactions side panel completely filled out to perform a contract deployment.](/images/builders/ethereum/dev-env/remix/remix-12.webp) Once the transaction has been deployed, you'll see details about the deployment transaction in the Remix terminal. Additionally, the contract will appear under the **Deployed Contracts** section of the side panel. ## Interact with Deployed Smart Contracts {: #interact-with-deployed-smart-contracts } Once you've deployed a smart contract or accessed an existing contract via the **At Address** button, the contract will appear under the **Deployed Contracts** section of the side panel. You can expand the contract to view all of the contract's functions you can interact with. To interact with a given function, you can click on the function name, which will be contained in an orange, red, or blue button. Orange buttons are for functions that write to the blockchain and are non-payable; red buttons are for functions that write to the blockchain and are payable; and blue buttons are for functions that read data from the blockchain. Depending on the function you're interacting with, you may need to input parameter values. If the function requires inputs, you'll be able to enter them by expanding the function and entering a value for each of the parameters. If the function you're interacting with is payable, you'll be able to enter an amount in the **VALUE** field towards the top of the side panel, in the same value field used for contracts that have payable constructors. ### Call the Smart Contract Functions {: #call-the-smart-contract-functions } If you expand the **MYTOKEN** contract dropdown, you'll be able to see all of the available functions you can interact with. To interact with a given function, you can provide any inputs, if needed, and then click on the button containing the function name you want to interact with. For example, if you wanted to call the `totalSupply` function, you wouldn't need to sign a transaction, as you'd get a response right away. ![A view of the functions available in the deployed ERC-20 contract and the response from calling the totalSupply function.](/images/builders/ethereum/dev-env/remix/remix-13.webp) On the other hand, if you call the `approve` function, which will approve an account as a spender of a given amount of MYTOK tokens, you'll need to submit the approval in MetaMask. To test this out, you can take the following steps: 1. Set the **spender** to an account that you want to be able to spend tokens on your behalf. For this example, you can use Bob's account (one of the pre-funded development accounts): `0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0` 2. Enter the amount the spender can spend. For this example, you can approve Bob to spend 10 MYTOK by entering in `10000000000000000000` 3. Press **transact** 4. MetaMask will pop up and you'll need to review the details of the approval and submit the approval ![The inputs for the approve function of the ERC-20 contract and the MetaMask pop-up for the approval.](/images/builders/ethereum/dev-env/remix/remix-14.webp) To view your balance or approvals, or transfer MYTOKs, you can add the MYTOK to your wallet. For information on how to add a token to MetaMask, you can refer to the [Add an ERC-20 Token](/tokens/connect/metamask/#add-erc20){target=\_blank} section of [our MetaMask documentation](/tokens/connect/metamask/){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/ethereum/dev-env/scaffold-eth/ --- BEGIN CONTENT --- --- title: Create a DApp with Scaffold-ETH 2 description: You can deploy a Solidity DApp with a React UI and subgraph on Moonbeam in minutes by using Scaffold-ETH 2. Learn how in this tutorial. categories: Dev Environments, Ethereum Toolkit --- # Using Scaffold-ETH 2 to Deploy a DApp on Moonbeam ## Introduction {: #introduction } [Scaffold-ETH 2](https://github.com/scaffold-eth/scaffold-eth-2){target=\_blank} is a collection of commonly used Ethereum development tools to quickly deploy a Solidity smart contract and launch a DApp with a React frontend. Scaffold-ETH 2 consists of several sub-components, including [Hardhat](https://hardhat.org/docs){target=\_blank} for creating, deploying, and testing smart contracts and [Next.js](https://nextjs.org/docs){target=\_blank} for building a React frontend. These components can be used on Moonbeam networks with some slight modifications. This guide will walk through the steps to deploy and run the default example contract and DApp that Scaffold-ETH 2 comes with on a Moonbeam network. ## Checking Prerequisites {: #checking-prerequisites } To get started, you will need the following: - An account with funds. 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} - An [Etherscan API key](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank} - 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} ### Installing Scaffold-ETH 2 {: #installing-scaffold-eth } First, download [Scaffold-ETH 2 from GitHub](https://github.com/scaffold-eth/scaffold-eth-2){target=\_blank}. From the command line, enter: ```bash git clone https://github.com/scaffold-eth/scaffold-eth-2.git ``` After the download completes, run: ```bash yarn install ``` ## The Development Process with Scaffold-ETH 2 {: #development-process } The process for developing a project with Scaffold-ETH 2 can be outlined as follows: 1. Update the network configurations in Hardhat for Moonbeam 2. Add your smart contracts to the `packages/hardhat/contracts` 3. Edit your deployment scripts in the `packages/hardhat/deploy` 4. Deploy your smart contracts to Moonbeam 5. Verify your smart contracts with the Etherscan plugin and your Etherscan API key 6. Configure your frontend to target Moonbeam in the `packages/nextjs/scaffold.config.ts` file 7. Edit your frontend as needed in the `packages/nextjs/pages` directory In this guide, you can use the default contract and frontend that you get out of the box when you clone the Scaffold-ETH 2 repository. All you'll have to do is modify these components for Moonbeam. ## The Hardhat Component {: #hardhat-component } In the following sections, you'll update the network configurations in the Hardhat configuration file to target the Moonbeam-based network you want to interact with, and deploy and verify the example contract to that network. ### Configure Hardhat for Moonbeam {: #configure-hardhat-for-moonbeam } You can begin by making modifications to the Hardhat component under the `packages/hardhat` folder. You'll primarily be editing the `hardhat.config.js` file to configure it for Moonbeam. However, you'll also need to create a `.env` file to store a couple of variables that will be consumed by the `hardhat.config.js` file. You can refer to the `.env.example` file for the variables that are already used in the `hardhat.config.js` file. For Moonbeam, you'll only need to manually create one variable, the `ETHERSCAN_API_KEY`. Check out the [Etherscan Plugins](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank} documentation to learn how to generate an Etherscan API key. To get started, create a `.env` file: ```bash touch packages/hardhat/.env ``` Edit your `.env` file to include the following variables: ```text ETHERSCAN_API_KEY=INSERT_ETHERSCAN_API_KEY ``` Next, import your deployment account by either generating a new one with `yarn generate` or importing an existing one using `yarn account:import`. If importing, you'll need to provide your private key and create a password to encrypt it. The encrypted key will be saved in your `.env` file. Keep your password safe as you'll need it to decrypt the private key for future deployments. Remember to never share or commit your private keys or `.env` file. For this example, we'll import an existing private key with the following command: ```bash yarn account:import ```
yarn account:import 👛 Importing Wallet Paste your private key: [hidden] Enter a password to encrypt your private key: [hidden] Confirm password: [hidden] 📄 Encrypted Private Key saved to packages/hardhat/.env file 🪄 Imported wallet address: 0x3B939FeaD1557C741Ff06492FD0127bd287A421e ⚠️ Make sure to remember your password! You'll need it to decrypt the private key.
The private key you add in the account import workflow corresponds to the account that will deploy and interact with the smart contracts in your Hardhat project. Additionally, the Etherscan API key will correspond to your Etherscan API key and will be used to verify your deployed smart contracts. To learn how to generate an Etherscan API key, check out the [Etherscan Plugins](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank} documentation. With the deployment account and the Etherscan API key taken care of, next you can modify the `hardhat.config.js` file for Moonbeam: 1. Set the constant `defaultNetwork` to the network you are deploying the smart contract to === "Moonbeam" ```js defaultNetwork = 'moonbeam'; ``` === "Moonriver" ```js defaultNetwork = 'moonriver'; ``` === "Moonbase Alpha" ```js defaultNetwork = 'moonbaseAlpha'; ``` === "Moonbeam Dev Node" ```js defaultNetwork = 'moonbeamDevNode'; ``` 2. Add the network configurations for the Moonbeam network you want to interact with under the `networks` configuration object === "Moonbeam" ```js moonbeam: { url: "{{ networks.moonbeam.rpc_url }}", accounts: [deployerPrivateKey], }, ``` === "Moonriver" ```js moonriver: { url: "{{ networks.moonriver.rpc_url }}", accounts: [deployerPrivateKey], }, ``` === "Moonbase Alpha" ```js moonbaseAlpha: { url: "{{ networks.moonbase.rpc_url }}", accounts: [deployerPrivateKey], }, ``` === "Moonbeam Dev Node" ```js moonbeamDevNode: { url: "{{ networks.development.rpc_url }}", accounts: [deployerPrivateKey], }, ``` 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}. For more information on using Hardhat with Moonbeam, please check the dedicated [Hardhat page](/builders/ethereum/dev-env/hardhat/){target=\_blank} for more details. ### Deploy Your Contract to Moonbeam {: #deploy-contract } After all the modifications to the configuration files are done, you can deploy your contract to the configured Moonbeam-based network. First, you can compile your contract by running: ```bash yarn compile ```
yarn compile Generating typings for: 2 artifacts in dir: typechain-types for target: ethers-v6 Successfully generated 6 typings! Compiled 2 Solidity files successfully (evm target: paris).
Then, you can run the following command from the root directory of your project: ```bash yarn deploy ```
yarn deploy Enter password to decrypt private key: [hidden] Nothing to compile No need to generate any newer typings. deploying "YourContract" (tx: 0xda4b71904cae30fad60669b321e1dd51b28a6cf197fc7ea13b5d85035b41d92c)...: deployed at 0xB527D4Ed38249d35cfCBAb92b51f45895622c6Eb with 837042 gas 👋 Initial greeting: Building Unstoppable Apps!!! 📝 Updated TypeScript contract definition file on ../nextjs/contracts/deployedContracts.ts
!!! note If you did not set the `defaultNetwork` config in the `hardhat.config.js` file, you can append `--network INSERT_NETWORK` to the command. For example, the following command would deploy a contract to Moonbeam. ```bash yarn deploy --network moonbeam ``` ### Verify Your Deployed Contract {: #verify-contracts } If you would also like to use Scaffold-ETH 2 to verify the deployed smart contract and have entered your Etherscan API key into the `.env` file, you can go ahead and verify your deployed contract. If the smart contract you are verifying has constructor method parameters, you will also need to append the parameters used to the end of the command. You can use the following command to verify the smart contract: === "Moonbeam" ```bash yarn verify --api-url https://api-moonbeam.moonscan.io ``` === "Moonriver" ```bash yarn verify --api-url https://api-moonriver.moonscan.io ``` === "Moonbase Alpha" ```bash yarn verify --api-url https://api-moonbase.moonscan.io ``` !!! note If you did not set the `defaultNetwork` configuration in the `hardhat.config.js` file, you can append `--network INSERT_NETWORK` to the command. For example, the following command would verify a contract on Moonbeam. ```bash yarn verify --network moonbeam --api-url https://api-moonbeam.moonscan.io ``` After a short wait, the console output will display the verification result and, if successful, the URL to the verified contract on Moonscan.
yarn verify --api-url https://api-moonbase.moonscan.io verifying YourContract (0xB527D4Ed38249d35cfCBAb92b51f45895622c6Eb) ... waiting for result... => contract YourContract is now verified
For more information about verifying smart contracts on Moonbeam using the Hardhat Etherscan plugin, please refer to the [Etherscan Plugins page](/builders/ethereum/verify-contracts/etherscan-plugins/#using-the-hardhat-etherscan-plugin){target=\_blank}. ## The Next.js Component {: #nextjs-component } In the following sections, you'll modify the Next.js configuration so that it targets the Moonbeam-based network that your contract has been deployed to, and then you'll launch the dApp. ### Configure the DApp for Moonbeam {: #configure-dapp } To target the Moonbeam-based network that you deployed your smart contract to, you'll need to edit the configurations in the `packages/nextjs/scaffold.config.ts` file. More specifically, you'll need to modify the `targetNetworks` array in the `scaffoldConfig` object. You can use the [list of chains that viem provides](https://github.com/wevm/viem/blob/main/src/chains/index.ts){target=\_blank} to specify the chain(s) you've deployed your contract to. === "Moonbeam" ```js targetNetworks: [chains.moonbeam], ``` === "Moonriver" ```js targetNetworks: [chains.moonriver], ``` === "Moonbase Alpha" ```js targetNetworks: [chains.moonbaseAlpha], ``` === "Moonbeam Dev Node" ```js targetNetworks: [chains.moonbeamDev], ``` That's all you have to do to configure Next.js! Next, you can launch the dApp. ### Launch the DApp {: #launch-the-dapp } After all the modifications to the configuration files are done, you can launch the example dApp. To do so, you can run: ```bash yarn start ```
yarn start ▲ Next.js 14.2.11 - Local: http://localhost:3000 ✓ Starting... Downloading swc package @next/swc-darwin-arm64... ✓ Ready in 3.7s ○ Compiling / ... 🌼 daisyUI 4.12.10 ├─ ✔︎ 2 themes added https://daisyui.com/docs/themes ╰─ ★ Star daisyUI on GitHub https://github.com/saadeghi/daisyui ✓ Compiled / in 10.8s (7727 modules) GET / 200 in 11353ms HEAD / 200 in 31ms
This will launch the React-based DApp frontend at `http://localhost:3000/` by default. You can then point your browser to `http://localhost:3000/` and interact with the React frontend by connecting your wallet or checking out the contract debugger page. ![The frontend of the DApp on the browser.](/images/builders/ethereum/dev-env/scaffold-eth/new/scaffold-eth-1.webp) And that's it! Now that you have the basics down, feel free to create and deploy your own smart contracts and modify the frontend to fit your dApp's needs! For more information, you can check out the [Scaffold-ETH 2 docs](https://docs.scaffoldeth.io){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/ethereum/dev-env/tenderly/ --- BEGIN CONTENT --- --- title: Tenderly Development Platform description: Learn how to use Tenderly, an Ethereum development platform, to build, debug, and monitor Solidity smart contracts on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using Tenderly on Moonbeam ## Introduction {: #introduction } [Tenderly](https://tenderly.co){target=\_blank} is a Web3 development platform that contains a suite of tools designed to help developers throughout the DApp development life cycle. With Tenderly, you can build, debug, test, optimize, monitor, set up alerts, and view analytics for your smart contracts on Moonbeam and Moonriver. The Tenderly platform provides the following features: - **[Contract Verification](https://docs.tenderly.co/contract-verification){target=\_blank}** - as it is essential to verify your smart contracts to take full advantage of all of Tenderly's features, Tenderly provides several methods of verification. You can verify smart contracts through [the Tenderly dashboard](https://docs.tenderly.co/contract-verification/dashboard){target=\_blank}, [the Tenderly CLI and Foundry](https://docs.tenderly.co/contract-verification/foundry){target=\_blank}, or [the Tenderly Hardhat plugin](https://docs.tenderly.co/contract-verification/hardhat){target=\_blank} - **[Debugger](https://docs.tenderly.co/debugger){target=\_blank}** - use the visual debugger to inspect transactions and get better insight into the behavior of your code. With the debugger, you can review a transaction's stack trace, view the calls made in a transaction, step through a contract, and review decoded inputs, outputs, and state variables. You can use the debugger on the Tenderly dashboard or the [Tenderly Debugger Chrome Extension](https://docs.tenderly.co/debugger/dev-toolkit-browser-extension){target=\_blank} - **[Gas Profiler](https://docs.tenderly.co/debugger/gas-profiler){target=\_blank}** - view how much gas you're spending on a granular level, so you can optimize your smart contracts and reduce transaction gas costs - **[Simulator](https://docs.tenderly.co/simulator-ui){target=\_blank}** - simulate transactions in a TestNet development environment to learn how your transactions will behave without having to send them on-chain. This way, you can know the transaction's outcome and ensure it works as expected before sending it to the network. You can experiment with different parameters, simulate historical and current transactions, and edit the contract source code. You can access the simulator from the Tenderly dashboard, or you can use the [Tenderly Simulation API](https://docs.tenderly.co/reference/api#tag/Simulations){target=\_blank} to take advantage of the simulator programmatically - **[Virtual TestNets](https://docs.tenderly.co/virtual-testnets){target=\_blank}** - simulate the live Moonbeam network in an isolated environment to interact with deployed contracts and real-time on-chain data. These test environments enable controlled development, testing, and debugging across smart contracts, UI, backend, and data indexing. They support sequential transaction simulations for complex scenarios. There are some limitations to be aware of when using this feature. [Moonbeam precompiled contracts](/builders/ethereum/precompiles/overview){target=\_blank} are not supported, as they are part of the Substrate implementation and cannot be replicated in the simulated EVM environment, prohibiting you from interacting with cross-chain assets, staking, and governance. - **[Alerting](https://docs.tenderly.co/alerts/intro-to-alerts){target=\_blank}** - configure real-time alerts to notify you whenever a specific event occurs, allowing you to stay informed about what's going on with your smart contracts - **[Web3 Actions](https://docs.tenderly.co/web3-actions/intro-to-web3-actions){target=\_blank}** - create programmable functions in JavaScript or TypeScript that are executed automatically by Tenderly when a specific smart contract or chain event occurs !!! note Tenderly supports Moonbeam, Moonriver, and Moonbase Alpha, except for the Web3 Gateway. For more information, check out Tenderly's documentation on [Supported Networks](https://docs.tenderly.co/supported-networks#supported-networks){target=\_blank}. ## Getting Started The Tenderly dashboard provides access to an all-in-one Web3 development platform. To get started with the dashboard, you'll need to [sign up](https://dashboard.tenderly.co/register){target=\_blank} for an account. Once you've signed up, you'll be able to start exploring your Tenderly dashboard. ![Tenderly dashboard](/images/builders/ethereum/dev-env/tenderly/tenderly-1.webp) If you prefer not to set up an account, you can also access limited features using [Tenderly's explorer](https://dashboard.tenderly.co/explorer){target=\_blank}. Without an account, you can still gain insights into contracts and transactions. However, you won't be able to simulate transactions or create Virtual TestNets. To interact with Tenderly's features programmatically, you can check out the [Tenderly CLI](https://github.com/Tenderly/tenderly-cli){target=\_blank} GitHub repository for more information. The following sections will show you how to get started with Tenderly on Moonbeam. For more detailed documentation, please refer to [Tenderly's documentation site](https://docs.tenderly.co){target=\_blank}. ### Add a Contract {: #add-a-contract } A good place to start with the Tenderly dashboard is to add a deployed smart contract. Once you've added a contract, you'll be able to create transaction simulations and Virtual TestNets, use the debugger, set up monitoring and alerts, and more. To add a new contract, you can click on **Contracts** on the left-side panel and click **Add Contract**. A pop-up will appear, and you can take the following steps: 1. Enter the contract address 2. (Optional) You can give your contract a name 3. Choose **Moonbeam**, **Moonriver**, or **Moonbase Alpha** as the network, depending on which network you've deployed your smart contract to 4. (Optional) Toggle the **Add more** slider to add additional contracts after the initial one 5. Finally, to add the contract to the dashboard, click **Save** ![Add a contract](/images/builders/ethereum/dev-env/tenderly/tenderly-2.webp) After a contract has been added, it will appear in the list of contracts on the **Contracts** dashboard. If the contract hasn't been verified yet, the dashboard will display an **Unverified** status along with a **Verify** button. ![Contract in list of contracts](/images/builders/ethereum/dev-env/tenderly/tenderly-3.webp) To take full advantage of the Tenderly tool set, it is recommended that you verify your smart contracts, which you can do by clicking on **Verify**. You can choose to verify your contract by uploading the contract's JSON, ABI, or source code. For more information, please refer to Tenderly's documentation on [Smart Contract Verification](https://docs.tenderly.co/contract-verification#verifying-a-smart-contract){target=\_blank}. ### Create a Virtual TestNet {: #virtual-testnets-moonbeam } Tenderly's Virtual TestNets feature simulates the live Moonbeam network in an isolated environment, which enables you to interact with deployed contracts and live on-chain data. There are some limitations to be aware of when using this feature. You cannot interact with any of the [Moonbeam precompiled contracts](/builders/ethereum/precompiles/){target=\_blank} and their functions. Precompiles are a part of the Substrate implementation and, therefore, cannot be replicated in the simulated EVM environment. This prohibits you from interacting with cross-chain assets on Moonbeam and Substrate-based functionality such as staking and governance. Tenderly makes creating a TestNet through the dashboard quite simple. To get started, click on **Virtual TestNets** on the left-side menu and then click **Create Virtual TestNet**. From there, you can take the following steps: 1. Select **Moonbeam**, **Moonriver**, or **Moonbase Alpha** from the **Parent network** dropdown 2. (Optional) Give your TestNet a name 3. Select your **Chain ID**; you can use a custom one or the original network ID. It is recommended to set a custom Chain ID to prevent replay attacks and avoid issues when adding the Virtual TestNet to wallets 4. Choose whether to turn on or off the **Public Explorer** 5. Enable **State Sync** if you want to keep your Virtual TestNet updated in real-time with the parent network 6. To limit data, disable **Use latest block** and enter a block number, or keep it enabled to include all blocks 7. Click **Create** ![Virtual TestNet Moonbeam](/images/builders/ethereum/dev-env/tenderly/tenderly-4.webp) Once you've created your Virtual TestNet, you can start using it by deploying a contract or creating a transaction simulation. To deploy a contract, go to Contracts in the left menu. Use one from **Watched Contracts** or add a new one via **Watch Contract**. Once added, it will appear in **Contracts**, where you can view its details. To create a simulation, click the **Simulation** button and enter the configurations for the simulation. For more information on simulations, please refer to Tenderly's [Simulator UI Overview](https://docs.tenderly.co/simulator-ui/using-simulation-ui){target=\_blank} documentation. ![TestNet simulations](/images/builders/ethereum/dev-env/tenderly/tenderly-5.webp) Now that you've learned how to get started with a few of Tenderly's features on Moonbeam, please feel free to dive in and check out the other tools available in their development platform. You can visit [Tenderly's documentation site](https://docs.tenderly.co){target=\_blank} for more information. You can also check out Moonbeam's tutorial on [Using Tenderly to Simulate and Debug Transactions](/tutorials/eth-api/using-tenderly/){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/ethereum/dev-env/thirdweb/ --- BEGIN CONTENT --- --- title: How to use thirdweb description: This guide will show you some of thirdweb's features, including building, testing, and deploying smart contract templates to launch dApps on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using thirdweb on Moonbeam ## Introduction {: #introduction } [thirdweb](https://thirdweb.com){target=\_blank} is a complete Web3 development framework that provides everything you need to develop smart contracts, build dApps, and more. With thirdweb, you can access tools to help you through every phase of the dApp development cycle. You can create your own custom smart contracts or use any of thirdweb's prebuilt contracts to get started quickly. From there, you can use thirdweb's CLI to deploy your smart contracts. Then you can interact with your smart contracts by creating a Web3 application using the language of your choice, including but not limited to React and TypeScript. This guide will show you some of the thirdweb features you can use to develop smart contracts and dApps on Moonbeam. To check out all of the features thirdweb has to offer, please refer to the [thirdweb documentation site](https://portal.thirdweb.com){target=\_blank}. For a comprehensive step-by-step tutorial for building a dApp on Moonbeam with thirdweb, be sure to check out Moonbeam's [thirdweb tutorial in the tutorials section](/tutorials/eth-api/thirdweb/). ## Create Contract {: #create-contract } To create a new smart contract using the [thirdweb CLI](https://portal.thirdweb.com/cli){target=\_blank}, follow these steps: 1. In your CLI, run the following command: ```bash npx thirdweb create contract ``` 2. Input your preferences for the command line prompts: 1. Give your project a name 2. Choose your preferred framework: **Hardhat** or **Foundry** 3. Name your smart contract 4. Choose the type of base contract: **Empty**, [**ERC20**](https://portal.thirdweb.com/tokens/build/base-contracts/erc-20/base){target=\_blank}, [**ERC721**](https://portal.thirdweb.com/tokens/build/base-contracts/erc-721/base){target=\_blank}, or [**ERC1155**](https://portal.thirdweb.com/tokens/build/base-contracts/erc-1155/base){target=\_blank} 5. Add any desired [extensions](https://portal.thirdweb.com/tokens/build/extensions){target=\_blank} 3. Once created, navigate to your project’s directory and open in your preferred code editor 4. If you open the `contracts` folder, you will find your smart contract; this is your smart contract written in Solidity The following is code for an `ERC721Base` contract without specified extensions. It implements all of the logic inside the [`ERC721Base.sol`](https://github.com/thirdweb-dev/contracts/blob/main/contracts/base/ERC721Base.sol){target=\_blank} contract; which implements the [`ERC721A`](https://github.com/thirdweb-dev/contracts/blob/main/contracts/eip/ERC721A.sol){target=\_blank} standard. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@thirdweb-dev/contracts/base/ERC721Base.sol'; contract Contract is ERC721Base { constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps ) ERC721Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {} } ``` This contract inherits the functionality of `ERC721Base` through the following steps: - Importing the `ERC721Base` contract - Inheriting the contract by declaring that your contract is an `ERC721Base` contract - Implementing any required methods, such as the constructor 5. After modifying your contract with your desired custom logic, you can deploy it to Moonbeam. That will be covered in the next section! Alternatively, you can deploy a prebuilt contract for NFTs, tokens, or marketplace directly from the thirdweb Explore page: 1. Go to the [thirdweb Explore page](https://thirdweb.com/explore){target=\_blank} ![thirdweb Explore](/images/builders/ethereum/dev-env/thirdweb/thirdweb-1.webp) 2. Choose the type of contract you want to deploy from the available options: NFTs, tokens, marketplace, and more 3. Follow the on-screen prompts to configure and deploy your contract For more information on different contracts available on Explore, check out [thirdweb’s documentation on prebuilt contracts](https://portal.thirdweb.com/contracts){target=\_blank}. ## Deploy a Contract {: #deploy-contract } thirdweb allows you to easily deploy a smart contract to any EVM compatible network without configuring RPC URLs, exposing your private keys, writing scripts, and other additional setup such as verifying your contract. 1. To deploy your smart contract using the CLI, navigate to the `contracts` directory of your project and execute the following command: ```bash npx thirdweb deploy ``` Executing this command will trigger the following actions: - Compiling all the contracts in the current directory - Providing the option to select which contract(s) you wish to deploy - Uploading your contract source code (ABI) to IPFS 2. When it is completed, it will open a dashboard interface to finish filling out the parameters - `_name` - contract name - `_symbol` - symbol or "ticker" - `_royaltyRecipient` - wallet address to receive royalties from secondary sales - `_royaltyBps` - basis points (bps) that will be given to the royalty recipient for each secondary sale, e.g. 500 = 5% 3. Select the desired Moonbeam network, e.g., Moonbeam, Moonriver, or Moonbase Alpha 4. Manage additional settings on your contract’s dashboard as needed such as uploading NFTs, configuring permissions, and more ![thirdweb deploy](/images/builders/ethereum/dev-env/thirdweb/thirdweb-2.webp) For additional information on deploying contracts, please reference [thirdweb’s documentation](https://portal.thirdweb.com/contracts/deploy){target=\_blank}. ## Create Application {: #create-application } thirdweb offers SDKs for a range of programming languages, such as React, React Native, TypeScript, and Unity. You'll start off by creating an application and then you can choose which SDK to use: 1. In your CLI run the following command: ```bash npx thirdweb create --app ``` 2. Input your preferences for the command line prompts: 1. Give your project a name 2. Choose your preferred framework: **Next.js**, **Vite**, or **React Native**. For this example, select **Vite** 3. Use the React or TypeScript SDK to interact with your application’s functions. This will be covered in the following section on interacting with a contract ### Specify Client ID {: #specify-client-id } Before you launch your dApp (locally or publicly deployed), you must have a thirdweb Client ID associated with your project. A thirdweb Client ID is synonymous with an API key. You can create a free API key by [signing into your thirdweb account, navigating to **Settings**, and clicking on **API Keys**](https://thirdweb.com/dashboard/settings/api-keys){target=\_blank}. Press **Create API Key** then take the following steps: 1. Give your API key a name 2. Enter the allowed domains that the API key should accept requests from. It's recommended that you allow only necessary domains, but for development purposes, you can select **Allow all domains** 3. Press **Next** and confirm the prompt on the next page ![thirdweb create API key](/images/builders/ethereum/dev-env/thirdweb/thirdweb-3.webp) !!! note The respective name for your Client ID variable will vary with the framework you've chosen, e.g., Vite will be `VITE_TEMPLATE_CLIENT_ID`, Next.js will be `NEXT_PUBLIC_TEMPLATE_CLIENT_ID`, and React Native will be `EXPO_PUBLIC_THIRDWEB_CLIENT_ID`. Finally, specify your Client ID (API Key) in your `.env` file. Your `.env` file must be located at the root directory of the project (e.g., not the `src` folder). If you generated your thirdweb app with Vite, you'll have a `client.ts` file that looks like the below. As long you've created a `.env` file with your thirdweb API Key (Client ID) defined in `VITE_TEMPLATE_CLIENT_ID`, you can leave the `client.ts` as is and proceed to the next section. ```typescript title="client.ts" import { createThirdwebClient } from 'thirdweb'; // Replace this with your client ID string. // Refer to https://portal.thirdweb.com/typescript/v5/client on how to get a client ID const clientId = import.meta.env.VITE_TEMPLATE_CLIENT_ID; export const client = createThirdwebClient({ clientId: clientId, }); ``` !!! note If you don't create a Client ID and specify is correctly in your `.env` file, you'll get a blank screen when trying to build the web app. There is no error message shown without digging into the console, so ensure you've set your Client ID correctly first and foremost. ### Run Locally {: #run-locally } To run your dApp locally for testing and debugging purposes, use the command: ```bash yarn dev ``` The app will compile and specify the localhost and port number for you to visit in your browser. ![thirdweb run locally](/images/builders/ethereum/dev-env/thirdweb/thirdweb-4.webp) ### Configure Chain {: #configure-chain } thirdweb offers a small number of chains from `@thirdweb/chains` and does not include Moonbeam networks in that list, so you'll need to specify the network details including chain ID and RPC URL. You can create a custom chain with [`defineChain`](https://portal.thirdweb.com/references/typescript/v5/defineChain){target=\_blank} as follows: === "Moonbeam" ```typescript title="chains.ts" import { defineChain } from 'thirdweb'; const moonbeam = defineChain({ id: {{ networks.moonbeam.chain_id }}, rpc: '{{ networks.moonbeam.public_rpc_url }}', }); ``` === "Moonriver" ```typescript title="chains.ts" import { defineChain } from 'thirdweb'; const moonriver = defineChain({ id: {{ networks.moonriver.chain_id }}, rpc: '{{ networks.moonriver.public_rpc_url }}', }); ``` === "Moonbase Alpha" ```typescript title="chains.ts" import { defineChain } from 'thirdweb'; const moonbase = defineChain({ id: {{ networks.moonbase.chain_id }}, rpc: '{{ networks.moonbase.rpc_url }}', }); ``` ## thirdweb SDK {: #thirdweb-sdk } The following sections will provide an overview of fundamental methods of the thirdweb SDK and how to interact with them. Each code snippet will showcase the relevant import statements and demonstrate using the method in a typical scenario. This guide is intended to be a quick reference guide to the most common thirdweb methods that dApp developers will use. However, it does not include information on each and every thirdweb offering. For details on the entirety of thirdweb's offerings, be sure to visit the [thirdweb documentation site](https://portal.thirdweb.com/){target=\_blank}. For a comprehensive, step-by-step guide to building a dApp with thirdweb be sure to check out Moonbeam's [thirdweb tutorial in the tutorials section](/tutorials/eth-api/thirdweb/). The following sections will cover everything from connecting wallets, to preparing transactions, and more. ### Accounts and Wallets {: #accounts-and-wallets } thirdweb distinguishes between accounts and wallets in the SDK. In the eyes of the thirdweb SDK, an account always has a single blockchain address and can sign messages, transactions, and typed data, but it cannot be "connected" or "disconnected." In contrast, a wallet contains one or more accounts, can be connected or disconnected, and delegates the signing tasks to its accounts. The below code snippet demonstrates how to initialize and connect a MetaMask wallet using the thirdweb SDK, then sign and send a transaction, retrieving the transaction hash. This process is applicable to any of the 300+ wallet connectors supported by the SDK. ???+ code "initialize.ts" ```typescript import { sendTransaction } from 'thirdweb'; // MetaMask wallet used for example, the pattern is the same for all wallets import { createWallet } from 'thirdweb/wallets'; // Initialize the wallet. thirdweb supports 300+ wallet connectors const wallet = createWallet('io.metamask'); // Connect the wallet. This returns a promise that resolves to the connected account const account = await wallet.connect({ // Pass the client you created with `createThirdwebClient()` client, }); // Sign and send a transaction with the account. Returns the transaction hash const { transactionHash } = await sendTransaction({ // Assuming you have called `prepareTransaction()` or `prepareContractCall()` before, which returns the prepared transaction to send transaction, // Pass the account to sign the transaction with account, }); ``` ### Get Contract {: #get-contract } To connect to your contract, use the SDK’s [`getContract`](https://portal.thirdweb.com/references/typescript/v5/getContract){target=\_blank} method. As an example, you could fetch data from an [incrementer contract on Moonbase Alpha](https://moonbase.moonscan.io/address/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8){target=\_blank}. ```typescript import { getContract } from 'thirdweb'; import { client } from './client'; const myContract = getContract({ client, chain: moonbase, address: 0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8, // Incrementer contract address on Moonbase Alpha abi: '[{"inputs":[],"name":"increment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"number","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]'; }); ``` ### Calling Contract Functions {: #calling-contract-functions } To call a contract in the latest version of the SDK, you can use [`prepareContractCall`](https://portal.thirdweb.com/typescript/v5/transactions/prepare){target=\_blank}. ```typescript import { prepareContractCall, toWei } from 'thirdweb'; const tx = prepareContractCall({ contract, // Pass the method signature that you want to call method: 'function mintTo(address to, uint256 amount)', // Pass the params for that method. // Their types are automatically inferred based on the method signature params: ['0x123...', toWei('100')], }); ``` Returning to our [incrementer contract](https://moonbase.moonscan.io/address/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8){target=\_blank}, preparing a call to increment the contract looks like the following: ```typescript import { prepareContractCall } from 'thirdweb'; const tx = prepareContractCall({ contract, // Pass the method signature that you want to call method: 'function increment()', // Increment takes no params so we are leaving an empty array params: [], }); ``` ### Preparing Raw Transactions {: #preparing-raw-transactions } You can also prepare a transaction directly with encoded data. To do so, you'll use thirdweb's [`prepareTransaction` method](https://portal.thirdweb.com/typescript/v5/transactions/prepare){target=\_blank} and specify the `to`, `value`, `chain`, and `client` values directly. ```typescript import { prepareTransaction, toWei } from 'thirdweb'; const transaction = prepareTransaction({ // The account that will be the receiver to: '0x456...', // The value is the amount of ether you want to send with the transaction value: toWei('1'), // The chain to execute the transaction on. This assumes you already set up // moonbase as a custom chain as shown in the configure chain section chain: moonbase, // Your thirdweb client client, }); ``` ### Reading Contract State {: #read-contract-state } Use the [`readContract` function](https://portal.thirdweb.com/typescript/v5/transactions/read){target=\_blank} to call any read functions on your contract by passing in the Solidity method signature and any parameters. ```typescript import { readContract } from 'thirdweb'; const balance = await readContract({ contract: contract, method: 'function balanceOf(address) view returns (uint256)', params: ['0x123...'], }); ``` For a function that takes no parameters, such as the number function that returns the current number stored in the [incrementer contract](https://moonbase.moonscan.io/address/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8){target=\_blank}, you simply need to provide the function name as follows: ```typescript import { readContract } from 'thirdweb'; const number = await readContract({ contract: contract, method: 'number', params: [], }); ``` Did you know? With the [thirdweb CLI](https://portal.thirdweb.com/cli){target=\_blank}, you can easily and generate functions for all of the possible calls to a contract. To do so, run the following command in the command line: ```bash npx thirdweb generate INSERT_CHAIN_ID/INSERT_CONTRACT_ADDRESS ``` Both the chain ID and the contract address are required. As an example, if you wanted to generate the functions for the [incrementer contract on Moonbase Alpha](https://moonbase.moonscan.io/address/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8){target=\_blank} , you would use the following command: ```bash npx thirdweb generate 1287/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8 ``` The file generated with all of the corresponding methods will be placed in a directory labelled `thirdweb/CHAIN_ID/CONTRACT_ADDRESS`. In the example shown above, the output file is located at `thirdweb/1287/0xa72f549a1a12b9b49f30a7f3aeb1f4e96389c5d8.ts`. For more information, see the [thirdweb's docs on the CLI](https://portal.thirdweb.com/cli/generate){target=\_blank}. ### Sending a Transaction {: #sending-a-transaction } Every transaction sent using the SDK must first be prepared. This preparation process is synchronous and lightweight, requiring no network requests. Additionally, it provides type-safe definitions for your contract calls. You can prepare a transaction as follows: ```typescript title="Prepare a transaction" import { prepareTransaction, toWei } from 'thirdweb'; const transaction = prepareTransaction({ to: '0x1234567890123456789012345678901234567890', chain: moonbase, client: thirdwebClient, value: toWei('1.0'), gasPrice: 150n, }); ``` After the transaction is prepared, you can send it as follows: ```typescript title="Send a transaction" import { sendTransaction } from 'thirdweb'; const { transactionHash } = await sendTransaction({ account, transaction, }); ``` You can optionally use `sendAndConfirmTransaction` to wait for the transaction to be mined. This is relevant if you want to block the user from continuing until the transaction is confirmed. ```typescript title="Send and Confirm a Transaction" import { sendAndConfirmTransaction } from 'thirdweb'; import { createWallet } from 'thirdweb/wallets'; const wallet = createWallet('io.metamask'); const account = await wallet.connect({ client }); const receipt = await sendAndConfirmTransaction({ transaction, account, }); ``` ### Transaction Utilities {: #transaction-utilities } thirdweb provides a number of helpful utility methods surrounding preparing and sending transactions. You can estimate the gas used by a transaction as follows: ```typescript title="Estimating gas" import { estimateGas } from 'thirdweb'; const gasEstimate = await estimateGas({ transaction }); console.log('estmated gas used', gasEstimate); ``` You can estimate the gas cost in Ether and Wei as follows: ```typescript title="Estimating gas cost" import { estimateGas } from 'thirdweb'; const gasCost = await estimateGasCost({ transaction }); console.log('cost in ether', gasCost.ether); ``` thirdweb also provides a handy way to simulate transactions and verify their integrity before actually submitting it to the blockchain. You can simulate a transaction as follows: ```typescript title="Simulate a transaction" import { simulateTransaction } from 'thirdweb'; const result = await simulateTransaction({ transaction }); console.log('simulation result', result); ``` You can encode transaction data to act on later by taking the following steps: ```typescript title="Encode transaction data" import { encode } from 'thirdweb'; const data = await encode(transaction); console.log('encoded data', data); ``` ### ConnectButton {: #connect-button } Perhaps the first and most important interaction users will have with your dApp is connecting their wallet. thirdweb provides an easy and highly customizable way for you to enable this. thirdweb provides a highly customizable [`ConnectButton`](https://portal.thirdweb.com/react/v5/components/ConnectButton){target=\_blank} to tailor it to your desired wallets. The `ConnectButton` accepts an optional `wallets` parameter with an array of wallets. You can add or remove wallets from the `wallets` array to change the options available to users. thirdweb also offers a [`ConnectButton` Playground](https://thirdweb.com/dashboard/connect/playground){target=\_blank} to customize and view changes for the `ConnectButton` in real-time, given the button's high degree of flexibility. ```typescript title="ConnectButton" import { ConnectButton } from 'thirdweb/react'; import { createWallet, inAppWallet } from 'thirdweb/wallets'; const wallets = [ inAppWallet(), createWallet('io.metamask'), createWallet('com.coinbase.wallet'), createWallet('me.rainbow'), ]; function Example() { return (
); } ``` ## Deploy Application {: #deploy-application } As a reminder, you can build your example project locally by running: ```bash yarn dev ``` To host your static web application on decentralized storage, run: ```bash npx thirdweb deploy --app ``` By running this command, your application is built for production and stored using [Storage](https://portal.thirdweb.com/infrastructure/storage/overview){target=\_blank}, thirdweb's decentralized file management solution. The built application is uploaded to IPFS, a decentralized storage network, and a unique URL is generated for your application. This URL serves as a permanent hosting location for your application on the web. If you have any further questions or encounter any issues during the process, please reach out to thirdweb support at [support.thirdweb.com](http://support.thirdweb.com){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/ethereum/dev-env/waffle-mars/ --- BEGIN CONTENT --- --- title: Deploy Smart Contracts with Waffle & Mars description: Learn how to use Waffle and Mars to write, compile, test, and deploy Ethereum smart contracts on Moonbeam. categories: Dev Environments, Ethereum Toolkit --- # Using Waffle & Mars to Deploy to Moonbeam ## Introduction {: #introduction } [Waffle](https://getwaffle.io){target=\_blank} is a library for compiling and testing smart contracts, and [Mars](https://github.com/TrueFiEng/Mars){target=\_blank} is a deployment manager. Together, Waffle and Mars can be used to write, compile, test, and deploy Ethereum smart contracts. Since Moonbeam is Ethereum compatible, Waffle and Mars can be used to deploy smart contracts to a [Moonbeam development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} or the [Moonbase Alpha TestNet](/builders/get-started/networks/moonbase/){target=\_blank}. Waffle uses minimal dependencies, has syntax that is easy to learn and extend, and provides fast execution times when compiling and testing smart contracts. Furthermore, it is [TypeScript](https://www.typescriptlang.org){target=\_blank} compatible and uses [Chai matchers](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html){target=\_blank} to make tests easy to read and write. Mars provides a simple, TypeScript compatible framework for creating advanced deployment scripts and staying in sync with state changes. Mars focuses on infrastructure-as-code, allowing developers to specify how their smart contracts should be deployed and then using those specifications to automatically handle state changes and deployments. In this guide, you'll be creating a TypeScript project to write, compile, and test a smart contract using Waffle, then deploy it on to the Moonbase Alpha TestNet using Mars. ## Checking Prerequisites {: #checking-prerequisites } You will need to have the following: - MetaMask installed and [connected to Moonbase Alpha](/tokens/connect/metamask/){target=\_blank} - An account with funds. 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} - 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} Once you've created an account you'll need to export the private key to be used in this guide. ## Create a TypeScript Project with Waffle & Mars {: #create-a-typescript-project-with-waffle-mars } To get started, you'll create a TypeScript project and install and configure a few dependencies. 1. Create the project directory and change to it: ```bash mkdir waffle-mars && cd waffle-mars ``` 2. Initialize the project. Which will create a `package.json` in the directory: ```bash npm init -y ``` 3. Install the following dependencies: ```bash npm install ethereum-waffle ethereum-mars ethers \ @openzeppelin/contracts typescript ts-node chai \ @types/chai mocha @types/mocha ``` - [Waffle](https://github.com/TrueFiEng/Waffle) - for writing, compiling, and testing smart contracts - [Mars](https://github.com/TrueFiEng/Mars) - for deploying smart contracts to Moonbeam - [Ethers](https://github.com/ethers-io/ethers.js) - for interacting with Moonbeam's Ethereum API - [OpenZeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) - the contract you'll be creating will use OpenZeppelin's ERC-20 base implementation - [TypeScript](https://github.com/microsoft/TypeScript) - the project will be a TypeScript project - [TS Node](https://github.com/TypeStrong/ts-node) - for executing the deployment script you'll create later in this guide - [Chai](https://github.com/chaijs/chai) - an assertion library used alongside Waffle for writing tests - [@types/chai](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/chai) - contains the type definitions for chai - [Mocha](https://github.com/mochajs/mocha) - a testing framework for writing tests alongside Waffle - [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) - contains the type definitions for mocha 4. Create a [TypeScript configuration](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) file: ```bash touch tsconfig.json ``` 5. Add a basic TypeScript configuration: ```json { "compilerOptions": { "strict": true, "target": "ES2019", "moduleResolution": "node", "resolveJsonModule": true, "esModuleInterop": true, "module": "CommonJS", "composite": true, "sourceMap": true, "declaration": true, "noEmit": true } } ``` Now, you should have a basic TypeScript project with the necessary dependencies to get started building with Waffle and Mars. ## Add a Contract {: #add-a-contract } For this guide, you will create an ERC-20 contract that mints a specified amount of tokens to the contract creator. It's based on the OpenZeppelin ERC-20 template. 1. Create a directory to store your contracts and a file for the smart contract: ```bash mkdir contracts && cd contracts && touch MyToken.sol ``` 2. Add the following contract to `MyToken.sol`: ```solidity pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor() ERC20("MyToken", "MYTOK") {} function initialize(uint initialSupply) public { _mint(msg.sender, initialSupply); } } ``` In this contract, you are creating an ERC-20 token called MyToken with the symbol MYTOK, that allows you, as the contract creator, to mint as many MYTOKs as desired. ## Use Waffle to Compile and Test {: #use-waffle-to-compile-and-test } ### Compile with Waffle {: #compile-with-waffle } Now that you have written a smart contract, the next step is to use Waffle to compile it. Before diving into compiling your contract, you will need to configure Waffle: 1. Go back to the root project directory and create a `waffle.json` file to configure Waffle: ```bash cd .. && touch waffle.json ``` 2. Edit the `waffle.json` to specify compiler configurations, the directory containing your contracts, and more. For this example, we'll use `solcjs` and the Solidity version you used for the contract, which is `0.8.0`: ```json { "compilerType": "solcjs", "compilerVersion": "0.8.0", "compilerOptions": { "optimizer": { "enabled": true, "runs": 20000 } }, "sourceDirectory": "./contracts", "outputDirectory": "./build", "typechainEnabled": true } ``` 3. Add a script to run Waffle in the `package.json`: ```json "scripts": { "build": "waffle" }, ``` That is all you need to do to configure Waffle, now you're all set to compile the `MyToken` contract using the `build` script: ```bash npm run build ```
npm run build >waffle-mars@1.0.0 build >waffle Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: «SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. --> contracts/MyToken.sol
After compiling your contracts, Waffle stores the JSON output in the `build` directory. Since the contract in this guide is based on OpenZeppelin's ERC-20 template, relevant ERC-20 JSON files will appear in the `build` directory too. ### Test with Waffle {: #test-with-waffle } Before deploying your contract and sending it off into the wild, you should test it first. Waffle provides an advanced testing framework and has plenty of tools to help you with testing. You'll be running tests against the Moonbase Alpha TestNet and will need the corresponding RPC URL to connect to it: `{{ networks.moonbase.rpc_url }}`. To configure your project for 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}. Since you will be running tests against the TestNet, it might take a couple minutes to run all of the tests. If you want a more efficient testing experience, you can [spin up a Moonbeam development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank} using [`instant seal`](/builders/get-started/networks/moonbeam-dev/#node-options){target=\_blank}. Running a local Moonbeam development node with the `instant seal` feature is similar to the quick and iterative experience you would get with [Hardhat Network](https://hardhat.org/hardhat-network/docs/overview){target=\_blank}. 1. Create a directory to contain your tests and a file to test your `MyToken` contract: ```bash mkdir test && cd test && touch MyToken.test.ts ``` 2. Open the `MyToken.test.ts` file and setup your test file to use Waffle's Solidity plugin and use Ethers custom JSON-RPC provider to connect to Moonbase Alpha: ```typescript import { use, expect } from 'chai'; import { Provider } from '@ethersproject/providers'; import { solidity } from 'ethereum-waffle'; import { ethers, Wallet } from 'ethers'; import { MyToken, MyTokenFactory } from '../build/types'; // Tell Chai to use Waffle's Solidity plugin use(solidity); describe ('MyToken', () => { // Use custom provider to connect to Moonbase Alpha let provider: Provider = new ethers.providers.JsonRpcProvider( '{{ networks.moonbase.rpc_url }}' ); let wallet: Wallet; let walletTo: Wallet; let token: MyToken; beforeEach(async () => { // Logic for setting up the wallet and deploying MyToken will go here }); // Tests will go here }) ``` 3. Before each test is run, you'll want to create wallets and connect them to the provider, use the wallets to deploy an instance of the `MyToken` contract, and then call the `initialize` function once with an initial supply of 10 tokens: ```typescript beforeEach(async () => { // This is for demo purposes only. Never store your private key in a JavaScript/TypeScript file const privateKey = 'INSERT_PRIVATE_KEY' // Create a wallet instance using your private key & connect it to the provider wallet = new Wallet(privateKey).connect(provider); // Create a random account to transfer tokens to & connect it to the provider walletTo = Wallet.createRandom().connect(provider); // Use your wallet to deploy the MyToken contract token = await new MyTokenFactory(wallet).deploy(); // Mint 10 tokens to the contract owner, which is you let contractTransaction = await token.initialize(10); // Wait until the transaction is confirmed before running tests await contractTransaction.wait(); }); ``` 4. Now you can create your first test. The first test will check your initial balance to ensure you received the initial supply of 10 tokens. However, to follow good testing practices, write a failing test first: ```typescript it('Mints the correct initial balance', async () => { expect(await token.balanceOf(wallet.address)).to.equal(1); // This should fail }); ``` 5. Before you can run your first test, you'll need to go back to the root direction and add a `.mocharc.json` Mocha configuration file: ```bash cd .. && touch .mocharc.json ``` 6. Now edit the `.mocharc.json` file to configure Mocha: ```json { "require": "ts-node/register/transpile-only", "timeout": 600000, "extension": "test.ts" } ``` 7. You'll also need to add a script in the `package.json` to run your tests: ```json "scripts": { "build": "waffle", "test": "mocha" }, ``` 8. You're all set to run the tests, simply use the `test` script you just created and run: ```bash npm run test ``` Please note that it could take a few minutes to process because the tests are running against Moonbase Alpha, but if all worked as expected, you should have one failing test. 9. Next, you can go back and edit the test to check for 10 tokens: ```typescript it('Mints the correct initial balance', async () => { expect(await token.balanceOf(wallet.address)).to.equal(10); // This should pass }); ``` 10. If you run the tests again, you should now see one passing test: ```bash npm run test ``` 11. You've tested the ability to mint tokens, next you'll test the ability to transfer the minted tokens. If you want to write a failing test first again that is up to, however the final test should look like this: ```typescript it('Should transfer the correct amount of tokens to the destination account', async () => { // Send the destination wallet 7 tokens await (await token.transfer(walletTo.address, 7)).wait(); // Expect the destination wallet to have received the 7 tokens expect(await token.balanceOf(walletTo.address)).to.equal(7); }); ``` Congratulations, you should now have two passing tests! Altogether, your test file should look like this: ```typescript import { use, expect } from 'chai'; import { Provider } from '@ethersproject/providers'; import { solidity } from 'ethereum-waffle'; import { ethers, Wallet } from 'ethers'; import { MyToken, MyTokenFactory } from '../build/types'; use(solidity); describe('MyToken', () => { let provider: Provider = new ethers.providers.JsonRpcProvider( '{{ networks.moonbase.rpc_url }}' ); let wallet: Wallet; let walletTo: Wallet; let token: MyToken; beforeEach(async () => { // For demo purposes only. Never store your private key in a JavaScript/TypeScript file const privateKey = 'INSERT_PRIVATE_KEY'; wallet = new Wallet(privateKey).connect(provider); walletTo = Wallet.createRandom().connect(provider); token = await new MyTokenFactory(wallet).deploy(); let contractTransaction = await token.initialize(10); await contractTransaction.wait(); }); it('Mints the correct initial balance', async () => { expect(await token.balanceOf(wallet.address)).to.equal(10); }); it('Should transfer the correct amount of tokens to the destination account', async () => { await (await token.transfer(walletTo.address, 7)).wait(); expect(await token.balanceOf(walletTo.address)).to.equal(7); }); }); ``` If you want to write more tests on your own, you could consider testing transfers from accounts without any funds or transfers from accounts without enough funds. ## Use Mars to Deploy to Moonbase Alpha {: #use-mars-to-deploy-to-moonbase-alpha } After you compile your contracts and before deployment, you will have to generate contract artifacts for Mars. Mars uses the contract artifacts for typechecks in deployments. Then you'll need to create a deployment script and deploy the `MyToken` smart contract. Remember, you will be deploying to Moonbase Alpha and will need to use the TestNet RPC URL: ```text {{ networks.moonbase.rpc_url }} ``` To configure your project for 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}. The deployment will be broken up into three sections: [generate artifacts](#generate-artifacts), [create a deployment script](#create-a-deployment-script), and [deploy with Mars](#deploy-with-mars). ### Generate Artifacts {: #generate-artifacts } Artifacts need to be generated for Mars so that typechecks are enabled within deployment scripts. 1. Update existing script to run Waffle in the `package.json` to include Mars: ```json "scripts": { "build": "waffle && mars", "test": "mocha" }, ``` 2. Generate the artifacts and create the `artifacts.ts` file needed for deployments: ```bash npm run build ```
npm run build
> waffle-mars@1.0.0 build > waffle && mars
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. --> contracts/MyToken.sol
If you open the `build` directory, you should now see an `artifacts.ts` file containing the artifact data needed for deployments. To continue on with the deployment process, you'll need to write a deployment script. The deployment script will be used to tell Mars which contract to deploy, to what network, and which account is to be used to trigger the deployment. ### Create a Deployment Script {: #create-a-deployment-script } Now you need to configure the deployment for the `MyToken` contract to the Moonbase Alpha TestNet. In this step, you'll create the deployment script which will define how the contract should be deployed. Mars offers a `deploy` function that you can pass options to such as the private key of the account to deploy the contract, the network to deploy to, and more. Inside of the `deploy` function is where the contracts to be deployed are defined. Mars has a `contract` function that accepts the `name`, `artifact`, and `constructorArgs`. This function will be used to deploy the `MyToken` contract with an initial supply of 10 MYTOKs. 1. Create a `src` directory to contain your deployment scripts and create the script to deploy the `MyToken` contract: ```bash mkdir src && cd src && touch deploy.ts ``` 2. In `deploy.ts`, use Mars' `deploy` function to create a script to deploy to Moonbase Alpha using your account's private key: ```javascript import { deploy } from 'ethereum-mars'; // For demo purposes only. Never store your private key in a JavaScript/TypeScript file const privateKey = 'INSERT_PRIVATE_KEY'; deploy( { network: '{{ networks.moonbase.rpc_url }}', privateKey }, (deployer) => { // Deployment logic will go here } ); ``` 3. Set up the `deploy` function to deploy the `MyToken` contract created in the previous steps: ```javascript import { deploy, contract } from 'ethereum-mars'; import { MyToken } from '../build/artifacts'; // For demo purposes only. Never store your private key in a JavaScript/TypeScript file const privateKey = 'INSERT_PRIVATE_KEY'; deploy({ network: '{{ networks.moonbase.rpc_url }}', privateKey }, () => { contract('myToken', MyToken); }); ``` 4. Add a deploy script to the `scripts` object in the `package.json`: ```json "scripts": { "build": "waffle && mars", "test": "mocha", "deploy": "ts-node src/deploy.ts" } ``` So far, you should have created a deployment script in `deploy.ts` that will deploy the `MyToken` contract to Moonbase Alpha, and added the ability to easily call the script and deploy the contract. ### Deploy with Mars {: #deploy-with-mars } You've configured the deployment, now it's time to actually deploy to Moonbase Alpha. 1. Deploy the contract using the script you just created: ```bash npm run deploy ``` 2. In your Terminal, Mars will prompt you to press `ENTER` to send your transaction
npm run deploy
> waffle-mars@1.0.0 deploy > ts-node src/deploy.ts
Transaction: Deploy myToken Fee: $0.00, Ξ0.0 Balance: $4142380208.17,Ξ1207925.819614629174706176 ENTER to submit, Ctrl+C to exit...
If successful, you should see details about your transaction including its hash, the block it was included in, and it's address.
npm run deploy
> waffle-mars@1.0.0 deploy > ts-node src/deploy.ts
Transaction: Deploy myToken Fee: $0.00,Ξ0.0 Balance: Sending Block: 1 $4142380208.17, Ξ1207925.819614629174706176 Hash: Oxfa8bcad89cb8efdabfc@e5575dbe7151ce1c38f8aa67229fd5122bbdafe8b2f9 Address: 0xC2Bf5F29a4384b1aB0C063e1c666f02121B6084a
Congratulations! You've deployed a contract to Moonbase Alpha using Waffle and Mars! ## Example Project {: #example-project } If you want to see a completed example of a Waffle and Mars project on Moonbeam, check out the [moonbeam-waffle-mars-example](https://github.com/EthWorks/moonbeam-waffle-mars-example){target=\_blank} created by the team behind Waffle and Mars, EthWorks.
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/substrate/dev-env/chopsticks/ --- BEGIN CONTENT --- --- title: How to use Chopsticks to Fork Moonbeam description: Learn the basics of how to use Chopsticks to replay blocks, dissect state changes, test XCM interactions, and locally fork the entirety of a Moonbeam network. categories: Substrate Toolkit, Dev Environments --- # How to Use Chopsticks to Fork Moonbeam ## Introduction {: #introduction } [Chopsticks](https://github.com/AcalaNetwork/chopsticks){target=\_blank} provides a developer-friendly method of locally forking existing Substrate based chains. It allows for the replaying of blocks to easily examine how extrinsics affect state, the forking of multiple blocks for XCM testing, and more. This allows developers to test and experiment with their own custom blockchain configurations in a local development environment, without the need to deploy a live network. Overall, Chopsticks aims to simplify the process of building blockchain applications on Substrate and make it accessible to a wider range of developers. ## Forking Moonbeam with Chopsticks {: #forking-moonbeam } To use Chopsticks, you can install it as a package with the [Node package manager](https://nodejs.org/en){target=\_blank} or [Yarn](https://yarnpkg.com){target=\_blank}: ```bash npm i @acala-network/chopsticks@latest ``` Once installed, you can run commands with the Node package executor. For example, this runs Chopstick's base command: ```bash npx @acala-network/chopsticks@latest ``` To run Chopsticks, you will need some sort of configuration, typically through a file. Chopsticks' source repository includes a set of [YAML](https://yaml.org){target=\_blank} configuration files that can be used to create a local copy of a variety of Substrate chains. You can download the configuration files from the [source repository's `configs` folder](https://github.com/AcalaNetwork/chopsticks){target=\_blank}. Moonbeam, Moonriver, and Moonbase Alpha all have default files available: === "Moonbeam" ```yaml endpoint: wss://wss.api.moonbeam.network mock-signature-host: true db: ./db.sqlite import-storage: System: Account: - - - "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" - data: free: "100000000000000000000000" TechCommitteeCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] CouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] TreasuryCouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] AuthorFilter: EligibleRatio: 100 EligibleCount: 100 ``` === "Moonriver" ```yaml endpoint: wss://wss.moonriver.moonbeam.network mock-signature-host: true db: ./db.sqlite import-storage: System: Account: - - - "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" - data: free: "100000000000000000000000" TechCommitteeCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] CouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] TreasuryCouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] AuthorFilter: EligibleRatio: 100 EligibleCount: 100 ``` === "Moonbase Alpha" ```yaml endpoint: wss://wss.api.moonbase.moonbeam.network mock-signature-host: true db: ./db.sqlite import-storage: System: Account: - - - "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" - data: free: "100000000000000000000000" TechCommitteeCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] CouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] TreasuryCouncilCollective: Members: ["0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"] Sudo: Key: "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" AuthorFilter: EligibleRatio: 100 EligibleCount: 100 ``` These are the settings that can be included in the config file: | Option | Description | |:--------------------------:|:------------------------------------------------------------------------------------------------------------:| | `genesis` | The link to a parachain's raw genesis file to build the fork from, instead of an endpoint. | | `timestamp` | Timestamp of the block to fork from. | | `endpoint` | The endpoint of the parachain to fork. | | `block` | Use to specify at which block hash or number to replay the fork. | | `wasm-override` | Path of the WASM to use as the parachain runtime, instead of an endpoint's runtime. | | `db` | Path to the name of the file that stores or will store the parachain's database. | | `config` | Path or URL of the config file. | | `port` | The port to expose an endpoint on. | | `build-block-mode` | How blocks should be built in the fork: batch, manual, instant. | | `import-storage` | A pre-defined JSON/YAML storage file path to override in the parachain's storage. | | `allow-unresolved-imports` | Whether to allow WASM unresolved imports when using a WASM to build the parachain. | | `html` | Include to generate storage diff preview between blocks. | | `mock-signature-host` | Mock signature host so that any signature starts with `0xdeadbeef` and filled by `0xcd` is considered valid. | You can use the configuration file with the base command `npx @acala-network/chopsticks@latest` to fork assets by providing it with the `--config` flag. You can use a raw GitHub URL of the default configuration files, a path to a local configuration file, or simply use the chain's name for the `--config` flag. For example, the following commands all use Moonbeam's configuration in the same way: === "Chain Name" ```bash npx @acala-network/chopsticks@latest --config=moonbeam ``` === "GitHub URL" ```bash npx @acala-network/chopsticks@latest \ --config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonbeam.yml ``` === "Local File Path" ```bash npx @acala-network/chopsticks@latest --config=configs/moonbeam.yml ``` !!! note If using a file path, make sure you've downloaded the [Moonbeam configuration file](https://github.com/AcalaNetwork/chopsticks/blob/master/configs/moonbeam.yml){target=\_blank}, or have created your own. A configuration file is not necessary, however. All of the settings (except `genesis` and `timestamp`) can also be passed as flags to configure the environment completely in the command line. For example, the following command forks Moonbase Alpha at block 100. ```bash npx @acala-network/chopsticks@latest --endpoint {{ networks.moonbase.wss_url }} --block 100 ``` ### Quickstart {: #quickstart } The simplest way to fork Moonbeam is through the configuration files that are stored in the Chopsticks GitHub repository: === "Moonbeam" ```bash npx @acala-network/chopsticks@latest \ --config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonbeam.yml ``` === "Moonriver" ```bash npx @acala-network/chopsticks@latest \ --config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonriver.yml ``` === "Moonbase Alpha" ```bash npx @acala-network/chopsticks@latest \ --config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonbase-alpha.yml ``` ### Interacting with a Fork {: #interacting-with-a-fork } When running a fork, by default it will be accessible at: ```text ws://localhost:8000 ``` You will be able to interact with the parachain via libraries such as [Polkadot.js](https://github.com/polkadot-js/common){target=\_blank} and its [user interface, Polkadot.js Apps](https://github.com/polkadot-js/apps){target=\_blank}. You can interact with Chopsticks via the [Polkadot.js Apps hosted user interface](https://polkadot.js.org/apps/#/explorer){target=\_blank}. To do so, visit the page and take the following steps: 1. Click the icon in the top left 2. Go to the bottom and open **Development** 3. Select the **Custom** endpoint and enter `ws://localhost:8000` 4. Click the **Switch** button ![Open WSS](/images/builders/substrate/dev-env/chopsticks/chopsticks-1.webp) ![Switch WSS](/images/builders/substrate/dev-env/chopsticks/chopsticks-2.webp) You should now be able to interact with the fork as you would an active parachain or relay chain. !!! note If your browser cannot connect to the WebSocket endpoint provided by Chopsticks, you might need to allow insecure connections for the Polkadot.js Apps URL. Another solution is to run the [Docker version of Polkadot.js Apps](https://github.com/polkadot-js/apps#docker){target=\_blank}. ## Replaying Blocks {: #replaying-blocks } In the case where you would like to replay a block and retrieve its information to dissect the effects of an extrinsic, you can use the `npx @acala-network/chopsticks@latest run-block` command. Its following flags are: | Flag | Description | |:--------------------------:|:--------------------------------------------------------------------------------------:| | `endpoint` | The endpoint of the parachain to fork. | | `block` | Use to specify at which block hash or number to replay the fork. | | `wasm-override` | Path of the WASM to use as the parachain runtime, instead of an endpoint's runtime. | | `db` | Path to the name of the file that stores or will store the parachain's database. | | `config` | Path or URL of the config file. | | `output-path=/[file_path]` | Use to print out results to a JSON file instead of printing it out in the console. | | `html` | Include to generate an HTML representation of the storage diff preview between blocks. | | `open` | Whether to open the HTML representation. | For example, running the following command will re-run Moonbeam's block 1000, and write the storage diff and other data in a `moonbeam-output.json` file: ```bash npx @acala-network/chopsticks@latest run-block \ --endpoint wss://wss.api.moonbeam.network \ --output-path=./moonbeam-output.json \ --block 1000 ``` ## XCM Testing {: #xcm-testing } To test out XCM messages between networks, you can fork multiple parachains and a relay chain locally. For example, the following will fork Moonriver, Karura, and Kusama given that you've downloaded the [`configs` directory from the source GitHub repository](https://github.com/AcalaNetwork/chopsticks/tree/master/configs){target=\_blank}: ```bash npx @acala-network/chopsticks@latest xcm \ --r=kusama.yml \ --p=moonriver.yml \ --p=karura.yml ``` You should see something like the following output: ```text [13:50:57.807] INFO (rpc/64805): Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonriver.yml [13:50:59.655] INFO (rpc/64805): Moonriver RPC listening on port 8000 [13:50:59.656] INFO (rpc/64805): Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/karura.yml [13:51:03.275] INFO (rpc/64805): Karura RPC listening on port 8001 [13:51:03.586] INFO (xcm/64805): Connected parachains [2000,2023] [13:51:03.586] INFO (rpc/64805): Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/kusama.yml [13:51:07.241] INFO (rpc/64805): Kusama RPC listening on port 8002 [13:51:07.700] INFO (xcm/64805): Connected relaychain 'Kusama' with parachain 'Moonriver' [13:51:08.386] INFO (xcm/64805): Connected relaychain 'Kusama' with parachain 'Karura' ``` Including the `r` flag as the relay chain is optional, as Chopsticks will automatically mock a relay chain between networks. You can also use a raw GitHub URL or the name of a popular branch, similar to the base command. ## WebSocket Commands {: #websocket-commands } Chopsticks' internal websocket server has special endpoints that allows the manipulation of the local Substrate chain. These are the methods that can be invoked: | Method | Parameters | Description | |:----------------:|:---------------------:|:-------------------------------------------------------------:| | `dev_newBlock` | `options` | Generates one or more new blocks. | | `dev_setStorage` | `values`, `blockHash` | Create or overwrite the value of any storage. | | `dev_timeTravel` | `date` | Sets the timestamp of the block to the `date` value. | | `dev_setHead` | `hashOrNumber` | Sets the head of the blockchain to a specific hash or number. | The parameters above are formatted in the following ways: | Parameter | Format | Example | |:--------------:|:-----------------------------------:|:----------------------------------------------------------------------:| | `options` | `{ "to": number, "count": number }` | `{ "count": 5 }` | | `values` | `Object` | `{ "Sudo": { "Key": "0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b" } }` | | `blockHash` | `string` | `"0x1a34506b33e918a0106b100db027425a83681e2332fe311ee99d6156d2a91697"` | | `date` | `Date` | `"2030-08-15T00:00:00"` | | `hashOrNumber` | `number | string` | - **`options` { "to": number, "count": number }** - a JSON object where `"to"` will create blocks up to a certain value, and `"count"` will increase by a certain number of blocks. Use only one entry at a time within the JSON object - **`values` Object** - a JSON object resembling the path to a storage value, similar to what you would retrieve via Polkadot.js - **`blockHash` string** - optional, the blockhash at which the storage value is changed - **`date` Date** - a Date string (compatible with the JavaScript Date library) that will change the time stamp from which the next blocks being created will be at. All future blocks will be sequentially after that point in time - **`hashOrNumber` number | string** - if found, the chain head will be set to the block with the block number or block hash of this value Each method can be invoked by connecting to the websocket (`ws://localhost:8000` by default) and sending the data and parameters in the following format. Replace `METHOD_NAME` with the name of the method, and replace or delete `PARAMETER_1` and `PARAMETER_2` with the parameter data relevant to the method: ```json { "jsonrpc": "2.0", "id": 1, "method": "METHOD_NAME", "params": ["PARAMETER_1", "PARAMETER_2", "..."] } ```
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/tutorials/eth-api/foundry-start-to-end/ --- BEGIN CONTENT --- --- title: Foundry Development Life Cycle from Start to End description: Follow a step-by-step tutorial on how to use Foundry to build a project on Moonbeam, from writing smart contracts and tests to deploying on TestNet and MainNet. categories: Tutorials, Dev Environments --- # Using Foundry Start to End with Moonbeam _by Jeremy Boetticher_ ## Introduction {: #introduction } Foundry has become an increasingly popular development environment for smart contracts because it requires only one language: Solidity. Moonbeam offers [introductory documentation on using Foundry](/builders/ethereum/dev-env/foundry/){target=\_blank} with Moonbeam networks, which is recommended to read to get an introduction to using Foundry. In this tutorial, we will dip our toes deeper into the library to get a more cohesive look at properly developing, testing, and deploying with Foundry. In this demonstration, we will deploy two smart contracts. One is a token, and the other will depend on that token. We will also write unit tests to ensure the contracts work as expected. To deploy them, we will write a script that Foundry will use to determine the deployment logic. Finally, we will verify the smart contracts on Moonbeam's blockchain explorer. ## Checking Prerequisites {: #checking-prerequisites } To get started, you will need the following: - Have an account with funds. 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} - 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} - Have [Foundry installed](https://getfoundry.sh/introduction/installation/){target=\_blank} - Have an [Etherscan API Key](/builders/ethereum/verify-contracts/api-verification/#generating-an-etherscan-api-key){target=\_blank} ## Create a Foundry Project {: #create-a-foundry-project } The first step to start a Foundry project is, of course, to create it. If you have Foundry installed, you can run: ```bash forge init foundry && cd foundry ``` This will have the `forge` utility initialize a new folder named `foundry` with a Foundry project initialized within it. The `script`, `src`, and `test` folders may have files in them already. Be sure to delete them, because we will be writing our own soon. From here, there are a few things to do first before writing any code. First, we want to add a dependency to [OpenZeppelin's smart contracts](https://github.com/OpenZeppelin/openzeppelin-contracts){target=\_blank}, because they include helpful contracts to use when writing token smart contracts. To do so, add them using their GitHub repository name: ```bash forge install OpenZeppelin/openzeppelin-contracts ``` This will add the OpenZeppelin git submodule to your `lib` folder. To be sure that this dependency is mapped, you can override the mappings in a special file, `remappings.txt`: ```bash forge remappings > remappings.txt ``` Every line in this file is one of the dependencies that can be referenced in the project's smart contracts. Dependencies can be edited and renamed so that it's easier to reference different folders and files when working on smart contracts. It should look similar to this with OpenZeppelin installed properly: ```text ds-test/=lib/forge-std/lib/ds-test/src/ forge-std/=lib/forge-std/src/ openzeppelin-contracts/=lib/openzeppelin-contracts/ ``` Finally, let's open up the `foundry.toml` file. In preparation for Etherscan verification and deployment, add this to the file: ```toml [profile.default] src = 'src' out = 'out' libs = ['lib'] solc_version = '0.8.20' [rpc_endpoints] moonbase = "{{ networks.moonbase.rpc_url }}" moonbeam = "{{ networks.moonbeam.rpc_url }}" [etherscan] moonbase = { key = "${MOONSCAN_API_KEY}" } moonbeam = { key = "${MOONSCAN_API_KEY}" } ``` The first addition is a specification of the `solc_version`, underneath `profile.default`. The `rpc_endpoints` tag allows you to define which RPC endpoints to use when deploying to a named network, in this case, Moonbase Alpha and Moonbeam. The `etherscan` tag allows you to add Etherscan API keys for smart contract verification, which we will review later. ## Add Smart Contracts {: #add-smart-contracts-in-foundry } Smart contracts in Foundry destined for deployment by default belong in the `src` folder. In this tutorial, we'll write two smart contracts. Starting with the token: ```bash touch src/MyToken.sol ``` Open the file and add the following to it: ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Import OpenZeppelin Contract import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // This ERC-20 contract mints the specified amount of tokens to the contract creator contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") { _mint(msg.sender, initialSupply); } // An external minting function allows anyone to mint as many tokens as they want function mint(uint256 toMint, address to) external { require(toMint <= 1 ether); _mint(to, toMint); } } ``` As you can see, the OpenZeppelin `ERC20` smart contract is imported by the mapping defined in `remappings.txt`. The second smart contract, which we'll name `Container.sol`, will depend on this token contract. It is a simple contract that holds the ERC-20 token we'll deploy. You can create the file by executing: ```bash touch src/Container.sol ``` Open the file and add the following to it: ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Import OpenZeppelin Contract import {MyToken} from "./MyToken.sol"; enum ContainerStatus { Unsatisfied, Full, Overflowing } contract Container { MyToken token; uint256 capacity; ContainerStatus public status; constructor(MyToken _token, uint256 _capacity) { token = _token; capacity = _capacity; status = ContainerStatus.Unsatisfied; } // Updates the status value based on the number of tokens that this contract has function updateStatus() public { address container = address(this); uint256 balance = token.balanceOf(container); if (balance < capacity) { status = ContainerStatus.Unsatisfied; } else if (balance == capacity) { status = ContainerStatus.Full; } else if (_isOverflowing(balance)) { status = ContainerStatus.Overflowing; } } // Returns true if the contract should be in an overflowing state, false if otherwise function _isOverflowing(uint256 balance) internal view returns (bool) { return balance > capacity; } } ``` The `Container` smart contract can have its status updated based on how many tokens it holds and what its initial capacity value was set to. If the number of tokens it holds is above its capacity, its status can be updated to `Overflowing`. If it holds tokens equal to capacity, its status can be updated to `Full`. Otherwise, the contract will start and stay in the `Unsatisfied` state. `Container` requires a `MyToken` smart contract instance to function, so when we deploy it, we will need logic to ensure that it is deployed with a `MyToken` smart contract. ## Write Tests {: #write-tests } Before we deploy anything to a TestNet or MainNet, however, it's good to test your smart contracts. There are many types of tests: - **Unit tests** — allow you to test specific parts of a smart contract's functionality. When writing your own smart contracts, it can be a good idea to break functionality into different sections so that it is easier to unit test - **Fuzz tests** — allow you to test a smart contract with a wide variety of inputs to check for edge cases - **Integration tests** — allow you to test a smart contract when it works in conjunction with other smart contracts, so that you know it works as expected in a deployed environment - **Forking tests** - integration tests that allows you to make a fork (a carbon copy of a network), so that you can simulate a series of transactions on a preexisting network ### Unit Tests in Foundry {: #unit-tests-in-foundry} To get started with writing tests for this tutorial, make a new file in the `test` folder: ```bash cd test touch MyToken.t.sol ``` By convention, all of your tests should end with `.t.sol` and start with the name of the smart contract that it is testing. In practice, the test can be stored anywhere and is considered a test if it has a function that starts with the word *"test"*. Let's start by writing a test for the token smart contract. Open up `MyToken.t.sol` and add: ```solidity pragma solidity ^0.8.0; import "forge-std/Test.sol"; import "../src/MyToken.sol"; contract MyTokenTest is Test { MyToken public token; // Runs before each test function setUp() public { token = new MyToken(100); } // Tests if minting during the constructor happens properly function testConstructorMint() public { assertEq(token.balanceOf(address(this)), 100); } } ``` Let's break down what's happening here. The first line is typical for a Solidity file: setting the Solidity version. The next two lines are imports. `forge-std/Test.sol` is the standard library that Forge (and thus Foundry) includes to help with testing. This includes the `Test` smart contract, certain assertions, and [forge cheatcodes](https://getfoundry.sh/forge/tests/cheatcodes/){target=\_blank}. If you take a look at the `MyTokenTest` smart contract, you'll see two functions. The first is `setUp`, which is run before each test. So in this test contract, a new instance of `MyToken` is deployed every time a test function is run. You know if a function is a test function if it starts with the word *"test"*, so the second function, `testConstructorMint` is a test function. Great! Let's write some more tests, but for `Container`. ```bash touch Container.t.sol ``` And add the following: ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {MyToken} from "../src/MyToken.sol"; import {Container, ContainerStatus} from "../src/Container.sol"; contract ContainerTest is Test { MyToken public token; Container public container; uint256 constant CAPACITY = 100; // Runs before each test function setUp() public { token = new MyToken(1000); container = new Container(token, CAPACITY); } // Tests if the container is unsatisfied right after constructing function testInitialUnsatisfied() public { assertEq(token.balanceOf(address(container)), 0); assertTrue(container.status() == ContainerStatus.Unsatisfied); } // Tests if the container will be "full" once it reaches its capacity function testContainerFull() public { token.transfer(address(container), CAPACITY); container.updateStatus(); assertEq(token.balanceOf(address(container)), CAPACITY); assertTrue(container.status() == ContainerStatus.Full); } } ``` This test smart contract has two tests, so when running the tests, there will be two deployments of both `MyToken` and `Container`, for four smart contracts. You can run the following command to see the result of the test: ```bash forge test ``` When testing, you should see the following output:
forge test [⠊] Compiling... No files changed, compilation skipped
Ran 1 test for test/MyToken.t.sol:MyTokenTest [PASS] testConstructorMint() (gas: 10651) Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 361.83µs (39.46µs CPU time)
Ran 2 tests for test/Container.t.sol:ContainerTest [PASS] testContainerFull() (gas: 73204) [PASS] testInitialUnsatisfied() (gas: 18476) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 422.00µs (128.67µs CPU time) Ran 2 test suites in 138.17ms (783.83µs CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)
### Test Harnesses in Foundry {: #test-harnesses-in-foundry } Sometimes you'll want to unit test an `internal` function in a smart contract. To do so, you'll have to write a test harness smart contract, which inherits from the smart contract and exposes the internal function as a public one. For example, in `Container`, there is an internal function named `_isOverflowing`, which checks to see if the smart contract has more tokens than its capacity. To test this, add the following test harness smart contract to the `Container.t.sol` file: ```solidity contract ContainerHarness is Container { constructor(MyToken _token, uint256 _capacity) Container(_token, _capacity) {} function exposed_isOverflowing(uint256 balance) external view returns(bool) { return _isOverflowing(balance); } } ``` Now, inside of the `ContainerTest` smart contract, you can add a new test that tests the previously unreachable `_isOverflowing` contract: ```solidity // Tests for negative cases of the internal _isOverflowing function function testIsOverflowingFalse() public { ContainerHarness harness = new ContainerHarness(token , CAPACITY); assertFalse(harness.exposed_isOverflowing(CAPACITY - 1)); assertFalse(harness.exposed_isOverflowing(CAPACITY)); assertFalse(harness.exposed_isOverflowing(0)); } ``` Now, when you run the test with `forge test`, you should see that `testIsOverflowingFalse` passes!
forge test [⠊] Compiling... [⠒] Compiling 1 files with 0.8.20 [⠢] Solc 0.8.20 finished in 1.06s Compiler run successful
Ran 1 test for test/MyToken.t.sol:MyTokenTest [PASS] testConstructorMint() (gas: 10651) Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 498.00µs (48.96µs CPU time)
Ran 3 tests for test/Container.t.sol:ContainerTest [PASS] testContainerFull() (gas: 73238) [PASS] testInitialUnsatisfied() (gas: 18510) [PASS] testIsOverflowingFalse() (gas: 192130) Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 606.17µs (183.54µs CPU time) Ran 2 test suites in 138.29ms (1.10ms CPU time): 4 tests passed, 0 failed, 0 skipped (4 total tests)
### Fuzzing Tests in Foundry {: #fuzzing-tests-in-foundry} When you write a unit test, you can only use so many inputs to test. You can test edge cases, a few select values, and perhaps one or two random ones. But when working with inputs, there are nearly an infinite amount of different ones to test! How can you be sure that they work for every value? Wouldn't you feel safer if you could test 10000 different inputs instead of less than 10? One of the best ways that developers can test many inputs is through fuzzing, or fuzz tests. Foundry automatically fuzz tests when an input in a test function is included. To illustrate this, add the following test to the `MyTokenTest` contract in `MyToken.t.sol`. ```solidity // Fuzz tests for success upon minting tokens one ether or below function testMintOneEtherOrBelow(uint256 amountToMint) public { vm.assume(amountToMint <= 1 ether); token.mint(amountToMint, msg.sender); assertEq(token.balanceOf(msg.sender), amountToMint); } ``` This test includes `uint256 amountToMint` as input, which tells Foundry to fuzz with `uint256` inputs! By default, Foundry will input 256 different inputs, but this can be configured with the [`FOUNDRY_FUZZ_RUNS` environment variable](https://getfoundry.sh/config/reference/testing/#runs){target=\_blank}. Additionally, the first line in the function uses `vm.assume` to only use inputs that are less than or equal to one ether since the `mint` function reverts if someone tries to mint more than one ether at a time. This cheatcode helps you direct the fuzzing into the right range. Let's look at another fuzzing test to put in the `MyTokenTest` contract, but this time where we expect to fail: ```solidity // Fuzz tests for failure upon minting tokens above one ether function testFailMintAboveOneEther(uint256 amountToMint) public { vm.assume(amountToMint > 1 ether); token.mint(amountToMint, msg.sender); } ``` In Foundry, when you want to test for a failure, instead of just starting your test function with the world *"test"*, you start it with *"testFail"*. In this test, we assume that the `amountToMint` is above one ether, which should fail! Now run the tests: ```bash forge test ``` You should see something similar to the following in the console:
forge test [⠊] Compiling... [⠊] Compiling 1 files with 0.8.20 [⠒] Solc 0.8.20 finished in 982.65ms Compiler run successful
Ran 3 tests for test/Container.t.sol:ContainerTest [PASS] testContainerFull() (gas: 73238) [PASS] testInitialUnsatisfied() (gas: 18510) [PASS] testIsOverflowingFalse() (gas: 192130) Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 446.25µs (223.67µs CPU time)
Ran 3 tests for test/MyToken.t.sol:MyTokenTest [PASS] testConstructorMint() (gas: 10651) [PASS] testFailMintAboveOneEther(uint256) (runs: 256, μ: 8462, ~: 8462) [PASS] testMintOneEtherOrBelow(uint256) (runs: 256, μ: 37939, ~: 39270) Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 10.78ms (18.32ms CPU time) Ran 2 test suites in 138.88ms (11.23ms CPU time): 6 tests passed, 0 failed, 0 skipped (6 total tests)
### Forking Tests in Foundry {: #forking-tests-in-foundry} In Foundry, you can locally fork a network so that you can test out how the contracts would work in an environment with already deployed smart contracts. For example, if someone deployed smart contract `A` on Moonbeam that required a token smart contract, you could fork the Moonbeam network and deploy your own token to test how smart contract `A` would react to it. !!! note Moonbeam's custom precompile smart contracts currently do not work in Foundry forks because precompiles are Substrate-based whereas typical smart contracts are completely based on the EVM. Learn more about [forking on Moonbeam](/builders/ethereum/dev-env/foundry/#forking-with-anvil){target=\_blank} and the [differences between Moonbeam and Ethereum](/learn/features/eth-compatibility/){target=\_blank}. In this tutorial, you will test how your `Container` smart contract interacts with an already deployed `MyToken` contract on Moonbase Alpha Let's add a new test function to the `ContainerTest` smart contract in `Container.t.sol` called `testAlternateTokenOnMoonbaseFork`: ```solidity // Fork tests in the Moonbase Alpha environment function testAlternateTokenOnMoonbaseFork() public { // Creates and selects a fork, returns a fork ID uint256 moonbaseFork = vm.createFork("moonbase"); vm.selectFork(moonbaseFork); assertEq(vm.activeFork(), moonbaseFork); // Get token that's already deployed & deploys a container instance token = MyToken(0x359436610E917e477D73d8946C2A2505765ACe90); container = new Container(token, CAPACITY); // Mint tokens to the container & update container status token.mint(CAPACITY, address(container)); container.updateStatus(); // Assert that the capacity is full, just like the rest of the time assertEq(token.balanceOf(address(container)), CAPACITY); assertTrue(container.status() == ContainerStatus.Full); } ``` The first step (and thus first line) in this function is to have the test function fork a network with `vm.createFork`. Recall that `vm` is a cheat code provided by the Forge standard library. All that's necessary to create a fork is an RPC URL, or an alias for an RPC URL that's stored in the `foundry.toml` file. In this case, we added an RPC URL for "moonbase" in [the setup step](#create-a-foundry-project), so in the test function we will just pass the word `"moonbase"`. This cheat code function returns an ID for the fork created, which is stored in an `uint256` and is necessary for activating the fork. On the second line, after the fork has been created, the environment will select and use the fork in the test environment with `vm.selectFork`. The third line just demonstrates that the current fork, retrieved with `vm.activeFork`, is the same as the Moonbase Alpha fork. The fourth line of code retrieves an already deployed instance of `MyToken`, which is what's so useful about forking: you can use contracts that are already deployed. The rest of the code tests capacity like you would expect a local test to. If you run the tests (with the `-vvvv` tag for extra logging), you'll see that it passes: ```bash forge test -vvvv ```
forge test [PASS] testIsOverflowingFalse() (gas: 192130) Traces: [192130] ContainerTest::testIsOverflowingFalse() ├─ [151256] → new ContainerHarness@0xF62849F9A0B5Bf2913b396098F7c7019b51A820a │ └─ ← [Return] 522 bytes of code ├─ [421] ContainerHarness::exposed_isOverflowing(99) [staticcall] │ └─ ← [Return] false ├─ [0] VM::assertFalse(false) [staticcall] │ └─ ← [Return] ├─ [421] ContainerHarness::exposed_isOverflowing(100) [staticcall] │ └─ ← [Return] false ├─ [0] VM::assertFalse(false) [staticcall] │ └─ ← [Return] ├─ [421] ContainerHarness::exposed_isOverflowing(0) [staticcall] │ └─ ← [Return] false ├─ [0] VM::assertFalse(false) [staticcall] │ └─ ← [Return] └─ ← [Stop] Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 2.07s (2.07s CPU time) Ran 2 test suites in 2.44s (2.08s CPU time): 7 tests passed, 0 failed, 0 skipped (7 total tests)
That's it for testing! You can find the complete `Container.t.sol` and `MyToken.t.sol` files below: ??? code "Container.t.sol" ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {MyToken} from "../src/MyToken.sol"; import {Container, ContainerStatus} from "../src/Container.sol"; contract ContainerTest is Test { MyToken public token; Container public container; uint256 constant CAPACITY = 100; function setUp() public { token = new MyToken(1000); container = new Container(token, CAPACITY); } function testInitialUnsatisfied() public { assertEq(token.balanceOf(address(container)), 0); assertTrue(container.status() == ContainerStatus.Unsatisfied); } function testContainerFull() public { token.transfer(address(container), CAPACITY); container.updateStatus(); assertEq(token.balanceOf(address(container)), CAPACITY); assertTrue(container.status() == ContainerStatus.Full); } function testIsOverflowingFalse() public { ContainerHarness harness = new ContainerHarness(token , CAPACITY); assertFalse(harness.exposed_isOverflowing(CAPACITY - 1)); assertFalse(harness.exposed_isOverflowing(CAPACITY)); assertFalse(harness.exposed_isOverflowing(0)); } function testAlternateTokenOnMoonbaseFork() public { // Creates and selects a fork uint256 moonbaseFork = vm.createFork("moonbase"); vm.selectFork(moonbaseFork); assertEq(vm.activeFork(), moonbaseFork); // Get token that's already deployed & deploys a container instance token = MyToken(0x93e1e9EC6c1A8736266A595EFe97B5673ea0fEAc); container = new Container(token, CAPACITY); // Mint tokens to the container & update container status token.mint(CAPACITY, address(container)); container.updateStatus(); // Assert that the capacity is full assertEq(token.balanceOf(address(container)), CAPACITY); assertTrue(container.status() == ContainerStatus.Full); } } contract ContainerHarness is Container { constructor(MyToken _token, uint256 _capacity) Container(_token, _capacity) {} function exposed_isOverflowing(uint256 balance) external view returns(bool) { return _isOverflowing(balance); } } ``` ??? code "MyToken.t.sol" ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "forge-std/Test.sol"; import "../src/MyToken.sol"; contract MyTokenTest is Test { MyToken public token; function setUp() public { token = new MyToken(100); } function testConstructorMint() public { assertEq(token.balanceOf(address(this)), 100); } function testMintOneEtherOrBelow(uint256 amountToMint) public { vm.assume(amountToMint <= 1 ether); token.mint(amountToMint, msg.sender); assertEq(token.balanceOf(msg.sender), amountToMint); } function testFailMintAboveOneEther(uint256 amountToMint) public { vm.assume(amountToMint > 1 ether); token.mint(amountToMint, msg.sender); } } ``` ## Deploy in Foundry with Solidity Scripts {: #deploy-in-foundry-with-solidity-scripts } Not only are tests in Foundry written in Solidity, the scripts are too! Like other developer environments, scripts can be written to help interact with deployed smart contracts or can help along a complex deployment process that would be difficult to do manually. Even though scripts are written in Solidity, they are never deployed to a chain. Instead, much of the logic is actually run off-chain, so don't worry about any additional gas costs for using Foundry instead of a JavaScript environment like Hardhat. ### Deploy on Moonbase Alpha {: #deploy-on-moonbase-alpha } In this tutorial, we will use Foundry's scripts to deploy the `MyToken` and `Container` smart contracts. To create the deployment scripts, create a new file in the `script` folder: ```bash cd script touch Container.s.sol ``` By convention, scripts should end with `s.sol` and have a name similar to the script they relate to. In this case, we are deploying the `Container` smart contract, so we have named the script `Container.s.sol`, though it's not the end of the world if you use a more suitable or descriptive name. In this script, add: ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; import "forge-std/Script.sol"; import {MyToken} from "../src/MyToken.sol"; import {Container} from "../src/Container.sol"; contract ContainerDeployScript is Script { // Runs the script; deploys MyToken and Container function run() external { vm.startBroadcast(); // Make a new token MyToken token = new MyToken(1000); // Make a new container new Container(token, 500); vm.stopBroadcast(); } } ``` Let's break this script down. The first line is standard: declaring the solidity version. The imports include the two smart contracts you previously added, which will be deployed. This includes additional functionality to use in a script, including the `Script` contract. Now let's look at the logic in the contract. There is a single function, `run`, which is where the script logic is hosted. In this `run` function, the `vm` object is used often. This is where all of the Forge cheatcodes are stored, which determines the state of the virtual machine that the solidity is run in. In the first line within the `run` function, `vm.startBroadcast` starts a broadcast, which indicates that the following logic should take place on-chain. So when the `MyToken` and the `Container` contracts are instantiated with the `new` keyword, they are instantiated on-chain. The final line, `vm.stopBroadcast` ends the broadcast. Before we run this script, you'll need to set up your keystore by importing your private key. You can do this using the cast wallet import command as follows: ```bash cast wallet import deployer --interactive ``` This will prompt you to: 1. Enter your private key 2. Enter a password to encrypt the keystore The account will be saved as "deployer" in your keystore. You can then use this account name in the deployment commands. You'll be prompted for your keystore password when deploying contracts or sending transactions. Now, your script and project should be ready for deployment! Use the following command to do so: ```bash forge script Container.s.sol:ContainerDeployScript --broadcast --verify -vvvv --legacy --rpc-url moonbase --account deployer ``` This command runs the `ContainerDeployScript` contract as a script. The `--broadcast` option tells Forge to allow broadcasting of transactions, the `--verify` option tells Forge to verify to Moonscan when deploying, `-vvvv` makes the command output verbose, and `--rpc-url moonbase` sets the network to what `moonbase` was set to in `foundry.toml`. The `--legacy` flag instructs Foundry to bypass EIP-1559. While all Moonbeam networks support EIP-1559, Foundry will refuse to submit the transaction to Moonbase and revert to a local simulation if you omit the `--legacy` flag. The `--account deployer` flag tells Foundry to use the "deployer" account from your keystore. You should see something like this as output:
Script ran successfully. Setting up 1 EVM. Simulated On-chain Traces: [488164] → new MyToken@0xAEe1a769b10d03a6CeB4D9DFd3aBB2EF807ee6aa ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: 0x3B939FeaD1557C741Ff06492FD0127bd287A421e, value: 1000) └─ ← [Return] 1980 bytes of code [133238] → new Container@0xeb1Ff38A645Eae4E64dFb93772D8129F88E11Ab1 └─ ← [Return] 432 bytes of code Chain 1287 Estimated gas price: 0.03125 gwei Estimated total gas used for script: 1670737 Estimated amount required: 0.000208842125 ETH Sending transactions [0 - 0]. ⠁ [00:00:00] [#############################################################>-------------------------------------------------------------] 1/2 txes (0.7s) Waiting for receipts. ⠉ [00:00:22] [#######################################################################################################################] 1/1 receipts (0.0s) moonbase ✅ [Success]Hash: 0x2ad8994c12af74bdcb04873e13d97dc543a2fa7390c1e194732ab43ec828cb3b Contract Address: 0xAEe1a769b10d03a6CeB4D9DFd3aBB2EF807ee6aa Block: 6717135 Paid: 0.000116937 ETH (935496 gas * 0.03125 gwei) Sending transactions [1 - 1]. ⠉ [00:00:23] [###########################################################################################################################] 2/2 txes (0.0s) Waiting for receipts. ⠉ [00:00:21] [#######################################################################################################################] 1/1 receipts (0.0s) moonbase ✅ [Success]Hash: 0x3bfb4cee2be4269badc57e0053d8b4d94d9d57d7936ecaa1e13ac1e2199f3b12 Contract Address: 0xeb1Ff38A645Eae4E64dFb93772D8129F88E11Ab1 Block: 6717137 Paid: 0.000035502 ETH (284016 gas * 0.03125 gwei) ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. Total Paid: 0.000152439 ETH (1219512 gas * avg 0.03125 gwei)
You should be able to see that your contracts were deployed, and are verified on Moonscan! For example, this is where my [`Container.sol` contract was deployed](https://moonbase.moonscan.io/address/0xe8bf2e654d7c1c1ba8f55fed280ddd241e46ced9#code){target=\_blank}. The entire deployment script is available below: ??? code "Container.s.sol" ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; import "forge-std/Script.sol"; import {MyToken} from "../src/MyToken.sol"; import {Container} from "../src/Container.sol"; contract ContainerDeployScript is Script { // Runs the script; deploys MyToken and Container function run() external { vm.startBroadcast(); // Make a new token MyToken token = new MyToken(1000); // Make a new container new Container(token, 500); vm.stopBroadcast(); } } ``` ### Deploy on Moonbeam MainNet {: #deploy-on-moonbeam-mainnet } Let's say you're comfortable with your smart contracts and want to deploy on the Moonbeam MainNet! The process isn't too different from what was just done, you just have to change the command's rpc-url from `moonbase` to `moonbeam`, since you've already added Moonbeam MainNet's information in the `foundry.toml` file: ```bash forge script Container.s.sol:ContainerDeployScript --broadcast --verify -vvvv --legacy --rpc-url moonbeam --account deployer ``` That's it! You've gone from nothing to a fully tested, deployed, and verified Foundry project. You can now adapt this so that you can use Foundry in your own projects!
This tutorial is for educational purposes only. As such, any contracts or code created in this tutorial should not be used in production.
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/tutorials/eth-api/hardhat-start-to-end/ --- BEGIN CONTENT --- --- title: Hardhat Developer Workflow description: Learn how to develop, test, and deploy smart contracts with Hardhat and how to take your contracts from a local development node to Moonbeam MainNet. categories: Tutorials, Dev Environments --- # Hardhat Developer Workflow _by Kevin Neilson & Erin Shaben_ ## Introduction {: #introduction } In this tutorial, we'll walk through the [Hardhat development environment](https://hardhat.org){target=\_blank} in the context of launching a [pooled staking DAO contract](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank}. We'll walk through the typical developer workflow in detail from start to finish. We'll assemble the components of the staking DAO and compile the necessary contracts. Then, we'll build a test suite with a variety of test cases relevant to our staking DAO, and run it against a local development node. Finally, we'll deploy the staking DAO to both Moonbase Alpha and Moonbeam and verify the contracts via the [Hardhat Etherscan plugin](/builders/ethereum/verify-contracts/etherscan-plugins/#using-the-hardhat-etherscan-plugin){target=\_blank}. If this is your first time exploring Hardhat, you may wish to start with [the introduction to Hardhat guide](/builders/ethereum/dev-env/hardhat/){target=\_blank}.
The information presented herein is for informational purposes only and has been provided by third parties. Moonbeam does not endorse any project listed and described on the Moonbeam docs website (https://docs.moonbeam.network/).
## Checking Prerequisites {: #checking-prerequisites } To get started, you will need the following: - A Moonbase Alpha account funded with DEV. 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} - An [Etherscan API Key](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank} - For the [Testing section](#running-your-tests), you'll need to have [a local Moonbeam node up and running](/builders/get-started/networks/moonbeam-dev/){target=\_blank} - 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} ## Creating a Hardhat Project {: #creating-a-hardhat-project } You will need to create a Hardhat project if you don't already have one. You can create one by completing the following steps: 1. Create a directory for your project ```bash mkdir stakingDAO && cd stakingDAO ``` 2. Initialize the project which will create a `package.json` file ```bash npm init -y ``` 3. Install Hardhat ```bash npm install hardhat@3.0.0-next.5 ``` 4. Create a project ```bash npx hardhat --init ``` !!! note `npx` is used to run executables installed locally in your project. Although Hardhat can be installed globally, installing it locally in each project is recommended so that you can control the version on a project-by-project basis. 5. You'll be prompted with a series of questions to set up your project: - Choose where to initialize the project (default is current directory) - Confirm converting to ESM (required for Hardhat v3) - Select the type of project to initialize: - A TypeScript Hardhat project using Node Test Runner and Viem - A TypeScript Hardhat project using Mocha and Ethers.js For this example, you can choose either option based on your preference. If you choose the Mocha and Ethers.js option, you'll get a project structure with: - A sample contract in `contracts/Counter.sol` - A test file in `test/Counter.ts` - TypeScript configuration - Mocha and Ethers.js dependencies The project will be set up with all necessary dependencies and configurations for you to start developing.
npx hardhat init 888    888                      888 888               888 888    888                      888 888               888 888    888                      888 888               888 8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888 888    888     "88b 888P"  d88" 888 888 "88b     "88b 888 888    888 .d888888 888    888  888 888  888 .d888888 888 888    888 888  888 888    Y88b 888 888  888 888  888 Y88b. 888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888
👷 Welcome to Hardhat v3.0.0-next.5 👷‍
 Where would you like to initialize the project?  .  Hardhat only supports ESM projects. Would you like to change "package.json" to turn your project into ESM? (Y/n) · true  What type of project would you like to initialize? …   A TypeScript Hardhat project using Node Test Runner and Viem  A TypeScript Hardhat project using Mocha and Ethers.js
## Add Smart Contracts {: #add-smart-contracts } The smart contract featured in this tutorial is more complex than the one in the [Introduction to Hardhat](/builders/ethereum/dev-env/hardhat/){target=\_blank} but the nature of the contract means it's perfect to demonstrate some of the advanced capabilities of Hardhat. [`DelegationDAO.sol`](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank} is a pooled staking DAO that uses [`StakingInterface.sol`](/builders/ethereum/precompiles/features/staking/){target=\_blank} to autonomously delegate to a [collator](/learn/platform/glossary/#collators){target=\_blank} when it reaches a determined threshold. Pooled staking contracts such as [`DelegationDAO.sol`](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank} allow delegators with less than the protocol minimum bond to join together to delegate their pooled funds and earn a share of staking rewards. !!! note `DelegationDAO.sol` is unreviewed and unaudited. It is designed only for demonstration purposes and not intended for production use. It may contain bugs or logic errors that could result in loss of funds. To get started, take the following steps: 1. Change to the contracts directory ```bash cd contracts ``` 2. Create a new file called `DelegationDAO.sol` ```bash touch DelegationDAO.sol ``` 3. Copy and paste the contents of [DelegationDAO.sol](https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-intro-course-resources/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank} into `DelegationDAO.sol` ??? code "DelegationDAO.sol" ```solidity // SPDX-License-Identifier: GPL-3.0-only // This is a PoC to use the staking precompile wrapper as a Solidity developer. pragma solidity >=0.8.0; import "./StakingInterface.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Address.sol"; contract DelegationDAO is AccessControl { // Role definition for contract members bytes32 public constant MEMBER = keccak256("MEMBER"); // Auto-compounding percentage (100%) uint8 public constant AUTOCOMPOUNDING_PERCENT = 100; // Possible states for the DAO to be in: // COLLECTING: the DAO is collecting funds before creating a delegation once the minimum delegation stake has been reached // STAKING: the DAO has an active delegation // REVOKING: the DAO has scheduled a delegation revoke // REVOKED: the scheduled revoke has been executed enum daoState { COLLECTING, STAKING, REVOKING, REVOKED } // Current state that the DAO is in daoState public currentState; // Member stakes (doesnt include rewards, represents member shares) mapping(address => uint256) public memberStakes; // Total Staking Pool (doesnt include rewards, represents total shares) uint256 public totalStake; // The ParachainStaking wrapper at the known pre-compile address. This will be used to make // all calls to the underlying staking solution ParachainStaking public staking; // Minimum Delegation Amount uint256 public constant minDelegationStk = 5 ether; // Moonbeam Staking Precompile address address public constant stakingPrecompileAddress = 0x0000000000000000000000000000000000000800; // The collator that this DAO is currently nominating address public target; // Event for a member deposit event deposit(address indexed _from, uint _value); // Event for a member withdrawal event withdrawal(address indexed _from, address indexed _to, uint _value); // Initialize a new DelegationDao dedicated to delegating to the given collator target. constructor(address _target, address admin) { // Directly grant roles _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(MEMBER, admin); //Sets the collator that this DAO nominating target = _target; // Initializes Moonbeam's parachain staking precompile staking = ParachainStaking(stakingPrecompileAddress); //Initialize the DAO state currentState = daoState.COLLECTING; } // Simple getter to return the target collator of the DAO function getTarget() public view returns (address) { return target; } // Grant a user the role of admin function grant_admin( address newAdmin ) public onlyRole(DEFAULT_ADMIN_ROLE) onlyRole(MEMBER) { grantRole(DEFAULT_ADMIN_ROLE, newAdmin); grantRole(MEMBER, newAdmin); } // Grant a user membership function grant_member( address newMember ) public onlyRole(DEFAULT_ADMIN_ROLE) { grantRole(MEMBER, newMember); } // Revoke a user membership function remove_member( address payable exMember ) public onlyRole(DEFAULT_ADMIN_ROLE) { revokeRole(MEMBER, exMember); } // Increase member stake via a payable function and automatically stake the added amount if possible function add_stake() external payable onlyRole(MEMBER) { if (currentState == daoState.STAKING) { // Sanity check if (!staking.isDelegator(address(this))) { revert("The DAO is in an inconsistent state."); } memberStakes[msg.sender] = memberStakes[msg.sender] + msg.value; totalStake = totalStake + msg.value; emit deposit(msg.sender, msg.value); staking.delegatorBondMore(target, msg.value); } else if (currentState == daoState.COLLECTING) { memberStakes[msg.sender] = memberStakes[msg.sender] + msg.value; totalStake = totalStake + msg.value; emit deposit(msg.sender, msg.value); if (totalStake < minDelegationStk) { return; } else { //initialiate the delegation and change the state staking.delegateWithAutoCompound( target, address(this).balance, AUTOCOMPOUNDING_PERCENT, staking.candidateDelegationCount(target), staking.candidateAutoCompoundingDelegationCount(target), staking.delegatorDelegationCount(address(this)) ); currentState = daoState.STAKING; } } else { revert("The DAO is not accepting new stakes in the current state."); } } // Function for a user to withdraw their stake function withdraw(address payable account) public onlyRole(MEMBER) { require( currentState != daoState.STAKING, "The DAO is not in the correct state to withdraw." ); if (currentState == daoState.REVOKING) { bool result = execute_revoke(); require(result, "Schedule revoke delay is not finished yet."); } if ( currentState == daoState.REVOKED || currentState == daoState.COLLECTING ) { //Sanity checks if (staking.isDelegator(address(this))) { revert("The DAO is in an inconsistent state."); } require(totalStake != 0, "Cannot divide by zero."); //Calculate the withdrawal amount including staking rewards uint amount = address(this).balance * memberStakes[msg.sender] / totalStake; require( check_free_balance() >= amount, "Not enough free balance for withdrawal." ); Address.sendValue(account, amount); totalStake = totalStake - (memberStakes[msg.sender]); memberStakes[msg.sender] = 0; emit withdrawal(msg.sender, account, amount); } } // Schedule revoke, admin only function schedule_revoke() public onlyRole(DEFAULT_ADMIN_ROLE) { require( currentState == daoState.STAKING, "The DAO is not in the correct state to schedule a revoke." ); staking.scheduleRevokeDelegation(target); currentState = daoState.REVOKING; } // Try to execute the revoke, returns true if it succeeds, false if it doesn't function execute_revoke() internal onlyRole(MEMBER) returns (bool) { require( currentState == daoState.REVOKING, "The DAO is not in the correct state to execute a revoke." ); staking.executeDelegationRequest(address(this), target); if (staking.isDelegator(address(this))) { return false; } else { currentState = daoState.REVOKED; return true; } } // Check how much free balance the DAO currently has. It should be the staking rewards if the DAO state is anything other than REVOKED or COLLECTING. function check_free_balance() public view onlyRole(MEMBER) returns (uint256) { return address(this).balance; } // Change the collator target, admin only function change_target( address newCollator ) public onlyRole(DEFAULT_ADMIN_ROLE) { require( currentState == daoState.REVOKED || currentState == daoState.COLLECTING, "The DAO is not in the correct state to change staking target." ); target = newCollator; } // Reset the DAO state back to COLLECTING, admin only function reset_dao() public onlyRole(DEFAULT_ADMIN_ROLE) { currentState = daoState.COLLECTING; } // Override _setupRole to use grantRole as _setupRole does not exist in AccessControl anymore function _setupRole(bytes32 role, address account) internal virtual { grantRole(role, account); } } ``` 4. Create a new file called `StakingInterface.sol` in the `contracts` directory ```bash touch StakingInterface.sol ``` 5. Copy and paste the contents of [StakingInterface.sol](https://raw.githubusercontent.com/moonbeam-foundation/moonbeam/master/precompiles/parachain-staking/StakingInterface.sol){target=\_blank} into `StakingInterface.sol` ??? code "StakingInterface.sol" ```solidity // SPDX-License-Identifier: GPL-3.0-only pragma solidity >=0.8.3; /// @dev The ParachainStaking contract's address. address constant PARACHAIN_STAKING_ADDRESS = 0x0000000000000000000000000000000000000800; /// @dev The ParachainStaking contract's instance. ParachainStaking constant PARACHAIN_STAKING_CONTRACT = ParachainStaking( PARACHAIN_STAKING_ADDRESS ); /// @author The Moonbeam Team /// @title Pallet Parachain Staking Interface /// @dev The interface through which solidity contracts will interact with Parachain Staking /// We follow this same interface including four-byte function selectors, in the precompile that /// wraps the pallet /// @custom:address 0x0000000000000000000000000000000000000800 interface ParachainStaking { /// @dev Check whether the specified address is currently a staking delegator /// @custom:selector fd8ab482 /// @param delegator the address that we want to confirm is a delegator /// @return A boolean confirming whether the address is a delegator function isDelegator(address delegator) external view returns (bool); /// @dev Check whether the specified address is currently a collator candidate /// @custom:selector d51b9e93 /// @param candidate the address that we want to confirm is a collator andidate /// @return A boolean confirming whether the address is a collator candidate function isCandidate(address candidate) external view returns (bool); /// @dev Check whether the specifies address is currently a part of the active set /// @custom:selector 740d7d2a /// @param candidate the address that we want to confirm is a part of the active set /// @return A boolean confirming whether the address is a part of the active set function isSelectedCandidate( address candidate ) external view returns (bool); /// @dev Total points awarded to all collators in a particular round /// @custom:selector 9799b4e7 /// @param round the round for which we are querying the points total /// @return The total points awarded to all collators in the round function points(uint256 round) external view returns (uint256); /// @dev Total points awarded to a specific collator in a particular round. /// A value of `0` may signify that no blocks were produced or that the storage for that round has been removed /// @custom:selector bfea66ac /// @param round the round for which we are querying the awarded points /// @param candidate The candidate to whom the points are awarded /// @return The total points awarded to the collator for the provided round function awardedPoints( uint32 round, address candidate ) external view returns (uint32); /// @dev The amount delegated in support of the candidate by the delegator /// @custom:selector a73e51bc /// @param delegator Who made this delegation /// @param candidate The candidate for which the delegation is in support of /// @return The amount of the delegation in support of the candidate by the delegator function delegationAmount( address delegator, address candidate ) external view returns (uint256); /// @dev Whether the delegation is in the top delegations /// @custom:selector 91cc8657 /// @param delegator Who made this delegation /// @param candidate The candidate for which the delegation is in support of /// @return If delegation is in top delegations (is counted) function isInTopDelegations( address delegator, address candidate ) external view returns (bool); /// @dev Get the minimum delegation amount /// @custom:selector 02985992 /// @return The minimum delegation amount function minDelegation() external view returns (uint256); /// @dev Get the CandidateCount weight hint /// @custom:selector a9a981a3 /// @return The CandidateCount weight hint function candidateCount() external view returns (uint256); /// @dev Get the current round number /// @custom:selector 146ca531 /// @return The current round number function round() external view returns (uint256); /// @dev Get the CandidateDelegationCount weight hint /// @custom:selector 2ec087eb /// @param candidate The address for which we are querying the nomination count /// @return The number of nominations backing the collator function candidateDelegationCount( address candidate ) external view returns (uint32); /// @dev Get the CandidateAutoCompoundingDelegationCount weight hint /// @custom:selector 905f0806 /// @param candidate The address for which we are querying the auto compounding /// delegation count /// @return The number of auto compounding delegations function candidateAutoCompoundingDelegationCount( address candidate ) external view returns (uint32); /// @dev Get the DelegatorDelegationCount weight hint /// @custom:selector 067ec822 /// @param delegator The address for which we are querying the delegation count /// @return The number of delegations made by the delegator function delegatorDelegationCount( address delegator ) external view returns (uint256); /// @dev Get the selected candidates for the current round /// @custom:selector bcf868a6 /// @return The selected candidate accounts function selectedCandidates() external view returns (address[] memory); /// @dev Whether there exists a pending request for a delegation made by a delegator /// @custom:selector 3b16def8 /// @param delegator the delegator that made the delegation /// @param candidate the candidate for which the delegation was made /// @return Whether a pending request exists for such delegation function delegationRequestIsPending( address delegator, address candidate ) external view returns (bool); /// @dev Whether there exists a pending exit for candidate /// @custom:selector 43443682 /// @param candidate the candidate for which the exit request was made /// @return Whether a pending request exists for such delegation function candidateExitIsPending( address candidate ) external view returns (bool); /// @dev Whether there exists a pending bond less request made by a candidate /// @custom:selector d0deec11 /// @param candidate the candidate which made the request /// @return Whether a pending bond less request was made by the candidate function candidateRequestIsPending( address candidate ) external view returns (bool); /// @dev Returns the percent value of auto-compound set for a delegation /// @custom:selector b4d4c7fd /// @param delegator the delegator that made the delegation /// @param candidate the candidate for which the delegation was made /// @return Percent of rewarded amount that is auto-compounded on each payout function delegationAutoCompound( address delegator, address candidate ) external view returns (uint8); /// @dev Join the set of collator candidates /// @custom:selector 1f2f83ad /// @param amount The amount self-bonded by the caller to become a collator candidate /// @param candidateCount The number of candidates in the CandidatePool function joinCandidates(uint256 amount, uint256 candidateCount) external; /// @dev Request to leave the set of collator candidates /// @custom:selector b1a3c1b7 /// @param candidateCount The number of candidates in the CandidatePool function scheduleLeaveCandidates(uint256 candidateCount) external; /// @dev Execute due request to leave the set of collator candidates /// @custom:selector 3867f308 /// @param candidate The candidate address for which the pending exit request will be executed /// @param candidateDelegationCount The number of delegations for the candidate to be revoked function executeLeaveCandidates( address candidate, uint256 candidateDelegationCount ) external; /// @dev Cancel request to leave the set of collator candidates /// @custom:selector 9c76ebb4 /// @param candidateCount The number of candidates in the CandidatePool function cancelLeaveCandidates(uint256 candidateCount) external; /// @dev Temporarily leave the set of collator candidates without unbonding /// @custom:selector a6485ccd function goOffline() external; /// @dev Rejoin the set of collator candidates if previously had called `goOffline` /// @custom:selector 6e5b676b function goOnline() external; /// @dev Request to bond more for collator candidates /// @custom:selector a52c8643 /// @param more The additional amount self-bonded function candidateBondMore(uint256 more) external; /// @dev Request to bond less for collator candidates /// @custom:selector 60744ae0 /// @param less The amount to be subtracted from self-bond and unreserved function scheduleCandidateBondLess(uint256 less) external; /// @dev Execute pending candidate bond request /// @custom:selector 2e290290 /// @param candidate The address for the candidate for which the request will be executed function executeCandidateBondLess(address candidate) external; /// @dev Cancel pending candidate bond request /// @custom:selector b5ad5f07 function cancelCandidateBondLess() external; /// @dev Make a delegation in support of a collator candidate /// @custom:selector 4b8bc9bf /// @param candidate The address of the supported collator candidate /// @param amount The amount bonded in support of the collator candidate /// @param autoCompound The percent of reward that should be auto-compounded /// @param candidateDelegationCount The number of delegations in support of the candidate /// @param candidateAutoCompoundingDelegationCount The number of auto-compounding delegations /// in support of the candidate /// @param delegatorDelegationCount The number of existing delegations by the caller function delegateWithAutoCompound( address candidate, uint256 amount, uint8 autoCompound, uint256 candidateDelegationCount, uint256 candidateAutoCompoundingDelegationCount, uint256 delegatorDelegationCount ) external; /// @dev Request to revoke an existing delegation /// @custom:selector 1a1c740c /// @param candidate The address of the collator candidate which will no longer be supported function scheduleRevokeDelegation(address candidate) external; /// @dev Bond more for delegators with respect to a specific collator candidate /// @custom:selector 0465135b /// @param candidate The address of the collator candidate for which delegation shall increase /// @param more The amount by which the delegation is increased function delegatorBondMore(address candidate, uint256 more) external; /// @dev Request to bond less for delegators with respect to a specific collator candidate /// @custom:selector c172fd2b /// @param candidate The address of the collator candidate for which delegation shall decrease /// @param less The amount by which the delegation is decreased (upon execution) function scheduleDelegatorBondLess( address candidate, uint256 less ) external; /// @dev Execute pending delegation request (if exists && is due) /// @custom:selector e98c8abe /// @param delegator The address of the delegator /// @param candidate The address of the candidate function executeDelegationRequest( address delegator, address candidate ) external; /// @dev Cancel pending delegation request (already made in support of input by caller) /// @custom:selector c90eee83 /// @param candidate The address of the candidate function cancelDelegationRequest(address candidate) external; /// @dev Sets an auto-compound value for a delegation /// @custom:selector faa1786f /// @param candidate The address of the supported collator candidate /// @param value The percent of reward that should be auto-compounded /// @param candidateAutoCompoundingDelegationCount The number of auto-compounding delegations /// in support of the candidate /// @param delegatorDelegationCount The number of existing delegations by the caller function setAutoCompound( address candidate, uint8 value, uint256 candidateAutoCompoundingDelegationCount, uint256 delegatorDelegationCount ) external; /// @dev Fetch the total staked amount of a delegator, regardless of the /// candidate. /// @custom:selector e6861713 /// @param delegator Address of the delegator. /// @return Total amount of stake. function getDelegatorTotalStaked( address delegator ) external view returns (uint256); /// @dev Fetch the total staked towards a candidate. /// @custom:selector bc5a1043 /// @param candidate Address of the candidate. /// @return Total amount of stake. function getCandidateTotalCounted( address candidate ) external view returns (uint256); } ``` 6. `DelegationDAO.sol` relies on a couple of standard [OpenZeppelin](https://www.openzeppelin.com){target=\_blank} contracts. Add the library with the following command: ```bash npm install @openzeppelin/contracts ``` ## Hardhat Configuration File {: #hardhat-configuration-file } When setting up the `hardhat.config.js` file, we'll need to import a few plugins that we'll use throughout this guide. So to get started, we'll need the [Hardhat Toolbox plugin](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox){target=\_blank}, which conveniently bundles together Hardhat plugins that can be used to deploy and interact with contracts using Ethers, test contracts with Mocha and Chai, verify contracts with Etherscan, and more. You can run the following command to install the plugin: ```bash npm install --save-dev @nomicfoundation/hardhat-toolbox ``` If you're curious about additional Hardhat plugins, here is [a complete list of official Hardhat plugins](https://hardhat.org/hardhat-runner/plugins){target=\_blank}. Hardhat 3 includes an encrypted secrets manager that makes handling sensitive information like private keys and API keys easier. This ensures you don't have to hardcode secrets in your source code or store them in plain text. !!! note The encrypted secrets manager is only available in Hardhat 3 or higher. As of writing this guide, Hardhat 3 is in alpha. You can install the latest alpha version with: ```bash npm install hardhat@3.0.0-next.5 ``` For the latest releases and updates, check the [Hardhat releases page](https://github.com/NomicFoundation/hardhat/releases/). To use encrypted secrets, you'll need to: 1. Install Hardhat 3 or later: ```bash npm install hardhat@3.0.0-next.5 ``` 2. Set up your secrets using the keystore: === "Moonbeam" ```bash npx hardhat keystore set MOONBEAM_RPC_URL npx hardhat keystore set MOONBEAM_PRIVATE_KEY ``` === "Moonriver" ```bash npx hardhat keystore set MOONRIVER_RPC_URL npx hardhat keystore set MOONRIVER_PRIVATE_KEY ``` === "Moonbase Alpha" ```bash npx hardhat keystore set MOONBASE_RPC_URL npx hardhat keystore set MOONBASE_PRIVATE_KEY ``` === "Moonbeam Dev Node" ```bash npx hardhat keystore set DEV_RPC_URL npx hardhat keystore set DEV_PRIVATE_KEY npx hardhat keystore set ALICE_PRIVATE_KEY npx hardhat keystore set BOB_PRIVATE_KEY ``` Then, update your configuration file to use the encrypted secrets: === "Moonbeam" ```js module.exports = { solidity: '0.8.20', networks: { moonbeam: { type: "http", chainType: "generic", url: configVariable("MOONBEAM_RPC_URL"), chainId: {{ networks.moonbeam.chain_id }}, // (hex: {{ networks.moonbeam.hex_chain_id }}), accounts: [configVariable("MOONBEAM_PRIVATE_KEY")], }, }, }; ``` === "Moonriver" ```js module.exports = { solidity: '0.8.20', networks: { moonriver: { type: "http", chainType: "generic", url: configVariable("MOONRIVER_RPC_URL"), chainId: {{ networks.moonriver.chain_id }}, // (hex: {{ networks.moonriver.hex_chain_id }}), accounts: [configVariable("MOONRIVER_PRIVATE_KEY")], }, }, }; ``` === "Moonbase Alpha" ```js module.exports = { solidity: '0.8.20', networks: { moonbase: { type: "http", chainType: "generic", url: configVariable("MOONBASE_RPC_URL"), chainId: {{ networks.moonbase.chain_id }}, // (hex: {{ networks.moonbase.hex_chain_id }}), accounts: [configVariable("MOONBASE_PRIVATE_KEY")], }, }, }; ``` === "Moonbeam Dev Node" ```js module.exports = { solidity: '0.8.20', networks: { dev: { type: "http", chainType: "generic", url: configVariable("DEV_RPC_URL"), chainId: 1281, // 0x501 in hex accounts: [ configVariable("DEV_PRIVATE_KEY"), configVariable("ALICE_PRIVATE_KEY"), // Alice (Alith) account configVariable("BOB_PRIVATE_KEY") // Bob (Baltathar) account ], }, }, }; ``` For this example, you'll need to add your private keys for your two accounts on Moonbase Alpha. Since some of the testing will be done on a development node, you'll also need to add the private keys of two of the pre-funded development node accounts, which, for this example, we can use Alice and Bob. In addition, you'll add your Etherscan API key, which can be used for both Moonbase Alpha and Moonbeam. ```js // 1. Import the Hardhat Toolbox plugin require('@nomicfoundation/hardhat-toolbox'); require('@nomicfoundation/hardhat-ignition-ethers'); module.exports = { // 2. Specify the Solidity version solidity: '0.8.20', networks: { // 3. Add the Moonbase Alpha network specification moonbase: { type: "http", chainType: "generic", url: configVariable("MOONBASE_RPC_URL"), chainId: {{ networks.moonbase.chain_id }}, // {{ networks.moonbase.hex_chain_id }} in hex accounts: [configVariable("MOONBASE_PRIVATE_KEY")], }, dev: { type: "http", chainType: "generic", url: configVariable("DEV_RPC_URL"), chainId: 1281, // 0x501 in hex accounts: [ configVariable("DEV_PRIVATE_KEY"), configVariable("ALICE_PRIVATE_KEY"), // Alice (Alith) account configVariable("BOB_PRIVATE_KEY") // Bob (Baltathar) account ], }, moonbeam: { type: "http", chainType: "generic", url: configVariable("MOONBEAM_RPC_URL"), chainId: {{ networks.moonbeam.chain_id }}, // {{ networks.moonbeam.hex_chain_id }} in hex accounts: [configVariable("MOONBEAM_PRIVATE_KEY")], }, }, // 4. Set up your Etherscan API key for contract verification // Moonbeam and Moonbase Alpha use the same Etherscan API key etherscan: { apiKey: { moonbaseAlpha: configVariable("ETHERSCAN_API_KEY"), moonbeam: configVariable("ETHERSCAN_API_KEY"), }, }, }; ``` !!! note Any real funds sent to the Alice and Bob development accounts will be lost immediately.Take precautions never to send MainNet funds to exposed development accounts. The private keys for these accounts are: - Alice (Alith): `0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133` - Bob (Baltathar): `0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b` These accounts should only be used on the local development node and never on Moonbeam MainNet or Moonbase Alpha. You're now ready to move on to compilation and testing. ## Compiling the Contract {: #compiling-the-contract } Now that you have your Hardhat project set up with the encrypted secrets manager, you can proceed with compilation and testing. The project comes with a sample contract and test file that you can use to verify your setup. ### Compiling the Contract {: #compiling-the-contract } To compile the sample contract, run: ```bash npx hardhat compile ```
npx hardhat compile Compiled 8 Solidity files successfully (evm target: paris).
After compilation, an `artifacts` directory is created: it holds the bytecode and metadata of the contract, which are `.json` files. Adding this directory to your `.gitignore` is a good idea. ## Testing {: #testing } A robust smart contract development workflow is complete with a testing suite. Hardhat has a number of tools that make it easy to write and run tests. In this section, you'll learn the basics of testing your smart contracts and some more advanced techniques. Hardhat tests are typically written with Mocha and Chai. [Mocha](https://mochajs.org){target=\_blank} is a JavaScript testing framework and [Chai](https://www.chaijs.com){target=\_blank} is a BDD/TDD JavaScript assertion library. BDD/TDD stands for behavior and test-driven development respectively. Effective BDD/TDD necessitates writing your tests *before* writing your smart contract code. The structure of this tutorial doesn't strictly follow these guidelines, but you may wish to adopt these principles in your development workflow. Hardhat recommends using [Hardhat Toolbox](https://hardhat.org/hardhat-runner/docs/advanced/migrating-from-hardhat-waffle){target=\_blank}, a plugin that bundles everything you need to get started with Hardhat, including Mocha and Chai. Because we will initially be running our tests on a local Moonbeam node, we need to specify Alice's address as the address of our target collator (Alice's account is the only collator for a local development node): ```text 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac ``` If instead you prefer to run your tests against Moonbase Alpha, you can choose the below collator, or [any other collator on Moonbase Alpha](https://apps.moonbeam.network/moonbase-alpha/staking){target=\_blank} you would like the DAO to delegate to: ```text {{ networks.moonbase.staking.candidates.address1 }} ``` ### Configuring the Test File {: #configuring-the-test-file } To set up your test file, take the following steps: 1. Create a `tests` directory ```bash mkdir tests ``` 2. Create a new file called `Dao.js` ```bash touch tests/Dao.js ``` 3. Then copy and paste the contents below to set up the initial structure of your test file. Be sure to read the comments, as they can clarify the purpose of each line ```javascript // Import Ethers const { ethers } = require('hardhat'); // Import Chai to use its assertion functions here const { expect } = require('chai'); // Indicate Alice's address as the target collator on local development node const targetCollator = '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac'; ``` ### Deploying a Staking DAO for Testing {: #deploying-a-staking-dao-for-testing } Before we can run any test cases we'll need to launch a staking DAO with an initial configuration. Our setup here is relatively simple - we'll be deploying a staking DAO with a single administrator (the deployer) and then adding a new member to the DAO. This simple setup is perfect for demonstration purposes, but it's easy to imagine more complex configurations you'd like to test, such as a scenario with 100 DAO members or one with multiple admins of the DAO. Mocha's `describe` function enables you to organize your tests. Multiple `describe` functions can be nested together. It's entirely optional but can be useful, especially in complex projects with many test cases. You can read more about constructing tests and [getting started with Mocha](https://mochajs.org/#getting-started){target=\_blank} on the Mocha docs site. We'll define a function called `deployDao` containing the setup steps for our staking DAO. To configure your test file, add the following snippet: ```javascript // The describe function receives the name of a section of your test suite, and a callback. The callback must define the tests of that section. This callback can't be an async function describe('Dao contract', function () { let wallet1, wallet2; before(async function () { // Get signers we defined in Hardhat config const signers = await ethers.getSigners(); wallet1 = signers[0]; wallet2 = signers[1]; }); async function deployDao() { const delegationDaoFactory = await ethers.getContractFactory( 'DelegationDAO', wallet2 ); // Deploy the staking DAO and wait for the deployment transaction to be confirmed try { const deployedDao = await delegationDaoFactory.deploy( targetCollator, wallet2.address ); await deployedDao.waitForDeployment(); // Wait for the transaction to be mined return { deployedDao }; } catch (error) { console.error('Failed to deploy contract:', error); return null; // Return null to indicate failure } } // Insert additional tests here }); ``` ### Writing your First Test Cases {: #writing-your-first-test-cases } First, you'll create a subsection called `Deployment` to keep the test file organized. This will be nested within the `Dao contract` describe function. Next, you'll define your first test case by using the `it` Mocha function. This first test checks to see that the staking DAO correctly stores the address of the target collator. Add the snippet below to the end of your `Dao contract` function. ```javascript // You can nest calls to create subsections describe('Deployment', function () { // Mocha's it function is used to define each of your tests. It receives the test name, and a callback function. If the callback function is async, Mocha will await it. Test case to check that the correct target collator is stored it('should store the correct target collator in the DAO', async function () { const deployment = await deployDao(); if (!deployment || !deployment.deployedDao) { throw new Error('Deployment failed; DAO contract was not deployed.'); } const { deployedDao } = deployment; // The expect function receives a value and wraps it in an assertion object. // This test will pass if the DAO stored the correct target collator expect(await deployedDao.getTarget()).to.equal( '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac' ); }); // The following test cases should be added here }); ``` Now, add another test case. When a staking DAO is launched, it shouldn't have any funds. This test verifies that is indeed the case. Go ahead and add the following test case to your `Dao.js` file: ```javascript // Test case to check that the DAO has 0 funds at inception it('should initially have 0 funds in the DAO', async function () { const { deployedDao } = await deployDao(); // This test will pass if the DAO has no funds as expected before any contributions expect(await deployedDao.totalStake()).to.equal(0); }); ``` ### Function Reverts {: #function-reverts } Now, you'll implement a more complex test case with a slightly different architecture. In prior examples, you've verified that a function returns an expected value. In this one, you'll be verifying that a function reverts. You'll also change the caller's address to test an admin-only function. In the [staking DAO contract](https://github.com/moonbeam-foundation/moonbeam-intro-course-resources/blob/main/delegation-dao-lesson-one/DelegationDAO.sol){target=\_blank}, only admins are authorized to add new members to the DAO. One could write a test that checks to see if the admin is authorized to add new members but a more important test is to ensure that *non-admins* can't add new members. To run this test case under a different account, you will ask for another address when you call `ethers.getSigners()` and specify the caller in the assertion with `connect(member1)`. Finally, after the function call you'll append `.to.be.reverted` to indicate that the test case is successful if the function reverts. And if it doesn't revert, it's a failed test! ```javascript // Test case to check that non-admins cannot grant membership it('should not allow non-admins to grant membership', async function () { const { deployedDao } = await deployDao(); // Connect the non-admin wallet to the deployed contract const deployedDaoConnected = deployedDao.connect(wallet1); const tx = deployedDaoConnected.grant_member( '0x0000000000000000000000000000000000000000' ); // Check that the transaction reverts, not specifying any particular reason await expect(tx).to.be.reverted; }); ``` ### Signing Transactions from Other Accounts {: #signing-transactions-from-other-accounts } For this example, you'll verify whether the newly added DAO member can call the `check_free_balance()` function of staking DAO, which has an access modifier such that only members can access it. ```javascript // Test case to check that members can access member only functions it('should only allow members to access member-only functions', async function () { const { deployedDao } = await deployDao(); // Connect the wallet1 to the deployed contract and grant membership const deployedDaoConnected = deployedDao.connect(wallet2); const grantTx = await deployedDaoConnected.grant_member(wallet1.address); await grantTx.wait(); // Check the free balance using the member's credentials const checkTx = deployedDaoConnected.check_free_balance(); // Since check_free_balance() does not modify state, we expect it not to be reverted and check the balance await expect(checkTx).to.not.be.reverted; expect(await checkTx).to.equal(0); }); ``` And that's it! You're now ready to run your tests! ### Running your Tests {: #running-your-tests } If you've followed all of the prior sections, your [`Dao.js`](https://raw.githubusercontent.com/moonbeam-foundation/moonbeam-intro-course-resources/main/delegation-dao-lesson-one/Dao.js){target=\_blank} test file should be all set to go. ??? code "Dao.js" ```js // Import Ethers const { ethers } = require('hardhat'); // Import Chai to use its assertion functions here const { expect } = require('chai'); // Indicate the collator the DAO wants to delegate to // For Moonbase Local Node, use: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac // For Moonbase Alpha, use: 0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5 const targetCollator = 'INSERT_COLLATOR_ADDRESS'; // The describe function receives the name of a section of your test suite, and a // callback. The callback must define the tests of that section. This callback // can't be an async function describe('Dao contract', function () { let wallet1, wallet2; before(async function () { // Get signers we defined in Hardhat config const signers = await ethers.getSigners(); wallet1 = signers[0]; wallet2 = signers[1]; }); async function deployDao() { const delegationDaoFactory = await ethers.getContractFactory( 'DelegationDAO', wallet2 ); // Deploy the staking DAO and wait for the deployment transaction to be confirmed try { const deployedDao = await delegationDaoFactory.deploy( targetCollator, wallet2.address ); await deployedDao.waitForDeployment(); // Correct way to wait for the transaction to be mined return { deployedDao }; } catch (error) { console.error('Failed to deploy contract:', error); return null; // Return null to indicate failure } } describe('Deployment', function () { // Test case to check that the correct target collator is stored it('should store the correct target collator in the DAO', async function () { const deployment = await deployDao(); if (!deployment || !deployment.deployedDao) { throw new Error('Deployment failed; DAO contract was not deployed.'); } const { deployedDao } = deployment; expect(await deployedDao.getTarget()).to.equal( '0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac' ); }); // Test case to check that the DAO has 0 funds at inception it('should initially have 0 funds in the DAO', async function () { const { deployedDao } = await deployDao(); expect(await deployedDao.totalStake()).to.equal(0); }); // Test case to check that non-admins cannot grant membership it('should not allow non-admins to grant membership', async function () { const { deployedDao } = await deployDao(); // Connect the non-admin wallet to the deployed contract const deployedDaoConnected = deployedDao.connect(wallet1); const tx = deployedDaoConnected.grant_member( '0x0000000000000000000000000000000000000000' ); // Check that the transaction reverts, not specifying any particular reason await expect(tx).to.be.reverted; }); // Test case to check that members can access member only functions it('should only allow members to access member-only functions', async function () { const { deployedDao } = await deployDao(); // Connect the wallet1 to the deployed contract and grant membership const deployedDaoConnected = deployedDao.connect(wallet2); const grantTx = await deployedDaoConnected.grant_member(wallet1.address); await grantTx.wait(); // Check the free balance using the member's credentials const checkTx = deployedDaoConnected.check_free_balance(); // Since check_free_balance() does not modify state, we expect it not to be reverted and check the balance await expect(checkTx).to.not.be.reverted; expect(await checkTx).to.equal(0); }); }); }); ``` Since our test cases encompass mostly configuration and setup of the staking DAO and don't involve actual delegation actions, we'll be running our tests on a Moonbeam development node (local node). Remember that Alice (`0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac`) is the only collator on a local development node. You can use the flag `--network moonbase` to run the tests using Moonbase Alpha. In that case, ensure your deployer address is sufficiently funded with DEV tokens. !!! challenge Try to create an additional test case that verifies the staking DAO successfully delegates to a collator once `minDelegationStk` is met. You must test this on Moonbase Alpha rather than a local development node. First, make sure that your local Moonbeam node is running by following the [instructions for launching a local development node](/builders/get-started/networks/moonbeam-dev/){target=\_blank}. Take precautions because you could inadvertently send real funds to the Alice and Bob development accounts, resulting in a loss of those funds. You can run your tests with the following command: ```bash npx hardhat test --network dev tests/Dao.js ``` If everything was set up correctly, you should see output like the following:
npx hardhat test --network dev tests/Dao.js

Dao contract Deployment ✅ The DAO should store the correct target collator (1624ms) ✅ The DAO should initially have 0 funds in it ✅ Non-admins should not be able to grant membership (150ms) ✅ DAO members should be able to access member only functions (132ms)

✅ 4 passing (2s)
## Deploying to Moonbase Alpha {: #deploying-to-moonbase-alpha } In the following steps, we'll deploy the `DelegationDAO` to the Moonbase Alpha TestNet. Before deploying to Moonbase Alpha or Moonbeam, double-check that you're not using the Alice and Bob accounts, which should only be used on a local development node. As a side note, `DelegationDAO` relies on [`StakingInterface.sol`](/builders/ethereum/precompiles/features/staking/){target=\_blank}, which is a Substrate-based offering unique to Moonbeam networks. The Hardhat Network and forked networks are simulated EVM environments which do not include the Substrate-based precompiles like `StakingInterface.sol`. Therefore, `DelegationDAO` will not work properly if deployed to the local default Hardhat Network or a [forked network](/builders/ethereum/dev-env/hardhat/#forking-moonbeam){target=\_blank}. To deploy `DelegationDAO`, you'll use Hardhat Ignition, a declarative framework for deploying smart contracts. Hardhat Ignition is designed to make managing recurring tasks surrounding smart contract deployment and testing easy. For more information about Hardhat Ignition and its architecture, be sure to check out the [Hardhat Ignition docs](https://hardhat.org/ignition/docs/getting-started#overview){target=\_blank}. To set up the proper file structure for your Ignition module, change to the ignition directory and create the DelegationDao.js file: ```sh cd ignition/modules && touch DelegationDao.js ``` Next, you can write your Hardhat Ignition module. To get started, take the following steps: 1. Import the `buildModule` function from the Hardhat Ignition module 2. Export a module using `buildModule` 3. Specify the target collator candidate for the DAO to delegate to 4. Use the `getAccount` method to select the deployer account 5. Deploy `DelegationDAO.sol` 6. Return an object from the module. This makes the `DelegationDao` contract accessible for interaction in Hardhat tests and scripts When all is said and done your deployment script should look similar to the following: ```javascript // 1. Import the required function from the Hardhat Ignition module import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; // 2. Define and export your deployment module using `buildModule` const DelegationDAOModule = buildModule('DelegationDAOModule', (m) => { // 3. Specify the target collator address for the DAO const targetCollator = '0x12E7BCCA9b1B15f33585b5fc898B967149BDb9a5'; // 4. Use the `getAccount` method to select the deployer account const deployer = m.getAccount(0); // 5. Deploy the `DelegationDAO` contract const delegationDao = m.contract( 'DelegationDAO', [targetCollator, deployer], { from: deployer, } ); // 6. Return an object from the module including references to deployed contracts, allowing the contract to be accessible for interaction in Hardhat tests and scripts return { delegationDao }; }); // Export the module as default export default DelegationDAOModule; ``` To run the script and deploy the `DelegationDAO.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, Hardhat will deploy the contract to a local Hardhat network by default. ```sh npx hardhat ignition deploy ./DelegationDao.js --network moonbase --deployment-id INSERT_YOUR_NAME ``` You'll be prompted to confirm the network you wish to deploy to. After a few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal.
npx hardhat ignition deploy ./DelegationDao.js --network moonbase --deployment-id INSERT_YOUR_NAME
✅ Confirm deploy to network moonbase (1287)? … yes Hardhat Ignition 🚀
Deploying [ DelegationDAOModule ]
Batch #1 Executed DelegationDAOModule#DelegationDAO
[ DelegationDAOModule ] successfully deployed 🚀
Deployed Addresses
DelegationDAOModule#DelegationDAO - 0x69c555fE1A8D0916E6dab0629bd7530D4d2Be4D1
Congratulations, your contract is live on Moonbase Alpha! Save the address, as you will use it to interact with this contract instance in the next step. ## Verifying Contracts on Moonbase Alpha {: #verifying-contracts-on-moonbase-alpha } Contract verification is an essential step of any developer's workflow, particularly in the theoretical example of this staking DAO. Potential participants in the DAO need to be assured that the smart contract works as intended - and verifying the contract allows anyone to observe and analyze the deployed smart contract. While it's possible to verify smart contracts on the [Moonscan website](https://moonscan.io/verifyContract){target=\_blank}, the Hardhat Etherscan plugin enables us to verify our staking DAO in a faster and easier manner. It's not an exaggeration to say that the plugin dramatically simplifies the contract verification process, especially for projects that include multiple Solidity files or libraries. Before beginning the contract verification process, you'll need to [acquire an Etherscan API Key](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank}. Note that Moonbeam, Moonriver, and Moonbase Alpha all use the same unified [Etherscan](https://etherscan.io){target=\_blank} API key. To verify the contract, you will run the `ignition verify` command and pass the name of your deployment you set in the prior step. ```bash npx hardhat ignition verify INSERT_YOUR_NAME ``` !!! note If you're deploying `DelegationDAO.sol` verbatim without any changes, you may get an `Already Verified` error because Moonscan automatically recognizes and verifies smart contracts that have matching bytecode. Your contract will still show as verified, so there is nothing else you need to do. However, if you'd prefer to verify your own `DelegationDAO.sol`, you can make a small change to the contract (such as changing a comment) and repeating the compilation, deployment and verification steps. In your terminal, you should see the source code for your contract was successfully submitted for verification. If the verification was successful, you should see **Successfully verified contract** and there will be a link to the contract code on [Moonscan for Moonbase Alpha](https://moonbase.moonscan.io){target=\_blank}. If the plugin returns an error, double check that your API key is configured correctly and that you have specified all necessary parameters in the verification command. You can refer to the [guide to the Hardhat Etherscan plugin](/builders/ethereum/verify-contracts/etherscan-plugins/){target=\_blank} for more information.
npx hardhat ignition verify INSERT_YOUR_NAME
Nothing to compile Successfully submitted source code for contract contracts/DelegationDAO.sol:DelegationDAO at 0x5D788B98E4A90F9642352B0b32694998e77cF4d7 for verification on the block explorer. Waiting for verification result...
Successfully verified contract DelegationDAO on Etherscan.
https://moonbase.moonscan.io/address/0x5D788B98E4A90F9642352B0b32694998e77cF4d7#code
## Deploying to Production on Moonbeam Mainnet {: #deploying-to-production-on-moonbeam-mainnet } !!! note `DelegationDAO.sol` is unreviewed and unaudited. It is designed only for demonstration purposes and not intended for production use. It may contain bugs or logic errors that could result in loss of funds. In the following steps, we'll be deploying the `DelegationDAO` contract to the Moonbeam MainNet network. Remember to add the Moonbeam network to your [`hardhat.config.js`](#hardhat-configuration-file) and update the private keys of your accounts on Moonbeam if you haven't done so already. Before deploying `DelegationDAO` to Moonbeam, we need to change the address of the target collator, since our target collator on Moonbase Alpha does not exist on Moonbeam. Head to your deploy script and change the target collator to `{{ networks.moonbeam.staking.candidates.address1 }}` or [another Moonbeam collator](https://apps.moonbeam.network/moonbeam/staking){target=\_blank} of your choice. Your deployment script, named `DelegationDao.js`, should thus look like the following: ```javascript // 1. Import the required function from the Hardhat Ignition module import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'; // 2. Define and export your deployment module using `buildModule` const DelegationDAOModule = buildModule('DelegationDAOModule', (m) => { // 3. Specify the target collator address for the DAO const targetCollator = '0x1C86E56007FCBF759348dcF0479596a9857Ba105'; // 4. Use the `getAccount` method to select the deployer account const deployer = m.getAccount(0); // 5. Deploy the `DelegationDAO` contract const delegationDao = m.contract( 'DelegationDAO', [targetCollator, deployer], { from: deployer, } ); // 6. Return an object from the module including references to deployed contracts, allowing the contract to be accessible for interaction in Hardhat tests and scripts return { delegationDao }; }); // Export the module as default export default DelegationDAOModule; ``` To run the script and deploy the `DelegationDAO.sol` contract, use the following command, which requires you to specify the network name as defined in your `hardhat.config.js`. If you don't specify a network, Hardhat will deploy the contract to a local Hardhat network by default. ```sh npx hardhat ignition deploy ./ignition/modules/DelegationDao.js --network moonbeam --deployment-id INSERT_YOUR_NAME ``` You'll be prompted to confirm the network you wish to deploy to. After a few seconds after you confirm, the contract is deployed, and you'll see the contract address in the terminal.
npx hardhat ignition deploy ./DelegationDao.js --network moonbeam --deployment-id INSERT_YOUR_NAME
✅ Confirm deploy to network moonbeam (1284)? … yes Hardhat Ignition 🚀
Deploying [ DelegationDAOModule ]
Batch #1 Executed DelegationDAOModule#DelegationDAO
[ DelegationDAOModule ] successfully deployed 🚀
Deployed Addresses
DelegationDAOModule#DelegationDAO - 0x6D895A55F5ba31e582bCEe71cae394266F240e9b
Congratulations, your contract is live on Moonbeam! Save the address, as you will use it to interact with this contract instance in the next step. ## Verifying Contracts on Moonbeam {: #verifying-contracts-on-moonbeam } In this section, we'll be verifying the contract that was just deployed on Moonbeam. Before beginning the contract verification process, you'll need to [acquire an Etherscan API Key](/builders/ethereum/verify-contracts/etherscan-plugins/#generating-an-etherscan-api-key){target=\_blank}. Note that Moonbeam, Moonriver, and Moonbase Alpha all use the same unified [Etherscan](https://etherscan.io){target=\_blank} API key. To verify the contract, you will run the `ignition verify` command and pass the name of your deployment you set in the prior step. ```bash npx hardhat ignition verify INSERT_YOUR_NAME ``` !!! note If you're deploying `DelegationDAO.sol` verbatim without any changes, you may get an `Already Verified` error because Moonscan automatically recognizes and verifies smart contracts that have matching bytecode. Your contract will still show as verified, so there is nothing else you need to do. However, if you'd prefer to verify your own `DelegationDAO.sol`, you can make a small change to the contract (such as changing a comment) and repeating the compilation, deployment, and verification steps. In your terminal you should see the source code for your contract was successfully submitted for verification. If the verification was successful, you should see **Successfully verified contract** and there will be a link to the contract code on [Moonbeam Moonscan](https://moonscan.io){target=\_blank}. If the plugin returns an error, double check that your API key is configured correctly and that you have specified all necessary parameters in the verification command. You can refer to the [guide to the Hardhat Etherscan plugin](/builders/ethereum/verify-contracts/etherscan-plugins/){target=\_blank} for more information.
npx hardhat ignition verify INSERT_YOUR_NAME
Nothing to compile Successfully submitted source code for contract contracts/DelegationDAO.sol:DelegationDAO at 0x6D895A55F5ba31e582bCEe71cae394266F240e9b for verification on the block explorer. Waiting for verification result...
Successfully verified contract DelegationDAO on Etherscan.
https://moonbeam.moonscan.io/address/0x6D895A55F5ba31e582bCEe71cae394266F240e9b#code
And that's it! We covered a lot of ground in this tutorial, but there's more resources available if you'd like to go deeper, including the following: - [Hardhat guide to Testing Contracts](https://hardhat.org/hardhat-runner/docs/guides/test-contracts){target=\_blank} - [Writing tasks and scripts](https://hardhat.org/hardhat-runner/docs/guides/tasks){target=\_blank}
This tutorial is for educational purposes only. As such, any contracts or code created in this tutorial should not be used in production.
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 --- ## 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 ---