A precompiled contract is a special contract at a fixed Ethereum address whose logic is implemented natively in the client software (Go, Rust) rather than as EVM bytecode. They provide complex cryptographic operations (elliptic curve math, hashing, signature verification) at predictable, lower gas costs than equivalent EVM execution would require.

What Is a Precompiled Contract?

3 min read

The short version

Precompiles are like hardware-accelerated functions built into Ethereum's engine. Instead of executing thousands of EVM opcodes to do complex math (which would be slow and expensive), the node software performs the operation directly in optimized native code, like using a calculator's built-in square root button instead of computing it by hand step by step.

How It Works

Ethereum has precompiles at addresses 0x01 through 0x0a (and more added by subsequent hard forks). Each performs a specific computation: 0x01 = ecRecover (recover signer from signature). 0x02 = SHA-256 hash. 0x03 = RIPEMD-160 hash. 0x04 = identity (data copy). 0x05 = modexp (modular exponentiation). 0x06-0x08 = BN128 elliptic curve operations (used by ZK proofs). 0x09 = BLAKE2b hash. 0x0a = point evaluation (EIP-4844, for blob verification). When a contract calls a precompile address, the EVM does not execute bytecode, it passes the input to native code and returns the output. Gas is fixed and predictable per precompile. New precompiles require hard forks to add, which is why they are limited to operations with broad, lasting utility.

How ZK rollup proof verification uses precompiles

A ZK rollup (like zkSync) submits a validity proof to Ethereum L1. The L1 verifier contract needs to perform elliptic curve pairings to check the proof, operations that would cost millions of gas if implemented in EVM bytecode. Instead, the contract calls precompiles 0x06 (ec_add), 0x07 (ec_mul), and 0x08 (ec_pairing) which perform these operations in native code at fixed, reasonable gas costs (~45,000-113,000 gas each). This makes ZK proof verification economically feasible on L1. Without these precompiles, ZK rollups would be impractically expensive to verify on-chain.

What People Get Wrong

  • Precompiles are smart contracts you can read on Etherscan

    Precompile addresses have no EVM bytecode, they are empty on-chain. Their logic is in the node software itself. You cannot "view the source" on Etherscan; you view it in the Ethereum client source code (Geth, Reth, etc.).

  • Anyone can deploy a new precompile

    Precompiles are protocol-level features that require a hard fork (network upgrade) to add. They must be implemented in every client and accepted by the community through the EIP process. This is intentionally difficult and reserved for operations with universal utility.

  • Precompiles are only for cryptography

    While most current precompiles are cryptographic, the concept is general. Any computation that is too expensive in EVM but useful enough to standardize could become a precompile. The identity precompile (0x04) simply copies data, it exists for gas-efficient memory operations.

Sources & Further Reading

Questions People Also Ask

How many precompiles does Ethereum have?
As of the Cancun upgrade (2024): 10 precompiles at addresses 0x01-0x0a. The most recently added is the point evaluation precompile (0x0a) for EIP-4844 blob verification. More may be added in future upgrades as needs arise.
Can I call a precompile from Solidity?
Yes. You call the precompile address with the expected input format using a low-level call. Libraries like OpenZeppelin provide wrappers for common precompiles. ecrecover() in Solidity is actually a built-in wrapper for the 0x01 precompile.
What happens if I send ETH to a precompile address?
The ETH is sent successfully and sits at that address, it is not lost, but it is also not recoverable (no one controls the private key for precompile addresses, and the precompile logic does not handle ETH transfers). Do not send ETH to precompile addresses.

More in Smart Contracts & Ethereum

See all →
Was this page helpful?

Page last checked