Overview of the Precompiled Contracts on Moonbeam¶
Overview¶
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. The EVM pallet includes the standard precompiles found on Ethereum and some additional precompiles that are not specific to Ethereum. It also provides the ability to create and execute custom precompiles through the generic Precompiles
trait. There are several custom Moonbeam-specific precompiles that have been created, all of which can be found in the Moonbeam codebase.
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:
Note
There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the Security Considerations page for more information.
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
- 1024-2047 - precompiles that are not in Ethereum and not Moonbeam specific
- 2048-4095 - Moonbeam specific precompiles
Ethereum MainNet Precompiles¶
Contract | Address |
---|---|
ECRECOVER | 0x0000000000000000000000000000000000000001 |
SHA256 | 0x0000000000000000000000000000000000000002 |
RIPEMD160 | 0x0000000000000000000000000000000000000003 |
Identity | 0x0000000000000000000000000000000000000004 |
Modular Exponentiation | 0x0000000000000000000000000000000000000005 |
BN128Add | 0x0000000000000000000000000000000000000006 |
BN128Mul | 0x0000000000000000000000000000000000000007 |
BN128Pairing | 0x0000000000000000000000000000000000000008 |
Blake2 | 0x0000000000000000000000000000000000000009 |
P256Verify | 0x0000000000000000000000000000000000000100 |
Contract | Address |
---|---|
ECRECOVER | 0x0000000000000000000000000000000000000001 |
SHA256 | 0x0000000000000000000000000000000000000002 |
RIPEMD160 | 0x0000000000000000000000000000000000000003 |
Identity | 0x0000000000000000000000000000000000000004 |
Modular Exponentiation | 0x0000000000000000000000000000000000000005 |
BN128Add | 0x0000000000000000000000000000000000000006 |
BN128Mul | 0x0000000000000000000000000000000000000007 |
BN128Pairing | 0x0000000000000000000000000000000000000008 |
Blake2 | 0x0000000000000000000000000000000000000009 |
P256Verify | 0x0000000000000000000000000000000000000100 |
Contract | Address |
---|---|
ECRECOVER | 0x0000000000000000000000000000000000000001 |
SHA256 | 0x0000000000000000000000000000000000000002 |
RIPEMD160 | 0x0000000000000000000000000000000000000003 |
Identity | 0x0000000000000000000000000000000000000004 |
Modular Exponentiation | 0x0000000000000000000000000000000000000005 |
BN128Add | 0x0000000000000000000000000000000000000006 |
BN128Mul | 0x0000000000000000000000000000000000000007 |
BN128Pairing | 0x0000000000000000000000000000000000000008 |
Blake2 | 0x0000000000000000000000000000000000000009 |
P256Verify | 0x0000000000000000000000000000000000000100 |
Non-Moonbeam Specific nor Ethereum Precompiles¶
Contract | Address |
---|---|
SHA3FIPS256 | 0x0000000000000000000000000000000000000400 |
Dispatch [Removed] | 0x0000000000000000000000000000000000000401 |
ECRecoverPublicKey | 0x0000000000000000000000000000000000000402 |
Contract | Address |
---|---|
SHA3FIPS256 | 0x0000000000000000000000000000000000000400 |
Dispatch [Removed] | 0x0000000000000000000000000000000000000401 |
ECRecoverPublicKey | 0x0000000000000000000000000000000000000402 |
Contract | Address |
---|---|
SHA3FIPS256 | 0x0000000000000000000000000000000000000400 |
Dispatch [Removed] | 0x0000000000000000000000000000000000000401 |
ECRecoverPublicKey | 0x0000000000000000000000000000000000000402 |
StorageCleaner | 0x0000000000000000000000000000000000000403 |
Moonbeam Specific Precompiles¶
Contract | Address |
---|---|
Parachain Staking | 0x0000000000000000000000000000000000000800 |
Crowdloan Rewards | 0x0000000000000000000000000000000000000801 |
ERC-20 Interface | 0x0000000000000000000000000000000000000802 |
Democracy [Removed] | 0x0000000000000000000000000000000000000803 |
X-Tokens | 0x0000000000000000000000000000000000000804 |
Relay Encoder | 0x0000000000000000000000000000000000000805 |
XCM Transactor V1 | 0x0000000000000000000000000000000000000806 |
Author Mapping | 0x0000000000000000000000000000000000000807 |
Batch | 0x0000000000000000000000000000000000000808 |
Randomness | 0x0000000000000000000000000000000000000809 |
Call Permit | 0x000000000000000000000000000000000000080a |
Proxy | 0x000000000000000000000000000000000000080b |
XCM Utilities | 0x000000000000000000000000000000000000080C |
XCM Transactor V2 | 0x000000000000000000000000000000000000080d |
Council Collective [Removed] | 0x000000000000000000000000000000000000080e |
Technical Committee Collective [Removed] | 0x000000000000000000000000000000000000080f |
Treasury Council Collective | 0x0000000000000000000000000000000000000810 |
Referenda | 0x0000000000000000000000000000000000000811 |
Conviction Voting | 0x0000000000000000000000000000000000000812 |
Preimage | 0x0000000000000000000000000000000000000813 |
OpenGov Tech Committee | 0x0000000000000000000000000000000000000814 |
Precompile Registry | 0x0000000000000000000000000000000000000815 |
GMP | 0x0000000000000000000000000000000000000816 |
XCM Transactor V3 | 0x0000000000000000000000000000000000000817 |
XCM interface | 0x000000000000000000000000000000000000081A |
Identity | 0x0000000000000000000000000000000000000818 |
Contract | Address |
---|---|
Parachain Staking | 0x0000000000000000000000000000000000000800 |
Crowdloan Rewards | 0x0000000000000000000000000000000000000801 |
ERC-20 Interface | 0x0000000000000000000000000000000000000802 |
Democracy [Disabled] | 0x0000000000000000000000000000000000000803 |
X-Tokens | 0x0000000000000000000000000000000000000804 |
Relay Encoder | 0x0000000000000000000000000000000000000805 |
XCM Transactor V1 | 0x0000000000000000000000000000000000000806 |
Author Mapping | 0x0000000000000000000000000000000000000807 |
Batch | 0x0000000000000000000000000000000000000808 |
Randomness | 0x0000000000000000000000000000000000000809 |
Call Permit | 0x000000000000000000000000000000000000080a |
Proxy | 0x000000000000000000000000000000000000080b |
XCM Utilities | 0x000000000000000000000000000000000000080C |
XCM Transactor V2 | 0x000000000000000000000000000000000000080d |
Council Collective [Removed] | 0x000000000000000000000000000000000000080e |
Technical Committee Collective [Removed] | 0x000000000000000000000000000000000000080f |
Treasury Council Collective | 0x0000000000000000000000000000000000000810 |
Referenda | 0x0000000000000000000000000000000000000811 |
Conviction Voting | 0x0000000000000000000000000000000000000812 |
Preimage | 0x0000000000000000000000000000000000000813 |
OpenGov Tech Committee | 0x0000000000000000000000000000000000000814 |
Precompile Registry | 0x0000000000000000000000000000000000000815 |
GMP | 0x0000000000000000000000000000000000000816 |
XCM Transactor V3 | 0x0000000000000000000000000000000000000817 |
XCM interface | 0x000000000000000000000000000000000000081A |
Identity | 0x0000000000000000000000000000000000000818 |
Contract | Address |
---|---|
Parachain Staking | 0x0000000000000000000000000000000000000800 |
Crowdloan Rewards | 0x0000000000000000000000000000000000000801 |
ERC-20 Interface | 0x0000000000000000000000000000000000000802 |
Democracy [Removed] | 0x0000000000000000000000000000000000000803 |
X-Tokens | 0x0000000000000000000000000000000000000804 |
Relay Encoder | 0x0000000000000000000000000000000000000805 |
XCM Transactor V1 | 0x0000000000000000000000000000000000000806 |
Author Mapping | 0x0000000000000000000000000000000000000807 |
Batch | 0x0000000000000000000000000000000000000808 |
Randomness | 0x0000000000000000000000000000000000000809 |
Call Permit | 0x000000000000000000000000000000000000080a |
Proxy | 0x000000000000000000000000000000000000080b |
XCM Utilities | 0x000000000000000000000000000000000000080C |
XCM Transactor V2 | 0x000000000000000000000000000000000000080d |
Council Collective [Removed] | 0x000000000000000000000000000000000000080e |
Technical Committee Collective [Removed] | 0x000000000000000000000000000000000000080f |
Treasury Council Collective | 0x0000000000000000000000000000000000000810 |
Referenda | 0x0000000000000000000000000000000000000811 |
Conviction Voting | 0x0000000000000000000000000000000000000812 |
Preimage | 0x0000000000000000000000000000000000000813 |
OpenGov Tech Committee | 0x0000000000000000000000000000000000000814 |
Precompile Registry | 0x0000000000000000000000000000000000000815 |
GMP | 0x0000000000000000000000000000000000000816 |
XCM Transactor V3 | 0x0000000000000000000000000000000000000817 |
XCM Interface | 0x000000000000000000000000000000000000081A |
Identity | 0x0000000000000000000000000000000000000818 |
| Created: November 1, 2022