Function format_units
pub fn format_units<T, K, E>(amount: T, units: K) -> Result<String, UnitsError>
Expand description
Formats the given number of Wei as the given unit.
ยงExamples
use alloy_primitives::{utils::format_units, U256};
let eth = U256::from_str_radix("1395633240123456000", 10).unwrap();
assert_eq!(format_units(eth, "eth").unwrap(), "1.395633240123456000");
assert_eq!(format_units(i64::MIN, "gwei").unwrap(), "-9223372036.854775808");
assert_eq!(format_units(i128::MIN, 36).unwrap(), "-170.141183460469231731687303715884105728");