Function ethers::utils::parse_ether[][src]

pub fn parse_ether<S>(eth: S) -> Result<U256, Box<dyn Error + 'static, Global>> where
    S: ToString
Expand description

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

use ethers_core::{types::U256, utils::{parse_ether, WEI_IN_ETHER}};

let eth = U256::from(WEI_IN_ETHER);
assert_eq!(eth, parse_ether(1u8).unwrap());
assert_eq!(eth, parse_ether(1usize).unwrap());
assert_eq!(eth, parse_ether("1").unwrap());