19 releases (5 breaking)

new 0.7.1 Apr 23, 2024
0.7.0 Mar 30, 2024
0.6.4 Feb 29, 2024
0.5.4 Dec 28, 2023
0.3.1 Jul 30, 2023

#1408 in Magic Beans

Download history 23687/week @ 2024-01-06 30356/week @ 2024-01-13 31419/week @ 2024-01-20 29727/week @ 2024-01-27 28701/week @ 2024-02-03 31287/week @ 2024-02-10 41087/week @ 2024-02-17 36924/week @ 2024-02-24 32742/week @ 2024-03-02 36654/week @ 2024-03-09 36043/week @ 2024-03-16 33603/week @ 2024-03-23 47668/week @ 2024-03-30 47078/week @ 2024-04-06 40906/week @ 2024-04-13 35098/week @ 2024-04-20

174,211 downloads per month
Used in 37 crates (24 directly)

MIT/Apache

660KB
14K 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

~4.5–7MB
~145K SLoC