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♦
- 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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#...
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 ...
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 ...
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 (...
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 ...
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,...
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 ...
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 ...
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 ...
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
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 ...
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).
...
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♦
- 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 ...
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,...
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....
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♦
- 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♦
- 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:
...
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 ...
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 ...
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.
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
precompiled-contracts × 45solidity × 12
evm × 9
go-ethereum × 6
contract-development × 4
pairings × 4
contract-design × 3
out-of-gas × 3
cryptography × 3
zksnark × 3
private-blockchain × 2
contract-debugging × 2
clients × 2
opcode × 2
yellow-paper × 2
exceptions × 2
elliptic × 2
tornado-cash × 2
web3js × 1
blockchain × 1
remix × 1
contract-deployment × 1
contract-invocation × 1
events × 1
security × 1