riglr-evm-common

Crates.ioriglr-evm-common
lib.rsriglr-evm-common
version0.3.0
created_at2025-09-10 18:15:40.457065+00
updated_at2025-09-10 18:15:40.457065+00
descriptionCommon EVM utilities shared across Riglr crates
homepagehttps://github.com/riglr/riglr
repositoryhttps://github.com/riglr/riglr
max_upload_size
id1832831
size244,962
J.Warp (jwarp-riglr)

documentation

README

riglr-evm-common

Common EVM utilities shared across the Riglr workspace.

Overview

This crate provides a single source of truth for EVM-related functionality that is shared between multiple crates in the Riglr workspace. It eliminates code duplication and ensures consistent behavior across all EVM operations.

Features

  • Address utilities: Validation, parsing, formatting, and checksumming of EVM addresses
  • Chain management: Chain ID to name mapping, RPC URL resolution, block explorer URLs
  • Type conversions: Wei/ETH/Gwei conversions, token amount formatting
  • Common types: Standardized EVM configuration, account, token, and transaction data structures
  • Error handling: Unified error types for EVM operations
  • Validation utilities: Chain ID and gas parameter validation

Usage

Add this to your Cargo.toml:

[dependencies]
riglr-evm-common = { path = "../riglr-evm-common" }

Then use the utilities in your code:

use riglr_evm_common::{
    parse_evm_address,
    validate_evm_address,
    eth_to_wei,
    chain_id_to_name,
    EvmConfig,
};

// Parse and validate addresses
let address = parse_evm_address("0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5")?;

// Convert between units
let wei_amount = eth_to_wei("1.5")?;

// Get chain information
let chain_name = chain_id_to_name(1)?; // "Ethereum"

Architecture

This crate is designed to be:

  • Dependency-free from riglr-core: Ensures no circular dependencies
  • Provider-agnostic: Works with any Alloy provider implementation
  • Type-safe: Leverages Rust's type system for safety
  • Well-tested: Comprehensive test coverage for all utilities

License

MIT OR Apache-2.0

Commit count: 209

cargo fmt