Files
nym/sdk/rust/nym-sdk/examples/simple.rs
T
2023-01-10 01:36:27 +01:00

24 lines
696 B
Rust

use nym_sdk::mixnet;
#[tokio::main]
async fn main() {
logging::setup_logging();
// Passing no config makes the client fire up an ephemeral session and figure shit out on its own
let mut client = mixnet::Client::connect().await.unwrap();
// Be able to get our client address
let our_address = client.nym_address();
println!("Our client nym address is: {our_address}");
// Send a message throught the mixnet to ourselves
client
.send_str(&our_address.to_string(), "hello there")
.await;
println!("Waiting for message");
client
.on_messages(|msg| println!("Received: {}", String::from_utf8_lossy(&msg.message)))
.await;
}