Expand description
§ethers-signers
A unified interface for locally signing Ethereum transactions.
Warning
This library is in the process of being deprecated. See #2667 for more information.
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
// 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();
Sign an Ethereum prefixed message (eip-712):
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());
Re-exports§
pub use coins_bip39;
pub use yubihsm;
yubihsm
and non-WebAssembly
Structs§
- AwsSigner
aws
- An ethers Signer that uses keys held in Amazon AWS KMS.
- Ledger
ledger
and non-WebAssembly - A Ledger Ethereum App.
- Mnemonic
Builder - Represents a structure that can resolve into a
Wallet<SigningKey>
. - Trezor
trezor
and non-WebAssembly - A Trezor Ethereum App.
- Wallet
- An Ethereum private-public key pair which can be used for signing messages.
Enums§
- AwsSigner
Error aws
- Errors produced by the AwsSigner
- HDPath
ledger
and non-WebAssembly - Ledger wallet type
- Ledger
Error ledger
and non-WebAssembly - Error when using the Ledger transport
- Trezor
Error trezor
and non-WebAssembly - Error when using the Trezor transport
- TrezorHD
Path trezor
and non-WebAssembly - Trezor wallet type
- Wallet
Error - Error thrown by the Wallet module
Traits§
- Signer
- Trait for signing transactions and messages
Functions§
- to_
eip155_ v - Applies EIP155
Type Aliases§
- Local
Wallet - A wallet instantiated with a locally stored private key
- Yubi
Wallet yubihsm
and non-WebAssembly - A wallet instantiated with a YubiHSM