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

Decrypts an encrypted JSON from the provided path to construct a Wallet instance

Creates a new random keypair seeded with the provided RNG

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

Uploads the provided keypair on the yubi at the provided id

Gets the wallet’s signer

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Gets the wallet’s chain id

Panics

If the chain id has not already been set.

Sets the wallet’s chain_id, used in conjunction with EIP-155 signing

Signs the hash of the provided message after prefixing it

Signs the transaction

Encodes and signs the typed data according EIP-712. Payload must implement Eip712 trait. Read more

Returns the signer’s Ethereum Address

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more