6 releases

0.2.2 Oct 29, 2023
0.2.1 Oct 27, 2023
0.1.2 Nov 20, 2022
0.1.1 Aug 25, 2022
0.1.0 May 30, 2022

#405 in Magic Beans

Download history 120/week @ 2024-03-13 47/week @ 2024-03-20 72/week @ 2024-03-27 146/week @ 2024-04-03 101/week @ 2024-04-10 186/week @ 2024-04-17 133/week @ 2024-04-24 217/week @ 2024-05-01 124/week @ 2024-05-08 270/week @ 2024-05-15 355/week @ 2024-05-22 552/week @ 2024-05-29 559/week @ 2024-06-05 505/week @ 2024-06-12 837/week @ 2024-06-19 729/week @ 2024-06-26

2,731 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

35KB
748 lines

Implementation of Ethereum public addresses for Rust.

This crate provides an Address type for representing Ethereum public addresses. It implements ERC-55 mixed-case checksum Display formatting and parsing with verification using Address::from_str_checksum().

Additionally an address! macro is included for compile-time verified address constants. Under the hood, it is implemented with const fn and does not use procedural macros.

Usage

Just add a dependency to your Cargo.toml:

[dependencies]
ethaddr = "*"

For complete documentation checkout docs.rs.


lib.rs:

Implementation of Ethereum public addresses for Rust.

This crate provides an Address type for representing Ethereum public addresses.

Checksums

Addresses are by default formatted with ERC-55 mixed-case checksum encoding. Addresses checksums may optionally be verified when parsing with [Address::from_str_checksum()].

address! Macro

This crate exports an address! macro that can be used for creating compile-time address constants. Under the hood, it is implemented with const fn and does not use procedural macros.

Features

  • default std: Additional integration with Rust standard library types. Notably, this includes std::error::Error implementation on the ParseAddressError type and conversions from Vec<u8>.
  • serde: Serialization traits for the serde crate. Note that the implementation is very much geared towards JSON serialization with serde_json.
  • sha3: Use the Rust Crypto Keccak-256 implementation (provided by the sha3 crate) instead of the built-in one. Note that the address! macro will always use the built-in Keccak-256 implementation for checksum verification, as sha3 does not expose a const fn API.

Dependencies

~0–445KB