Files
nym/sdk/rust/nym-sdk/examples/simple.rs
T
2023-02-09 14:58:42 +01:00

22 lines
693 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::MixnetClient::connect_new().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, "hello there").await;
println!("Waiting for message (ctrl-c to exit)");
client
.on_messages(|msg| println!("Received: {}", String::from_utf8_lossy(&msg.message)))
.await;
}