pub struct Address(/* private fields */);Expand description
An Ethereum account address.
§Examples
Parse an address from a string:
use std::str::FromStr;
let address = ic_ethereum_types::Address::from_str("0x7a250d5630b4cf539739df2c5dacb4c659f2488d").unwrap();
assert_eq!(address.into_bytes(), [0x7a, 0x25, 0x0d, 0x56, 0x30, 0xb4, 0xcf, 0x53, 0x97, 0x39, 0xdf, 0x2c, 0x5d, 0xac, 0xb4, 0xc6, 0x59, 0xf2, 0x48, 0x8d]);Instantiate an address from raw bytes:
let address = ic_ethereum_types::Address::new([0x7a, 0x25, 0x0d, 0x56, 0x30, 0xb4, 0xcf, 0x53, 0x97, 0x39, 0xdf, 0x2c, 0x5d, 0xac, 0xb4, 0xc6, 0x59, 0xf2, 0x48, 0x8d]);
assert_eq!(address.to_string(), "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D");Implementations§
Source§impl Address
impl Address
Sourcepub const ZERO: Self
pub const ZERO: Self
Ethereum zero address.
let address = ic_ethereum_types::Address::ZERO;
assert_eq!(address.to_string(), "0x0000000000000000000000000000000000000000");
assert_eq!(address.into_bytes(), [0u8; 20]);Sourcepub const fn into_bytes(self) -> [u8; 20]
pub const fn into_bytes(self) -> [u8; 20]
Convert an Ethereum address into a 20-byte array.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&Address> for [u8; 32]
Convert a 20-byte address to 32-byte array, with left zero padding.
impl From<&Address> for [u8; 32]
Convert a 20-byte address to 32-byte array, with left zero padding.
Source§impl Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
Source§impl TryFrom<&[u8; 32]> for Address
Parse an address from a 32-byte array with left zero padding.
impl TryFrom<&[u8; 32]> for Address
Parse an address from a 32-byte array with left zero padding.
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)