Module utils

Source
Expand description

Module with utility functions. Includes helpers for encoding, decoding, and other common tasks.

Functionsยง

eth_to_wei
Converts an ETH amount to wei as a U256. Accepts a BigDecimal ETH value and returns the equivalent amount in wei as a U256. This is useful for preparing values for smart contract calls or transactions. Returns an error if the value is too large to fit in a u128.
wei_to_eth
Converts a wei amount (U256) to ETH as a BigDecimal. Useful for displaying human-readable ETH values from raw wei amounts, such as for UI or logs. Panics if the U256 value cannot be parsed as a string (should not happen for valid values).