Skip to main content

Crate moloch_anchor_ethereum

Crate moloch_anchor_ethereum 

Source
Expand description

Ethereum Anchoring for Moloch.

This crate provides an Ethereum implementation of the AnchorProvider trait, allowing Moloch chain state to be anchored to Ethereum and EVM-compatible chains.

§Anchoring Methods

This provider supports multiple anchoring methods:

  1. Calldata Anchoring (Default)

    • Embeds commitment in transaction input data
    • Most cost-effective for pure anchoring
    • Data: [MOLOCH_SELECTOR (4)] [commitment_hash (32)] [chain_id_hash (8)]
  2. Contract Event Anchoring

    • Emits events from a dedicated anchor contract
    • Better for on-chain verification
    • Supports batch anchoring

§Example

use moloch_anchor_ethereum::{EthereumProvider, EthereumConfig, Chain};

let config = EthereumConfig::new("https://eth.llamarpc.com", Chain::Mainnet)
    .with_private_key("0x...");

let provider = EthereumProvider::new(config).await?;

// Anchor a commitment
let tx = provider.submit(&commitment).await?;

// Wait for confirmations
let proof = provider.wait_for_confirmations(&tx.tx_id, 12).await?;

Structs§

EthereumConfig
Configuration for the Ethereum provider.
EthereumProvider
Ethereum anchor provider.

Enums§

AnchorMethod
Method for anchoring data.
Chain
Ethereum chain/network.
EthereumError
Errors that can occur during Ethereum anchoring.

Constants§

ANCHOR_DATA_SIZE
Anchor data size: selector(4) + commitment(32) + chain_id(8) = 44 bytes.
DEFAULT_CONFIRMATIONS
Default number of confirmations for finality.
MOLOCH_SELECTOR
Function selector for Moloch anchor calls (first 4 bytes of keccak256(“anchor(bytes32,bytes8)”)).

Type Aliases§

Result
Result type for Ethereum operations.