#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

#530 in Magic Beans

Download history 79/week @ 2024-08-25 430/week @ 2024-09-01 502/week @ 2024-09-08 512/week @ 2024-09-15 606/week @ 2024-09-22 699/week @ 2024-09-29 357/week @ 2024-10-06 269/week @ 2024-10-13 200/week @ 2024-10-20 281/week @ 2024-10-27 518/week @ 2024-11-03 294/week @ 2024-11-10

1,300 downloads per month

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