For the complete documentation index, see llms.txt. This page is also available as Markdown.

Precompiles

Call Mercury EVM precompiles from Rust

Mercury EVM ships with six cryptographic precompiles at fixed addresses. They are callable via eth_call from any provider connected to a Seismic node — no encryption state or wallet is required.

Convenience Helpers

The seismic_alloy_provider::precompiles module provides three layers of helpers:

  1. Address constantsprecompiles::addresses::RNG, precompiles::addresses::ECDH, etc.

  2. Encode/decode functionsprecompiles::encode_rng(), precompiles::decode_secp256k1_sign(), etc.

  3. Async call wrappersprecompiles::call::rng(), precompiles::call::ecdh(), etc.

use seismic_alloy_provider::precompiles;

// Generate 32 random bytes
let random = precompiles::call::rng::<SeismicFoundry, _>(&provider, 32, b"my_domain").await?;

// Derive a shared AES key via ECDH
let aes_key = precompiles::call::ecdh::<SeismicFoundry, _>(&provider, &secret_key, &pubkey).await?;

// AES-GCM encrypt/decrypt
let ciphertext = precompiles::call::aes_encrypt::<SeismicFoundry, _>(&provider, &key, &nonce, plaintext).await?;
let plaintext = precompiles::call::aes_decrypt::<SeismicFoundry, _>(&provider, &key, &nonce, &ciphertext).await?;

Precompile calls are read-only eth_call operations. They do not require a SeismicSignedProvider — an unsigned provider works fine. However, if you use a signed provider, the call will still succeed.

Manual Calling Pattern

You can also call precompiles directly by building a TransactionRequest:


Reference

Precompile
Address
Description
Page

RNG

0x64 (100)

Cryptographically secure random byte generation

ECDH

0x65 (101)

Elliptic-curve Diffie-Hellman key exchange

AES-GCM Encrypt

0x66 (102)

AES-256-GCM authenticated encryption

AES-GCM Decrypt

0x67 (103)

AES-256-GCM authenticated decryption

HKDF

0x68 (104)

HMAC-based key derivation (HKDF-SHA256)

secp256k1 Sign

0x69 (105)

On-chain ECDSA signature generation

Quick Example

Internal Usage

The SeismicSignedProvider uses several of these precompiles internally as part of the filler pipeline:

  • ECDH (0x65) — Used during TEE key exchange to derive a shared secret between the client and the Seismic node's TEE

  • AES-GCM Encrypt (0x66) — Used to encrypt calldata before sending shielded transactions

  • AES-GCM Decrypt (0x67) — Used to decrypt responses from signed reads

  • HKDF (0x68) — Used to derive AES keys from ECDH shared secrets

You can also call these precompiles directly for custom cryptographic workflows.

See Also

Last updated