60 releases (18 stable)

2.0.14 Mar 6, 2024
2.0.11 Nov 16, 2023
2.0.8 Jul 15, 2023
2.0.2 Mar 28, 2023
0.1.3 Jun 20, 2020

#2 in #celo

Download history 54399/week @ 2024-07-22 49864/week @ 2024-07-29 50172/week @ 2024-08-05 50983/week @ 2024-08-12 47970/week @ 2024-08-19 46552/week @ 2024-08-26 49545/week @ 2024-09-02 46995/week @ 2024-09-09 44682/week @ 2024-09-16 44122/week @ 2024-09-23 50168/week @ 2024-09-30 52510/week @ 2024-10-07 48455/week @ 2024-10-14 47451/week @ 2024-10-21 44422/week @ 2024-10-28 38112/week @ 2024-11-04

180,575 downloads per month
Used in 320 crates (93 directly)

MIT/Apache

1MB
19K SLoC

ethers-core

Ethereum data types, cryptography and utilities.

Warning

This library is in the process of being deprecated. See #2667 for more information.

It is recommended to use the utils, types and abi re-exports instead of the core module to simplify your imports.

This library provides type definitions for Ethereum's main datatypes along with other utilities for interacting with the Ethereum ecosystem

For more information, please refer to the book.

Feature flags

  • eip712: Does nothing.

ABI

This crate re-exports the ethabi crate's functions under the abi module, as well as the secp256k1 and rand crates for convenience.

Utilities

The crate provides utilities for launching local Ethereum testnets by using ganache-cli via the GanacheBuilder struct.

Examples

Calculate the UniswapV2 pair address for two ERC20 tokens:

# use ethers_core::abi::{self, Token};
# use ethers_core::types::{Address, H256};
# use ethers_core::utils;
let factory: Address = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f".parse()?;

let token_a: Address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".parse()?;
let token_b: Address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".parse()?;
let encoded = abi::encode_packed(&[Token::Address(token_a), Token::Address(token_b)])?;
let salt = utils::keccak256(encoded);

let init_code_hash: H256 = "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f".parse()?;

let pair = utils::get_create2_address_from_hash(factory, salt, init_code_hash);
let weth_usdc = "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc".parse()?;
assert_eq!(pair, weth_usdc);
# Ok::<(), Box<dyn std::error::Error>>(())

Dependencies

~10–21MB
~305K SLoC