18

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).

14

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)

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.

13

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{},
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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