ethers-rs/ethers-signers
James Prestwich 73636a906e
RRR: Reconnection & Request Reissuance (#2181)
* wip: ws2

* ws2 backend compiles

* refactor: rename PubSubItem and BackendDriver

* feature: dispatch request to end subscription

* refactor: move ws2 to ws, fix reconnection and deser on subs

* chore: improve use of tracing in manager

* refactor: feature legacy_ws to enable backwards compatibility

* nit: mod file ordering

* docs: copy PR description to ws structs

* fixes: remove unused macros file, remove err formats

* docs: add comments to struct fields

* docs: comment client struct fields

* chore: changelog

* fix: unused imports in ws_errors test

* docs: missing comment

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>

* fix: legacy-ws feature in root crate, hyphen not underscore

* fix: a couple bad imports/exports

---------

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2023-02-28 18:25:59 -07:00
..
src fix: udeps (#2215) 2023-02-28 18:25:25 -07:00
Cargo.toml RRR: Reconnection & Request Reissuance (#2181) 2023-02-28 18:25:59 -07:00
README.md docs: fix broken links, update documentation (#2203) 2023-02-27 13:03:17 -07:00

README.md

ethers-signers

A unified interface for locally signing transactions.

You can implement the Signer trait to extend functionality to other signers such as Hardware Security Modules, KMS etc.

The exposed interfaces return a recoverable signature. In order to convert the signature and the TransactionRequest to a Transaction, look at the signing middleware.

Supported signers:

For more information, please refer to the book.

Examples

# use ethers_signers::{LocalWallet, Signer};
# use ethers_core::{k256::ecdsa::SigningKey, types::TransactionRequest};
# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
// instantiate the wallet
let wallet = "dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7"
    .parse::<LocalWallet>()?;

// create a transaction
let tx = TransactionRequest::new()
    .to("vitalik.eth") // this will use ENS
    .value(10000).into();

// sign it
let signature = wallet.sign_transaction(&tx).await?;

// can also sign a message
let signature = wallet.sign_message("hello world").await?;
signature.verify("hello world", wallet.address()).unwrap();
# Ok(())
# }

Sign an Ethereum prefixed message (eip-712):

# use ethers_signers::{Signer, LocalWallet};
# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
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(())
# }