Struct ethers_signers::Wallet [−][src]
pub struct Wallet<D: DigestSigner<ProxyDigest<Sha256>, RecoverableSignature>> { /* fields omitted */ }
Expand description
An Ethereum private-public key pair which can be used for signing messages.
Examples
Signing and Verifying a message
The wallet can be used to produce ECDSA Signature
objects, which can be
then verified. Note that this uses hash_message
under the hood which will
prefix the message being hashed with the Ethereum Signed Message
domain separator.
use ethers_core::rand::thread_rng;
use ethers_signers::{LocalWallet, Signer};
let wallet = LocalWallet::new(&mut thread_rng());
// Optionally, the wallet's chain id can be set, in order to use EIP-155
// replay protection with different chains
let wallet = wallet.with_chain_id(1337u64);
// The wallet can be used to sign messages
let message = b"hello";
let signature = wallet.sign_message(message).await?;
assert_eq!(signature.recover(&message[..]).unwrap(), wallet.address());
Implementations
Creates a new random encrypted JSON with the provided password and stores it in the provided directory
pub fn decrypt_keystore<P, S>(
keypath: P,
password: S
) -> Result<Self, WalletError> where
P: AsRef<Path>,
S: AsRef<[u8]>,
pub fn decrypt_keystore<P, S>(
keypath: P,
password: S
) -> Result<Self, WalletError> where
P: AsRef<Path>,
S: AsRef<[u8]>,
Decrypts an encrypted JSON from the provided path to construct a Wallet instance
Connects to a yubi key’s ECDSA account at the provided id
Creates a new random ECDSA keypair on the yubi at the provided id
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
impl<D: Sync + Send + DigestSigner<ProxyDigest<Sha256>, RecoverableSignature>> Signer for Wallet<D>
impl<D: Sync + Send + DigestSigner<ProxyDigest<Sha256>, RecoverableSignature>> Signer for Wallet<D>
Sets the wallet’s chain_id, used in conjunction with EIP-155 signing
type Error = Infallible
Signs the hash of the provided message after prefixing it
fn sign_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 TypedTransaction
) -> Pin<Box<dyn Future<Output = Result<Signature, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn sign_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 TypedTransaction
) -> Pin<Box<dyn Future<Output = Result<Signature, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Signs the transaction
Auto Trait Implementations
impl<D> RefUnwindSafe for Wallet<D> where
D: RefUnwindSafe,
impl<D> UnwindSafe for Wallet<D> where
D: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more