#ethereum #event-log #events #decode #logs #data #abi

no-std ethabi-decode

Decoding of ABI-encoded data and event logs

3 stable releases

2.0.0 Oct 1, 2024
1.1.0 Sep 11, 2024
1.0.0 Jan 15, 2024

#21 in #event-log

Download history 19687/week @ 2024-06-29 17880/week @ 2024-07-06 24903/week @ 2024-07-13 26171/week @ 2024-07-20 21812/week @ 2024-07-27 24136/week @ 2024-08-03 36154/week @ 2024-08-10 21630/week @ 2024-08-17 30631/week @ 2024-08-24 34639/week @ 2024-08-31 33381/week @ 2024-09-07 29489/week @ 2024-09-14 32180/week @ 2024-09-21 30898/week @ 2024-09-28 35245/week @ 2024-10-05 29689/week @ 2024-10-12

133,451 downloads per month
Used in 20 crates (3 directly)

Apache-2.0

73KB
1.5K SLoC

ethabi-decode

This library is a codec for ABI-encoded data and event logs. It is a fork of ethabi with a focus on providing decode functionality in environments where libstd may not be available.

For compatibility with constrained no_std environments, the design of this library differs from the the upstream ethabi in several respects, including:

  • ABI's need to be specified as code rather than being loaded from JSON (No SERDE support).
  • Use of Vec<u8> instead of std::string::String for owned strings.
  • Anything to do with human-readable error and display output was excised.

Building

  • Build without libstd

    cargo build --no-default-features
    
  • Build with libstd

    cargo build
    

Example

Decode an event log:

use ethabi_decode::{Event, ParamKind, Token};

fn decode_event_log(topics: Vec<H256>, data: Vec<u8>) -> Vec<Token> {

    let event = Event {
      signature: "SomeEvent(address,int256)",
      inputs: vec![
        Param { kind: ParamKind::Address, indexed: true },
        Param { kind: ParamKind::Int(256), indexed: false },
      ],
      anonymous: false,
    };

    event.decode(topics, data).unwrap()
}

Dependencies

~0.3–1.2MB
~22K SLoC