#type #byte #alloy #ethers #primitive #address #u256

alloy-ethers-typecast

Crate for safe typecasting between ethers and alloy types

2 unstable releases

0.2.0 Jan 1, 2024
0.1.0 Jan 1, 2024

#6 in #u256

Download history 122/week @ 2024-07-08 212/week @ 2024-07-15 362/week @ 2024-07-22 64/week @ 2024-07-29 81/week @ 2024-08-05 280/week @ 2024-08-12 272/week @ 2024-08-19 272/week @ 2024-08-26 172/week @ 2024-09-02 147/week @ 2024-09-09 92/week @ 2024-09-16 78/week @ 2024-09-23 78/week @ 2024-09-30 81/week @ 2024-10-07 173/week @ 2024-10-14 221/week @ 2024-10-21

559 downloads per month
Used in 2 crates

CAL-1.0 license

6KB
79 lines

Crate for Safe Typecasting between Ethers and Alloy types

Currently supporting type conversion for:

  • ethers::types::H160 to alloy_primitives::Address
  • alloy_primitives::Address to ethers::types::H160
  • ethers::types::U256 to alloy_primitives::U256
  • alloy_primitives::U256 to ethers::types::U256
  • ethers::types::Bytes to alloy_primitives::Bytes
  • alloy_primitives::Bytes to ethers::types::Bytes

Example

let ethers_address: ethers::types::H160 = ethers::types::H160::random();
let alloy_address: alloy_primitives::Address = ethers_address_to_alloy(ethers_address);
let ethers_u256: ethers::types::U256 = ethers::types::U256::from_dec_str("126731272983");
let alloy_u256: alloy_primitives::U256 = ethers_u256_to_alloy(ethers_u256);

Dependencies

~27–44MB
~817K SLoC