alloy_primitives::utils

Function parse_ether

Source
pub fn parse_ether(eth: &str) -> Result<U256, UnitsError>
Expand description

Converts the input to a U256 and converts from Ether to Wei.

ยงExamples

use alloy_primitives::{
    utils::{parse_ether, Unit},
    U256,
};

let eth = Unit::ETHER.wei();
assert_eq!(parse_ether("1").unwrap(), eth);