Precompiled Contracts
Last updated
Last updated
Precompiled contracts are a compromise used in the EVM to provide more complex library functions (usually used for complex operations such as encryption, hashing, etc.) that are not suitable for writing in opcode. They are applied to contracts that are simple but frequently called, or that are logically fixed but computationally intensive. Precompiled contracts are implemented on the client-side with client code, and because they do not require the EVM, they run fast. It also costs less for developers than using functions that run directly in the EVM.
To ease the development of light clients, all kinds of cryptography primitives are supported at the blockchain level and are exposed to EVM via pre-compiled contracts.
MAP Relay Chain will implement the pre-compiled contracts to support:
Address 0x0000000000000000000000000000000000000001
ecrecover implemented as a native contract.
Address 0x0000000000000000000000000000000000000002
SHA256 implemented as a native contract.
Address 0x0000000000000000000000000000000000000004
data copy implemented as a native contract.
Address 0x0000000000000000000000000000000000000005
bigModExp implements a native big integer exponential modular operation.
Address 0x0000000000000000000000000000000000000006
bn256Add implements a native elliptic curve point addition conforming to Istanbul consensus rules.
Address 0x0000000000000000000000000000000000000007
bn256ScalarMulIstanbul implements a native elliptic curve scalar multiplication conforming to Istanbul consensus rules.
Address 0x0000000000000000000000000000000000000008
bn256PairingIstanbul implements a pairing pre-compile for the bn256 curve conforming to Istanbul consensus rules.
Address 0x000068656164657273746F726541646472657373
execute atlas header store contract
Address 0x0000000000747856657269667941646472657373
RunTxVerify execute atlas tx verify contract
Address 0x00000000000000000000000000000000000000fd
Native transfer contract to make Atlas Gold ERC20 compatible.
Address 0x00000000000000000000000000000000000000fc
computes a * (b ^ exponent) to decimals
places of precision, where a and b are fractions
Address 0x00000000000000000000000000000000000000fb
verify validator`s address 、publicKey、g1publickey、signature
Address 0x00000000000000000000000000000000000000fa
Return the validators that are required to sign the given, possibly unsealed, block number. If this block is the last in an epoch, note that that may mean one or more of those validators may no longer be elected for subsequent blocks. WARNING: Validator set is always constructed from the canonical chain, therefore this precompile is undefined if the engine is aware of a chain with higher total difficulty.
Address 0x00000000000000000000000000000000000000f9
Return the number of validators that are required to sign this current, possibly unsealed, block. If this block is the last in an epoch, note that that may mean one or more of those validators may no longer be elected for subsequent blocks.
Address 0x00000000000000000000000000000000000000f8
return the epochSize
Address 0x00000000000000000000000000000000000000f7
return the blockNumber from header
Address 0x00000000000000000000000000000000000000f6
return the hashHeader from header
Address 0x00000000000000000000000000000000000000F5
Return the signer bitmap from the parent seal of a past block in the chain. Requested parent seal must have occurred within 4 epochs of the current block number.
Address 0x00000000000000000000000000000000000000F4
rerurn the extra.AggregatedSeal.Bitmap from header
Address 0x00000000000000000000000000000000000000f3
ed25519Verify implements a native Ed25519 signature verification.
Address 0x000000000000000000000000000000000000000a
Implements EIP-2537 G1Add precompile.
> G1 addition call expects 256
bytes as an input that is interpreted as byte concatenation of two G1 points (128
bytes each).
> Output is an encoding of addition operation result - single G1 point (128
bytes).
Address 0x000000000000000000000000000000000000000b
Implements EIP-2537 G1Mul precompile.
> G1 multiplication call expects 160
bytes as an input that is interpreted as byte concatenation of encoding of G1 point (128
bytes) and encoding of a scalar value (32
bytes).
> Output is an encoding of multiplication operation result - single G1 point(128
bytes).
Address 0x000000000000000000000000000000000000000c
Implements EIP-2537 G1MultiExp precompile.
G1 multiplication call expects 160*k
bytes as an input that is interpreted as byte concatenation of k
slices each of them being a byte concatenation of encoding of G1 point (128
bytes) and encoding of a scalar value (32
bytes).
Output is an encoding of multiexponentiation operation result - single G1 point (128
bytes).
Address 0x000000000000000000000000000000000000000d
Implements EIP-2537 G2Add precompile.
> G2 addition call expects 512
bytes as an input that is interpreted as byte concatenation of two G2 points (256
bytes each).
> Output is an encoding of addition operation result - single G2 point (256
bytes).
Address 0x000000000000000000000000000000000000000e
Implements EIP-2537 G2MUL precompile logic.
> G2 multiplication call expects 288
bytes as an input that is interpreted as byte concatenation of encoding of G2 point (256
bytes) and encoding of a scalar value (32
bytes).
> Output is an encoding of multiplication operation result - single G2 point (256
bytes).
Address 0x000000000000000000000000000000000000000f
Implements EIP-2537 G2MultiExp precompile logic
> G2 multiplication call expects 288*k
bytes as an input that is interpreted as byte concatenation of k
slices each of them being a byte concatenation of encoding of G2 point (256
bytes) and encoding of a scalar value (32
bytes).
> Output is an encoding of multiexponentiation operation result - single G2 point (256
bytes).
Address 0x0000000000000000000000000000000000000010
Implements EIP-2537 Pairing precompile logic.
> Pairing call expects 384*k
bytes as an inputs that is interpreted as byte concatenation of k
slices. Each slice has the following structure:
> - 128
bytes of G1 point encoding
> - 256
bytes of G2 point encoding
> Output is a 32
bytes where last single byte is 0x01
if pairing result is equal to multiplicative identity in a pairing target field and 0x00
otherwise
> (which is equivalent of Big Endian encoding of Solidity values uint256(1)
and uin256(0)
respectively).
Address 0x0000000000000000000000000000000000000011
Implements EIP-2537 Map_To_G1 precompile.
> Field-to-curve call expects 64
bytes an an input that is interpreted as a an element of the base field.
> Output of this call is 128
bytes and is G1 point following respective encoding rules.
Address 0x0000000000000000000000000000000000000012
Implements EIP-2537 Map_FP2_TO_G2 precompile logic.
> Field-to-curve call expects 128
bytes an an input that is interpreted as a an element of the quadratic extension field.
> Output of this call is 256
bytes and is G2 point following respective encoding rules.