Ethereum-Native Precompiles¶
Introduction¶
Ethereum-native precompiles are special contract implementations that provide essential cryptographic and utility functions at the runtime level. These precompiles are available at predefined addresses and offer optimized, native implementations of commonly used operations that would be computationally expensive or impractical to implement in pure contract code.
In pallet-revive, these precompiles keep the standard Ethereum addresses, so contracts written for Ethereum can call them without changes.
How to Use Precompiles¶
To use a precompile in your smart contract, call the precompile's address as you would any other contract. Each precompile has a specific address (shown in the table below) and expects input data in a particular format. The precompile executes natively at the runtime level and returns the result directly to your contract.
For example, to use the ECRecover precompile to verify a signature, you would call address 0x0000000000000000000000000000000000000001 with the properly formatted signature data. The precompile handles the complex cryptographic operations efficiently and returns the recovered public key.
You can find sample contracts for each precompile in the precompiles-hardhat project.
Standard Precompiles in Polkadot Hub¶
Revive implements the standard set of Ethereum precompiles:
| Contract Name | Address (Last Byte) | Description |
|---|---|---|
| ECRecover | 0x01 | Recovers the public key associated with a signature |
| Sha256 | 0x02 | Implements the SHA-256 hash function |
| Ripemd160 | 0x03 | Implements the RIPEMD-160 hash function |
| Identity | 0x04 | Data copy function (returns input as output) |
| Modexp | 0x05 | Modular exponentiation |
| Bn128Add | 0x06 | Addition on the alt_bn128 curve |
| Bn128Mul | 0x07 | Multiplication on the alt_bn128 curve |
| Bn128Pairing | 0x08 | Pairing check on the alt_bn128 curve |
| Blake2F | 0x09 | Blake2 compression function F |
Conclusion¶
Ethereum-native precompiles give contracts on pallet-revive native implementations of common cryptographic and utility functions. Because they keep the standard Ethereum precompile addresses and interfaces, existing Ethereum knowledge and tools apply unchanged.
| Created: June 11, 2025