Moonbeam Custom API¶
Introduction¶
Moonbeam nodes include support for custom JSON-RPC endpoints:
moon_isBlockFinalizedmoon_isTxFinalizedmoon_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.
Supported Custom RPC Methods¶
moon_isBlockFinalized
Checks for the finality of the block given by its block hash.
block_hashstring - the hash of the block, accepts either Substrate-style or Ethereum-style block hash as its input
Returns a boolean: true if the block is finalized, false if the block is not finalized or not found.
curl -H "Content-Type: application/json" -X POST --data '{
"jsonrpc": "2.0",
"id": "1",
"method": "moon_isBlockFinalized",
"params": ["INSERT_BLOCK_HASH"]
}' https://rpc.api.moonbase.moonbeam.network
moon_isTxFinalized
Checks for the finality of a transaction given its EVM transaction hash.
tx_hashstring - the EVM transaction hash of the transaction
Returns a boolean: true if the transaction is finalized, false if the transaction is not finalized or not found.
curl -H "Content-Type: application/json" -X POST --data '{
"jsonrpc": "2.0",
"id": "1",
"method": "moon_isTxFinalized",
"params": ["INSERT_TRANSACTION_HASH"]
}' https://rpc.api.moonbase.moonbeam.network
moon_getEthSyncBlockRange
Returns the range of blocks that are fully indexed in Frontier's backend.
None
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" ]
curl -H "Content-Type: application/json" -X POST --data '{
"jsonrpc": "2.0",
"id": "1",
"method": "moon_getEthSyncBlockRange",
"params": []
}' https://rpc.api.moonbase.moonbeam.network
| Created: April 17, 2024