Closed hzqd closed 2 years ago
I try to convert a &str address to Address type using Address::from_slice(<&str>.as_bytes()).
&str
Address
Address::from_slice(<&str>.as_bytes())
Getting panic message:
thread 'main' panicked at 'assertion failed: `(left == right)` left: `42`, right: `20`'
How should I convert a &str to an Address?
H160 implements FromStr trait (here), so you can simply do:
H160
FromStr
let str_addr: &str = "..."; let addr: Address = str_addr.parse().unwrap()
I try to convert a
&str
address toAddress
type usingAddress::from_slice(<&str>.as_bytes())
.Getting panic message:
How should I convert a
&str
to anAddress
?