The DIG SDK
@dignetwork/dig-sdk is the typed npm package for integrating developers. It unifies one wallet surface over two transports, reads verified content, monetizes access, and re-exports the canonical spend builder — so you wire DIG into your app without scraping prose or hand-rolling a spend.
npm i @dignetwork/dig-sdk
npm i @walletconnect/sign-client # optional: only for the WalletConnect fallback
What's in it
| Export | Subpath | What it does |
|---|---|---|
ChiaProvider | @dignetwork/dig-sdk | One wallet API; prefers injected window.chia, falls back to WalletConnect → Sage |
DigClient | @dignetwork/dig-sdk | Reads verified, encrypted content over the dig RPC — verify-then-decrypt, client-side |
Paywall | @dignetwork/dig-sdk | High-level pay-to-unlock / NFT-or-collection ownership gating |
| canonical CHIP-0035 spend builder | @dignetwork/dig-sdk/spend | The wasm that builds every coin spend — never hand-rolled |
ChiaProvider — connect a wallet
import { ChiaProvider } from "@dignetwork/dig-sdk";
// "auto" prefers the injected DIG Browser wallet, else WalletConnect → Sage.
const provider = await ChiaProvider.connect({ mode: "auto" });
const address = await provider.getAddress();
// provider.backend tells you which transport connected.
One connect() works in the DIG Browser (no QR, no relay) and everywhere else (WalletConnect). The method names and result shapes are identical either way; the exact contract is the normative window.chia provider spec.
DigClient — read verified content
import { DigClient } from "@dignetwork/dig-sdk";
const dig = new DigClient(); // resolves a node automatically; pass endpoint to override
const html = await dig.readText({
urn: "urn:dig:chia:<storeId>/index.html",
root: "<onchain-root-hex>", // the trust anchor, read from the chain
});
DigClient accepts an endpoint constructor option to point at a specific node; left unset, it resolves one automatically — preferring a reachable local dig-node (dig.local, then localhost) and falling back to the public gateway https://rpc.dig.net only when neither answers. Pointing at a local node changes where ciphertext is fetched, never whether it's trusted: it derives the URN's keys in the browser, verifies inclusion against the on-chain root, and decrypts — the serving host stays blind. → What is the dig RPC?