Polkadot Apps
    Preparing search index...

    High-level client for the Polkadot Statement Store.

    Provides a simple publish/subscribe API over the ephemeral statement store, handling topic management, signing (host or local), and resilient delivery (subscription + polling fallback).

    import { StatementStoreClient } from "@polkadot-apps/statement-store";

    // Inside a container (host mode)
    const client = new StatementStoreClient({ appName: "my-app" });
    await client.connect({ mode: "host", accountId: ["5Grw...", 42] });

    // Outside a container (local mode)
    await client.connect({ mode: "local", signer: { publicKey, sign } });

    // Publish
    await client.publish({ type: "presence", peerId: "abc" }, {
    channel: "presence/abc",
    topic2: "room-123",
    });

    // Subscribe
    client.subscribe<{ type: string }>(statement => {
    console.log(statement.data.type);
    });

    // Cleanup
    client.destroy();
    Index

    Constructors

    Methods

    • Destroy the client, stopping polling, unsubscribing, and closing the transport.

      Safe to call multiple times. After destruction, the client cannot be reused.

      Returns void

    • Get the signer's public key as a hex string (with 0x prefix).

      Returns string

      The hex-encoded public key, or empty string if not connected or in host mode.

    • Publish typed data to the statement store.

      Type Parameters

      • T

        The type of data being published.

      Parameters

      • data: T

        The value to publish (must be JSON-serializable, max 512 bytes).

      • Optionaloptions: PublishOptions

        Optional channel, topic2, TTL, and decryption key overrides.

      Returns Promise<boolean>

      true if accepted, false if rejected or errored.

      If not connected.

      If the encoded data exceeds 512 bytes.

    • Query existing statements from the store.

      Only available when the transport supports queries (RPC mode). In host mode, the subscription replays existing statements automatically.

      Type Parameters

      • T

      Parameters

      • Optionaloptions: { topic2?: string }

      Returns Promise<ReceivedStatement<T>[]>