#compat #alloy #conversion #ethereum-types #alloy-primitives

no-std alloy-compat

conversions between ethereum_types and alloy_primitives

3 unstable releases

0.2.0 Nov 7, 2024
0.1.1 Nov 7, 2024
0.1.0 Aug 31, 2024

#7 in #compat

Download history 102/week @ 2024-08-26 444/week @ 2024-09-02 519/week @ 2024-09-09 472/week @ 2024-09-16 602/week @ 2024-09-23 714/week @ 2024-09-30 357/week @ 2024-10-07 255/week @ 2024-10-14 256/week @ 2024-10-21 229/week @ 2024-10-28 517/week @ 2024-11-04 294/week @ 2024-11-11 256/week @ 2024-11-18 58/week @ 2024-11-25 70/week @ 2024-12-02 11/week @ 2024-12-09

399 downloads per month
Used in 2 crates

MIT/Apache

9KB
131 lines

Conversions between ethereum_types and alloy_primitives.

use alloy_compat::Compat as _;

// from alloy to ethereum_types
let address = alloy::address!("deadbeefdeadbeefdeadbeefdeadbeef00000000");
let _: eth::Address = address.compat();

// from ethereum_types to alloy
let hash = eth::H256::zero();
let _: alloy::B256 = hash.compat();

// integers are supported
let int = eth::U128::MAX;
assert_eq!(alloy::U128::MAX, int.compat());

lib.rs:

Conversions between ethereum_types and alloy_primitives.

use alloy_compat::Compat as _;

// from alloy to ethereum_types
let address = alloy::address!("deadbeefdeadbeefdeadbeefdeadbeef00000000");
let _: eth::Address = address.compat();

// from ethereum_types to alloy
let hash = eth::H256::zero();
let _: alloy::B256 = hash.compat();

// integers are supported
let int = eth::U128::MAX;
assert_eq!(alloy::U128::MAX, int.compat());

Dependencies

~5.5MB
~100K SLoC