#ethereum #abi #encoding #evm #solidity

no-std alloy-sol-types

Compile-time ABI and EIP-712 implementations

16 releases (4 breaking)

0.6.3 Feb 15, 2024
0.5.4 Dec 28, 2023
0.5.1 Nov 30, 2023
0.3.1 Jul 30, 2023

#1376 in Magic Beans

Download history 3543/week @ 2023-11-06 3324/week @ 2023-11-13 3764/week @ 2023-11-20 6544/week @ 2023-11-27 7511/week @ 2023-12-04 9185/week @ 2023-12-11 12919/week @ 2023-12-18 8503/week @ 2023-12-25 15625/week @ 2024-01-01 24016/week @ 2024-01-08 32143/week @ 2024-01-15 30984/week @ 2024-01-22 29277/week @ 2024-01-29 29109/week @ 2024-02-05 34370/week @ 2024-02-12 37988/week @ 2024-02-19

132,150 downloads per month
Used in 22 crates (14 directly)

MIT/Apache

390KB
8K SLoC

alloy-sol-types

Compile-time representation of Ethereum's type system with ABI and EIP-712 support.

This crate provides a developer-friendly interface to Ethereum's type system, by representing Solidity types. See type_system.md for a rundown, and the crate docs for more information

Features

  • static representation of Solidity types
  • ABI encoding and decoding
  • EIP-712 encoding and decoding
  • EIP-712 Domain object w/ serde support

Usage

See the crate docs for more details.

// Declare a solidity type in standard solidity
sol! {
    struct Foo {
        bar: u256;
        baz: bool;
    }
}

// A corresponding Rust struct is generated!
let foo = Foo {
    bar: 42.into(),
    baz: true,
};

// Works for UDTs
sol! { type MyType is uint8; }
let my_type = MyType::from(42u8);

// For errors
sol! {
    error MyError(
        string message,
    );
}

// And for functions!
sol! { function myFunc() external returns (uint256); }

Licensing

This crate is an extensive rewrite of the ethabi crate by the parity team. That codebase is used under the terms of the MIT license. We have preserved the original license notice in files incorporating ethabi code.

Dependencies

~0–2.5MB
~57K SLoC