35

Where can I find an authoritative/"official" listing of the pre-compiled contracts currently on the Ethereum network, along with their exact specifications? I couldn't find anything in the official documentation, but maybe I'm looking in the wrong place. Ideally, I'm looking for a list that will be kept up-to-date (as new EIPs will get approved).

2 Answers 2

35

Here are the precompiled contracts, the numbering is the address of the contract:

  1. Recovery of ECDSA signature
  2. Hash function SHA256
  3. Hash function RIPEMD160
  4. Identity
  5. Modular exponentiation (EIP 198)
  6. Addition on elliptic curve alt_bn128 (EIP 196)
  7. Scalar multiplication on elliptic curve alt_bn128 (EIP 196)
  8. Checking a pairing equation on curve alt_bn128 (EIP 197)
  9. BLAKE2b hash function (EIP 152)

A definitive list and specification is the Ethereum Yellow Paper.

The first 4:

... so-called ‘precompiled’ contracts, meant as a preliminary piece of architecture that may later become native extensions. The four contracts in addresses 1, 2, 3 and 4 execute the elliptic curve public key recovery function, the SHA2 256-bit hash scheme, the RIPEMD 160-bit hash scheme and the identity function respectively.

As the protocol is updated, the Yellow Paper will also get updated.

Here is a blog post with examples of using the next 4 precompiled contracts.

3
  • 2
    Thanks! Turns out Appendix E of the Yellow Paper is exactly what I was looking for. Apr 25, 2017 at 1:19
  • Why does the contract at address 1 not have any source code? etherscan.io/address/0x0000000000000000000000000000000000000001 is the source published somewhere?
    – pinhead
    Jun 15, 2017 at 19:21
  • 3
    @pinhead They don't have EVM bytecode: their source code is in the clients themselves, for example Geth
    – eth
    Jun 23, 2017 at 6:15
23

And in the (Geth) code, they can be found in contracts.go:

// PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum
// contracts used in the Byzantium release.
var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{
    common.BytesToAddress([]byte{1}): &ecrecover{},
    common.BytesToAddress([]byte{2}): &sha256hash{},
    common.BytesToAddress([]byte{3}): &ripemd160hash{},
    common.BytesToAddress([]byte{4}): &dataCopy{},
    common.BytesToAddress([]byte{5}): &bigModExp{},
    common.BytesToAddress([]byte{6}): &bn256Add{},
    common.BytesToAddress([]byte{7}): &bn256ScalarMul{},
    common.BytesToAddress([]byte{8}): &bn256Pairing{},
}
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.