Network 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 section of this guide.
Moonbeam¶
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
1RPC |
| 10k req/day |
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
1RPC |
| 10k req/day |
Moonriver¶
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
Moonbase Alpha¶
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
Moonbeam Foundation |
| 25 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
Provider | RPC URL | Limits |
---|---|---|
Blast |
| 80 req/sec |
Dwellir |
| 20 req/sec |
OnFinality |
| 40 req/sec |
Moonbeam Foundation |
| 25 req/sec |
UnitedBloc |
| 32 req/sec |
RadiumBlock |
| 200 req/sec |
Relay Chain¶
To connect to the Moonbase Alpha relay chain, you can use the following WS Endpoint:
Provider | RPC URL |
---|---|
OpsLayer |
|
RPC Endpoint Providers¶
You can create your own endpoint suitable for development or production use using any of the following API providers:
1RPC¶
1RPC 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 official site to set it up!
Blast¶
As a user of Blast 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, 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:
- Create a new project
- Click on Available Endpoints
- Select a network for your endpoint. There are three options to choose from: Moonbeam, Moonriver and Moonbase Alpha
- Confirm the selected network and Press Activate
- You'll now see your chosen network under Active Endpoints. Click on the network and you'll see your custom RPC and WSS endpoints on the next page
Dwellir¶
Dwellir 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:
- Visit Dwellir
- Submit your email and your node request
GetBlock¶
GetBlock is a service that provides instant API access to Moonbeam and Moonriver and is available through shared and dedicated nodes. Dedicated nodes provide access to a private server with fast speeds and without rate limits. Shared nodes provide a free API key based endpoint for you to get started quickly.
To get started with GetBlock and obtain an API key, you can go the GetBlock registration page and sign up. From the GetBlock Dashboard, you can view and manage your existing API keys and create new API keys.
Creating a new API key is simple, all you have to do is:
- Click Create a new API key
- Enter a name for your API key
- Click Create to generate your API key
OnFinality¶
OnFinality 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 and sign up, or if you already have signed up you can go ahead and log in. From the OnFinality Dashboard, you can:
- Click on API Service
- Select the network from the dropdown
- Your custom API endpoint will be generated automatically
Pocket Network¶
Pocket Network is a decentralized node service that provides a free personal endpoint to DApps on Moonbeam & Moonriver.
To get your own endpoint, go to Pocket Network and sign up or log in. From the Portal, you can:
- Click on Apps
- Select Create
- Enter the name of your DApp and select your corresponding network
- Your new endpoint will be generated and displayed for you in the following app screen
You don't have to generate a new DApp for every endpoint! You can add a new chain to your preexisting DApp:
- Click on your preexisting app in the Apps menu
- In the Endpoint section, select the Add new button and search for your desired network in the dropdown
- Your new endpoint will be generated and displayed for you
UnitedBloc¶
UnitedBloc 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 with some cool metrics.
Check the public endpoints section to get the relevant URL. You can contact them via their Telegram channel, or read more about their initiative on their blogpost page.
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 or compile the binary. 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 (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:
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 is100
milliseconds--lazy-loading-max-retries-per-request
- the maximum number of retries for an RPC request when using lazy loading. Default value is10
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:
[
{
"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:
[
{
"pallet": "System",
"storage": "Account",
"key": "TARGET_ADDRESS",
"value": "0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080"
}
]
Click to see more 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 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:
{
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:
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. 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:
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:
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:
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 Hexidecimal Little Endian encoded values to decimal, you can use this converter, 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 hexidecimal Little Endian value. When properly padded to fit into the SCALE encoded storage value, it becomes 69e10de76676d08000000000000000000
, such that the table now looks like:
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:
0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080
You can now specify the SCALE encoded override value in your state-overrides.json
file as follows:
[
{
"pallet": "System",
"storage": "Account",
"key": "0x3b939fead1557c741ff06492fd0127bd287a421e",
"value": "0x460c000002000000010000000600000069e10de76676d0800000000000000000040a556b0e032de12000000000000000004083a09e15c74c1b0100000000000000000000000000000000000000000000080"
}
]
To run lazy loading with the balance state override, you can use the following command:
--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
) 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.
[
{
"pallet": "EVM",
"storage": "AccountStorages",
"key": [
"0x931715FEE2d06333043d11F658C8CE934aC61D0c",
"0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342"
],
// Set whatever value you want here
"value": "0x000000000000000000000000000000000000000000000000000000012a05f200"
}
]
You can calculate the exact storage slot to override for your own account with the following script:
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-HERE";
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.
Override Wormhole BTC Token Balance
[
{
"pallet": "EVM",
"storage": "AccountStorages",
"key": [
"0xE57eBd2d67B462E9926e04a8e33f01cD0D64346D",
"0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342"
],
// Set whatever value you want here
"value": "0x000000000000000000000000000000000000000000000000000000012a05f200"
}
]
Override Wormhole ETH Token Balance
[
{
"pallet": "EVM",
"storage": "AccountStorages",
"key": [
"0xab3f0245B83feB11d15AAffeFD7AD465a59817eD",
"0x8c9902c0f94ae586c91ba539eb52087d3dd1578da91158308d79ff24a8d4f342"
],
// Set whatever value you want here
"value": "0x000000000000000000000000000000000000000000000000000000012a05f200"
}
]
Override WELL Token Balance
Because the WELL token 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:
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-HERE";
console.log(getBalanceSlot(address));
Thus, the storage override would be:
[
{
"pallet": "EVM",
"storage": "AccountStorages",
"key": [
"0x511aB53F793683763E5a8829738301368a2411E3",
"0x728d3daf4878939a6bb58cbc263f39655bb57ea15db7daa0b306f3bf2c3f1227"
],
// Set whatever value you want here
"value": "0x000000000000000000000000000000000000000000000000000000012a05f200"
}
]
Tracing RPC Endpoint 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 guide.
The following providers provide tracing RPC endpoints:
OnFinality¶
OnFinality'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.
To use the Trace API, you simply call the trace method of your choice from your private RPC endpoint. For a list of the supported networks and trace methods, please check out OnFinality's Trace API documentation.
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 post for more information on how to spin up your own dedicated trace node.
| Created: November 9, 2021