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:
[]
= { = "../riglr-evm-common" }
Then use the utilities in your code:
use ;
// Parse and validate addresses
let address = parse_evm_address?;
// Convert between units
let wei_amount = eth_to_wei?;
// Get chain information
let chain_name = chain_id_to_name?; // "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