Skip to main content

Precompiles

What are Precompiles?

A precompile refers to a set of special, pre-defined functions built into the native blockchain client software. In other words, precompiles are native smart contracts.

Precompiles are accessible at specific addresses on the blockchain and are designed to perform complex cryptographic operations such as hashing, digital signature verification, and mathematical operations more efficiently.

Blockchains deploy precompiled contracts for two main reasons. First, if the contracts are integral to the functioning of the blockchain itself, then it is vital that every instance of the blockchain contains these smart contracts. Secondly, precompiled contracts are far more efficient for certain operations.

Interacting With Precompiles

To interact with a precompile contract, simply treat the precompile contract as if it was any other smart contract. Stability has their own precompile contracts on our network to manage permissioned validators, as well as standard Ethereum Virtual Machine (EVM) precompiles.

Stability Native Precompiles

Stability

AddressNameInputOutputDescriptionSource
0x805ValidatorControllerdatadataA precompile that enables Stability to manage validator addresses.Code
0x806UpgradeRuntimeControllerPrecompiledatadataA precompile that enables Stability to manage runtime upgrades.Code

Ethereum Native Precompiles

To Learn More About Ethereum Precompile Contracts, we highly recommend visiting EVM Codes

AddressNameInputOutputDescription
0x01ecRecoverhash, v, r, spublicAddressVerify the signature of a message. In other words, you feed ecrecover the transaction's signature values and it returns an address. The signature is verified if the address returned is the same as the public address that sent the transaction.
0x02SHA2-256datahashReturns the SHA256 hash from the given data.
0x03RIPEMD-160datahashReturns the RIPEMD160 hash from the given data.
0x04identitydatadataAlso known as datacopy, this precompile serves as a cheaper way to copy data in memory.
0x05modexpBsize, Esize, Msize, B, E, MvalueCalculates the remainder when an integer b (base) is raised to the e-th power (the exponent), and is divided by a positive integer m (the modulus).
0x06BN128Addx1, y1, x2, y2x, yImplements a native elliptic curve point addition. Returns an elliptic curve point representing (ax, ay) + (bx, by) such that (ax, ay) and (bx, by) are valid points on the curve BN256.
0x07BN128Mulx1, y1, sx, yImplements a native elliptic curve multiplication with a scalar value. Returns an elliptic curve point representing scalar * (x, y) such that (x, y) is a valid curve point on the curve BN256.alt_bn128
0x08BN128Pairingx1, y1, x2, y2, ..., xk, yksuccessImplements elliptic curve pairing operation to perform zkSNARK verification.alt_bn128
0x09Blake2rounds, h, m, t, fhImplements the BLAKE2b hash function and other higher-round 64-bit BLAKE2 variants to run cheaply on the EVM.
0x400SHA3FIPS256datahashImplements the SHA-3 (Secure Hash Algorithm 3) cryptographic hashing function as specified in FIPS 202 (Federal Information Processing Standards Publication). This precompile takes an arbitrary length input and processes it to produce a fixed-length 256-bit (32 bytes) output hash.
0x402ECRecoverPublicKeyhash, v, r, shashSimilar to ecRecover, but returns the pubkey (not the corresponding Ethereum address)