Function ethers_core::utils::parse_ether [−][src]
pub fn parse_ether<S>(eth: S) -> Result<U256, S::Error> where
S: TryInto<U256>,
Expand description
Converts the input to a U256 and converts from Ether to Wei.
use ethers::{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());