Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Crate: kinetic-wasm

Stage: 15 — Browser Native Web3

Depends On: kinetic-network, kinetic-core


What Is This?

kinetic-wasm compiles the Kinetic P2P network client into a Universal WebAssembly library. It allows web browsers (via extensions or embedded JS) to connect directly to the libp2p network, perform DHT lookups, and fetch content over P2P without needing a local daemon installed.


Universal Multi-TLD Support

It is designed as a “Universal Web3 Extension” driven by the Atlas Registry. It doesn’t just resolve .kin — it resolves any Kinetic network fork registered in Atlas.


How It Works

File:

#![allow(unused)]
fn main() {
kinetic-wasm/src/lib.rs
}

1. Dynamic Registry

#![allow(unused)]
fn main() {
fetch_registry()
}

downloads the global index.json from the kinetic-atlas GitHub repo. It populates a mapping of TLD -> AtlasNetworkConfig (which includes the network’s unique network_id for signatures, and bootstrap_nodes).


2. On-Demand Swarm Spawning

#![allow(unused)]
fn main() {
get_or_spawn_swarm(tld)
}

creates an isolated NetworkEventLoop (a full libp2p swarm) for that specific TLD.

  • It resolves bootstrap nodes via the kintree Merkle DNS tree if configured.
  • Spawns the async loop using wasm_bindgen_futures::spawn_local.
  • Caches the NetworkClient in a HashMap.

3. Resolution and Signature Validation

#![allow(unused)]
fn main() {
resolve_domain(full_domain)
}

:

  • Extracts the TLD and gets the correct swarm.
  • Calls client.resolve_redundant_payload().

Important

  • Crucial: Validates the DHT record signature using the specific network_id configured for that TLD in the Atlas registry. A record signed for .kin is rejected on .alt.

4. Garbage Collection

#![allow(unused)]
fn main() {
start_manager()
}

runs a 60-second loop.

Note

Any swarm unused for 10 minutes is dropped, terminating its WebSockets to conserve browser memory and network connections.