Skip to content

Overview of the Precompiled Contracts on Moonbeam

Precompiled Contracts Banner

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:

Precompiled Contracts 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:

Ethereum MainNet Precompiles

Contract Address
ECRECOVER 0x0000000000000000000000000000000000000001
SHA256 0x0000000000000000000000000000000000000002
RIPEMD160 0x0000000000000000000000000000000000000003
Identity 0x0000000000000000000000000000000000000004
Modular Exponentiation 0x0000000000000000000000000000000000000005
BN128Add 0x0000000000000000000000000000000000000006
BN128Mul 0x0000000000000000000000000000000000000007
BN128Pairing 0x0000000000000000000000000000000000000008
Blake2 0x0000000000000000000000000000000000000009

Non-Moonbeam Specific nor Ethereum Precompiles

Contract Address
SHA3FIPS256 0x0000000000000000000000000000000000000400
Dispatch 0x0000000000000000000000000000000000000401
ECRecoverPublicKey 0x0000000000000000000000000000000000000402

Moonbeam Specific Precompiles

Contract Address
Parachain Staking 0x0000000000000000000000000000000000000800
Crowdloan Rewards 0x0000000000000000000000000000000000000801
ERC-20 Interface 0x0000000000000000000000000000000000000802
Democracy 0x0000000000000000000000000000000000000803
X-Tokens 0x0000000000000000000000000000000000000804
Relay Encoder 0x0000000000000000000000000000000000000805
XCM Transactor 0x0000000000000000000000000000000000000806
Author Mapping 0x0000000000000000000000000000000000000807
Batch 0x0000000000000000000000000000000000000808
Randomness 0x0000000000000000000000000000000000000809
Call Permit 0x000000000000000000000000000000000000080a
XCM Utils 0x000000000000000000000000000000000000080C
Council Collective 0x000000000000000000000000000000000000080e
Technical Committee Collective 0x000000000000000000000000000000000000080f
Treasury Council Collective 0x0000000000000000000000000000000000000810
Contract Address
Parachain Staking 0x0000000000000000000000000000000000000800
Crowdloan Rewards 0x0000000000000000000000000000000000000801
ERC-20 Interface 0x0000000000000000000000000000000000000802
Democracy 0x0000000000000000000000000000000000000803
X-Tokens 0x0000000000000000000000000000000000000804
Relay Encoder 0x0000000000000000000000000000000000000805
XCM Transactor 0x0000000000000000000000000000000000000806
Author Mapping 0x0000000000000000000000000000000000000807
Batch 0x0000000000000000000000000000000000000808
Randomness 0x0000000000000000000000000000000000000809
Call Permit 0x000000000000000000000000000000000000080a
XCM Utils 0x000000000000000000000000000000000000080C
Council Collective 0x000000000000000000000000000000000000080e
Technical Committee Collective 0x000000000000000000000000000000000000080f
Treasury Council Collective 0x0000000000000000000000000000000000000810
Contract Address
Parachain Staking 0x0000000000000000000000000000000000000800
Crowdloan Rewards 0x0000000000000000000000000000000000000801
ERC-20 Interface 0x0000000000000000000000000000000000000802
Democracy 0x0000000000000000000000000000000000000803
X-Tokens 0x0000000000000000000000000000000000000804
Relay Encoder 0x0000000000000000000000000000000000000805
XCM Transactor Legacy 0x0000000000000000000000000000000000000806
Author Mapping 0x0000000000000000000000000000000000000807
Batch 0x0000000000000000000000000000000000000808
Randomness 0x0000000000000000000000000000000000000809
Call Permit 0x000000000000000000000000000000000000080a
Proxy 0x000000000000000000000000000000000000080b
XCM Utils 0x000000000000000000000000000000000000080C
XCM Transactor 0x000000000000000000000000000000000000080d
Council Collective 0x000000000000000000000000000000000000080e
Technical Committee Collective 0x000000000000000000000000000000000000080f
Treasury Council Collective 0x0000000000000000000000000000000000000810