#合金 #以太坊 #字节 #类型 #原始类型 #地址 #u256

alloy-ethers-typecast

用于在以太坊和合金类型之间进行安全类型转换的包

2 个不稳定版本

0.2.0 2024年1月1日
0.1.0 2024年1月1日

#7#u256

Download history 8/week @ 2024-05-06 21/week @ 2024-05-13 48/week @ 2024-05-20 61/week @ 2024-05-27 148/week @ 2024-06-03 78/week @ 2024-06-10 97/week @ 2024-06-17 67/week @ 2024-06-24 218/week @ 2024-07-01 122/week @ 2024-07-08 212/week @ 2024-07-15 362/week @ 2024-07-22

917 每月下载量
用于 cargo-stylus-check

CAL-1.0 许可证

6KB
79

用于以太坊和合金类型之间安全类型转换的包

目前支持以下类型转换:

  • ethers::types::H160alloy_primitives::Address
  • alloy_primitives::Addressethers::types::H160
  • ethers::types::U256alloy_primitives::U256
  • alloy_primitives::U256ethers::types::U256
  • ethers::types::Bytesalloy_primitives::Bytes
  • alloy_primitives::Bytesethers::types::Bytes

示例

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);

依赖项

~27–43MB
~810K SLoC