ethers-rs/ethers/examples/sign.rs

16 lines
408 B
Rust
Raw Permalink Normal View History

use ethers::prelude::*;
2020-05-24 16:14:27 +00:00
fn main() {
let message = "Some data";
2020-06-02 10:58:48 +00:00
let wallet = Wallet::new(&mut rand::thread_rng());
2020-05-24 16:14:27 +00:00
// sign a message
let signature = wallet.sign_message(message);
println!("Produced signature {}", signature);
// verify the signature
signature.verify(message, wallet.address()).unwrap();
2020-05-24 16:14:27 +00:00
println!("Verified signature produced by {:?}!", wallet.address());
2020-05-24 16:14:27 +00:00
}