Skip to main content

mfm_evm_core/
lib.rs

1#![warn(missing_docs)]
2//! Low-level EVM ABI, hex, and RLP helpers used by runtime and collector crates.
3//!
4//! This crate keeps encoding and decoding concerns separate from transport code so higher layers
5//! can assemble RPC requests, contract calls, and byte-oriented payloads without reimplementing
6//! Ethereum primitives.
7//!
8//! # Examples
9//!
10//! ```rust
11//! use mfm_evm_core::abi::function_selector;
12//! use mfm_evm_core::encoding::{encode_erc20_decimals, normalize_address};
13//!
14//! let selector = function_selector("balanceOf", &["address".to_string()]);
15//! assert_eq!(selector, [0x70, 0xa0, 0x82, 0x31]);
16//! assert_eq!(encode_erc20_decimals(), "0x313ce567");
17//! assert_eq!(
18//!     normalize_address("0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")?,
19//!     "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20//! );
21//! # Ok::<(), mfm_evm_core::util_error::UtilError>(())
22//! ```
23
24/// ABI parsing, selector derivation, and argument encoding helpers.
25pub mod abi;
26/// Ethereum JSON-RPC quantity, address, and ERC-20 call encoding helpers.
27pub mod encoding;
28/// Hex-string normalization and decoding helpers.
29pub mod hex;
30/// Minimal Recursive Length Prefix (RLP) encoding helpers.
31pub mod rlp;
32/// Lightweight error type shared by the utility modules.
33pub mod util_error;