Skip to main content
35 votes
Accepted

List of pre-compiled contracts

Here are the precompiled contracts, the numbering is the address of the contract: Recovery of ECDSA signature Hash function SHA256 Hash function RIPEMD160 Identity Modular exponentiation (EIP 198) ...
eth's user avatar
  • 86.5k
23 votes

List of pre-compiled contracts

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 ...
Richard Horrocks's user avatar
14 votes

What's a precompiled contract and how are they different from native opcodes?

Not an authority, but I know of someone who is... From Vitalik's article, A Prehistory of the Ethereum Protocol The second was the idea of “precompiles”, solving the problem of allowing complex ...
benjaminion's user avatar
  • 9,317
9 votes

Can precompiles have state?

The existing precompiled contracts in Ethereum primarily handle specific computational tasks optimized for performance, and they have been stateless/pure mainly for design reasons, not because of ...
MShakeG's user avatar
  • 1,855
7 votes
Accepted

Why is there a SHA256 pre-compiled contract when SHA256 is also an opcode?

As far as I'm aware there is no SHA256 opcode. I tried finding one but couldn't find - not listed at least in, for example, this list: https://github.com/crytic/evm-opcodes Maybe you're mixing it up ...
Lauri Peltonen's user avatar
5 votes
Accepted

Which language are precompiled contracts written in?

Precompiled contracts aren't written in a particular language. Usually someone proposes a new precompiled contract and suggest a possible implementation. It can be written in any language, python for ...
Ismael's user avatar
  • 30.3k
5 votes

Why aren't all contracts compiled?

A precompiled contract, as I understand it, is actually protocol-subsidized. That is, while there is technically code at a given address, the gas price is far less than if it was run manually. If I'm ...
Matthew Schmidt's user avatar
5 votes

Verifying Modular exponentiation operation in etherum

From the answer of @Julien Marchand it's possible to create the function viewing the attributes of the precompiled contract: https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go#...
alberto's user avatar
  • 3,353
4 votes
Accepted

Verifying Modular exponentiation operation in etherum

Modular exponentiation can be computed on Ethereum using a precompile, which is included in all client implementations since the Byzantium fork (cf EIP-198) at address 0x05. Precompiles can be called ...
Julien Marchand's user avatar
3 votes

Why aren't more common algorithms done as precompiles?

Usually the cryptographic algorithms are considered most important for the blockchain functions, so they are implemented as precompiles first. From what I understand, quite a bit of work and reasoning ...
Bruce's user avatar
  • 997
3 votes

What’s the identity 0x4 precompile?

Yes, you are correct. It is the identity function. It copies its input to its output. It can be used to copy between memory portions. function dataCopy(bytes memory _input) internal view returns (...
Ismael's user avatar
  • 30.3k
3 votes
Accepted

How to add custom precompiled contract?

This is good reference that do a new pre-compile contract for Ethereum next hardfork named Istanbul https://github.com/keep-network/go-ethereum/pull/4/files Basically, you only need to implement two ...
Tony Dang's user avatar
  • 2,161
3 votes
Accepted

Must precompiled contracts be natively implemented?

There's no reason they can't be implemented in the EVM, but that completely defeats the purpose. The reason precompiles are precompiles instead of just Solidity libraries that people deploy is because,...
natewelch_'s user avatar
  • 12.2k
3 votes

Calling precompiled contracts from a pure function

Firstly note that the view modifier, as seen in the doc here doesn't allow modifying of the state, it only allows reading of the state and behaves the same as constant (the modifier used for these ...
willjgriff's user avatar
  • 1,658
2 votes
Accepted

Clarification on multiplication from modular exponentiation precompiled contract

but what exactly is to be passed to the modexp contract in order to achieve multiplication? is it the squaring of (a+b) and (a-b)? Yes, exactly that. To calculate a * b % m you call the precompile ...
benjaminion's user avatar
  • 9,317
2 votes
Accepted

How to call the precompiled contracts from my contract?

The solution for this problem is quite simple. Use solc v0.3.6! In solc v0.4.0 they added: Function call throws if target contract does not have code There is no code at the addresses of the ...
Kyroy's user avatar
  • 71
2 votes

Which language are precompiled contracts written in?

You can checkout the reference to go-ethereum's implementation of precompiled contracts here https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go
kyliek's user avatar
  • 21
2 votes

Pre-compiled contract - ecmul

pre-compile exist to reduce gas and because of this reason they are implemented with specific values and functions, in this case, EccMul is defined with the specific curve Y² = X³ + 3 over the prime ...
Payam Safaei's user avatar
2 votes
Accepted

Tornado Cash Hasher contract - circom

Figured it out. They use the mimc_sponge hash function (https://byt3bit.github.io/primesym/) and it's all precompiled by the IDEN guys and just the bytecode is deployed on-chain (so no solidity). ...
thefett's user avatar
  • 3,920
2 votes
Accepted

Why TornadoCash smart contract calls address = 8?

Address 8 is a pairing "precompiled contract". More specifically, EIP-197: Precompiled contracts for optimal ate pairing check on the elliptic curve alt_bn128. For a cyclic group G (written ...
eth's user avatar
  • 86.5k
2 votes
Accepted

Does `<address>.code` return code for precompiles?

The answer is no - The .code member does not return the code for precompiled addresses. Let's take the following examples: pragma solidity >=0.8.18; contract Foo { function getCode1() external ...
Paul Razvan Berg's user avatar
2 votes

Can precompiles be written in Solidity/ Yul?

Solidity precompiled contracts are similar to regular contracts, with one key difference: they are not deployed but instead created through the genesis JSON file at the launch of a blockchain. As such,...
tenbits's user avatar
  • 2,508
2 votes
Accepted

How does EVM chains update the states of Predeploys?

The block information from L1 is not actually stored in this contract. It comes from the L1Block contract. As shown below, the L1BlockNumber contract calls the L1Block contract. The Predeploys....
Ryan Holanda's user avatar
2 votes
Accepted

Is BLS12-381 precompile now available on mainnet?

Not yet available on mainnet: Dencun does not include EIP-2537. https://eips.ethereum.org/EIPS/eip-7569 lists the EIPs included in Dencun.
eth's user avatar
  • 86.5k
1 vote
Accepted

What’s the exact definition of the alt_bn128 curve used by the Ethereum’s precompile?

EIP-196 Precompiled contracts for addition and scalar multiplication on the elliptic curve alt_bn128 specification says the curve is defined by: Y^2 = X^3 + 3 over the field F_p with p = ...
eth's user avatar
  • 86.5k
1 vote

What's the difference between zkSync `system contracts` and EVM precompiles?

According to the zkSync AI Bot: The difference between zkSync system contracts and EVM precompiles lies in their roles and how they are integrated within the zkSync architecture: System Contracts: ...
Patrick Collins's user avatar
1 vote

Pre compiled contract for alt_bn128 for scalar multiplication on G2?

Here is an image that includes the precompile info: Source: https://medium.com/coinmonks/fuzzing-the-bls-precompiles-ba3728dec622. You should likely find a more reputable source than a medium ...
ruby_newbie's user avatar
1 vote

Pre-compiled contract - ecmul

The ecmul opcode in Solidity allows you to multiply a given point on the elliptic curve with a scalar value. The point used in the ecmul opcode must be a generator point on the elliptic curve, which ...
Yakitori's user avatar
  • 787
1 vote

How do i add EIP-1559 functionality to ERC-20 contract using solidity

Using a hardware wallet was causing the problem here. I created the contract using a regular metamask wallet.
stems's user avatar
  • 11
1 vote

Why aren't all contracts compiled?

Matthew's answer is correct. However, I will add that one of the goals of Ethereum 2.0 is to get rid of those pre-compiled contracts. Since they must be implemented by all clients, the risk of running ...
Alex Byrde's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible