Skip to content

eNet guides

The core is on crates.io:

Terminal window
cargo add enet-core

The Swift, Kotlin and WebAssembly bindings are not published yet; until they are, build exponential-net-ffi or exponential-net-wasm from the repo (ffi, wasm).

let node = Node::start(NetConfig::default(), Identity::from_bytes(saved)).await?;
let mut events = node.events().unwrap(); // taken once
node.add_ticket(&"enet1…".parse()?); // learn a peer's addresses
node.access().allow(peer_id); // and let it in
node.send_chat(peer_id, b"hi".to_vec()).await?; // acked by the peer
  • Keep the Identity (an ed25519 secret key, 32 bytes) across restarts; its public half is the id peers dial and allowlist.
  • Hand peers your Ticket (enet1…, fits a QR code) so they can find you.
  • NetConfig::relay picks the relay: the default, your own URLs, or Disabled for direct addresses only.

Every channel, push encryption and the security model: Reference.