ethers-rs/ethers-core
Georgios Konstantopoulos f037fc0243
fix: do not panic on invalid units conversion (#691)
* fix: do not panic on invalid units conversion

This is done by switching the From implementations to TryFrom and
making the conversion functions return a thiserror Error instead of
the previous Boxed error object

* chore: update changelog
2021-12-15 03:32:29 +01:00
..
ethers-derive-eip712 fix(codec)!: ambiguity unit8[] and bytes (#613) 2021-11-24 22:15:17 +02:00
src fix: do not panic on invalid units conversion (#691) 2021-12-15 03:32:29 +01:00
Cargo.toml chore(deps): bump elliptic-curve from 0.11.1 to 0.11.5 (#653) 2021-12-06 14:47:27 +02:00
README.md release: 0.6.0 (#611) 2021-11-23 21:23:12 +02:00

README.md

Ethereum types, cryptography and utilities.

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

Signing an ethereum-prefixed message

Signing in Ethereum is done by first prefixing the message with "\x19Ethereum Signed Message:\n" + message.length, and then signing the hash of the result.

# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
use ethers::signers::{Signer, LocalWallet};

let message = "Some data";
let wallet = LocalWallet::new(&mut rand::thread_rng());

// Sign the message
let signature = wallet.sign_message(message).await?;

// Recover the signer from the message
let recovered = signature.recover(message)?;

assert_eq!(recovered, wallet.address());
# Ok(())
# }

Utilities

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

Features

    • ["eip712"] | Provides Eip712 trait for EIP-712 encoding of typed data for derived structs

ABI Encoding and Decoding

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