Skip to main content

Using the playground

The playground is a Softchat client that runs in the page. It loads the SDK's WebAssembly build and uses the same RelaySession, SoftchatIdentity and SoftchatEvents an application would, so what you see is what any Softchat client does.

Start​

  1. New test key creates an identity in this tab. To use an existing one, paste its secret key as 64 hexadecimal characters.
  2. Connect opens a WebSocket to the relay in the toolbar, answers its NIP-42 challenge and asks for this key's inbox: the last 200 envelopes, then every new one.
  3. Paste someone's npub or hexadecimal key under Chats, choose Open, and write. To answer a message, choose reply on it.

The key exists only in this tab's memory. It is not stored, not sent anywhere, and Forget key erases it. A key you paste here is as exposed as the browser tab it is in: use a test key unless you mean to act as that identity.

What each panel shows​

Chats groups messages by their member set, as every Softchat client does. Your messages show their delivery state from the relay's answer: sending, accepted or rejected. Reactions, and edits and deletions by a message's own author, are applied as they arrive; a deletion signed by anyone else is ignored, as in every Softchat client.

Protocol has two views. Relay frames lists every frame in both directions: AUTH, REQ, EVENT, the EVENTS batch that carries your message, the relay's OK for each envelope, EOSE at the end of stored events. Select a frame to see its JSON; an EVENT frame opens its envelope. SDK actions lists what the relay session told the page to do: open the socket, authenticate, store an event, report a delivery, reconnect after a delay.

Envelope opens one message layer by layer: the gift wrap the relay stores, the seal its author signed, and the rumor that holds the text. A copy sent to someone else cannot be opened here; it is encrypted for them. Open your own copy of the message instead.

Commands​

The line at the bottom accepts short commands; help lists them.

CommandDoes
key newCreate a test identity in this tab.
key import <hex>Use an existing secret key.
connect [url]Connect, authenticate and load the inbox.
chatsList conversations with their index.
read <n> [count]Show the last messages of conversation n.
send <npub>[,<npub>…] <text>Send a message to one or more people.
reply <message id> <text>Reply to a message.
inspect <message id>Open the message's envelope.
frames [count]Print the last relay frames.
wait [npub]Wait for the next incoming message.

From an agent​

The page exposes the same operations as window.softchat, returning plain JSON values, so a browser-automation agent can use the client without reading the screen:

await softchat.generateKey(); // or softchat.importKey(secretHex)
await softchat.connect(); // resolves when the relay session is ready
softchat.conversations(); // [{index, key, members, subject, messages, last}]
softchat.messages(0, 20); // the last 20 messages of the first conversation
const id = softchat.send("npub1…", "Hello"); // returns the message ID
softchat.reply(id, "Following up");
const next = await softchat.waitForMessage(); // the next message from someone else
softchat.inspect(next.id); // the wrap, seal and rumor of that message
softchat.frames(50); // the last 50 relay frames, raw JSON included

softchat.help() lists every function. Errors are thrown with a readable message, for example when no key exists yet or the relay is not connected.

What it leaves out​

The playground shows the protocol, not a full app. It keeps everything in memory, asks the relay for the latest 200 envelopes instead of synchronizing with Negentropy, does not send attachments, and has no read markers. The account runtime is the complete client the Android app uses.