Polkadot Apps
    Preparing search index...

    Function getHostProvider

    • Get a PAPI-compatible JSON-RPC provider that routes through the host connection.

      When running inside a Polkadot container, this wraps the chain connection via the host's createPapiProvider, enabling shared connections and efficient routing. Returns null when @novasamatech/product-sdk is unavailable (standalone environments).

      Parameters

      • genesisHash: `0x${string}`

        Genesis hash of the target chain (0x-prefixed hex string).

      • Optionalfallback: JsonRpcProvider

        Optional fallback provider (e.g., WebSocket). Passed to the host provider, which uses it when the host doesn't support the requested chain.

      Returns Promise<JsonRpcProvider | null>

      A host-routed JsonRpcProvider, or null if product-sdk is unavailable.

      import { getHostProvider } from "@polkadot-apps/host";
      import { getWsProvider } from "polkadot-api/ws-provider/web";

      const ws = getWsProvider("wss://rpc.example.com");
      const provider = await getHostProvider("0xabc...", ws) ?? ws;