Simple Send

Lets look at a very simple example of how you can import and use the websocket client in a piece of Rust code (examples/

Simply importing the nym_sdk crate into your project allows you to create a client and send traffic through the mixnet.

use nym_sdk::mixnet;
use nym_sdk::mixnet::MixnetMessageSender;

async fn main() {

    // 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 through the mixnet to ourselves
        .send_plain_message(*our_address, "hello there")

    println!("Waiting for message (ctrl-c to exit)");
        .on_messages(|msg| println!("Received: {}", String::from_utf8_lossy(&msg.message)))