ethers-rs/ethers-core
Dan Cline ea10f4b4df
fix(core): set `GethInstance` p2p_port in spawn (#1933)
* fix(core): set GethInstance p2p_port in spawn

 * previously, spawning Geth with disabled discovery would not actually
   set the p2p port in the returned GethInstance. This is because it
   would only pass the port to the geth command. If the value started as
   None, it would remain to be None in the GethInstance even though a
   port was passed to the command.
 * adds tests for the existence of ports in GethInstance

* remove rpc port test

* rpc port test doesn't make sense because it will always be set, it is
  not an Option

* use sigterm instead of sigkill

* use sigint instead of sigterm

* run tests in different directories

 * prevents flaky behavior because cargo runs tests in parallel, if the
   default directory were used, each GethInstance would fight for geth's
   file system lock.

* remove nix as a dep

 * sigkill works for now
2022-12-09 09:42:23 -08:00
..
ethers-derive-eip712 (cargo-release) version 1.0.2 2022-11-27 12:27:56 -08:00
src fix(core): set `GethInstance` p2p_port in spawn (#1933) 2022-12-09 09:42:23 -08:00
testdata fix(core): correctly deserialize eip1186 proof responses 2022-02-12 18:58:58 +02:00
Cargo.toml fix(core): set `GethInstance` p2p_port in spawn (#1933) 2022-12-09 09:42:23 -08:00
README.md fmt: all (#1751) 2022-09-28 11:58:26 -07: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.