Building spends
When your app does something on-chain — mint a store, advance a capsule, pay in $DIG, mint an NFT — it builds the spend with the canonical CHIP-0035 spend builder and hands it to the wallet to sign. You never hand-roll a spend bundle. This is the exact pattern the hub and CLI use, so your app produces byte-identical spends.
The build → sign → broadcast split
- Build — the wasm builder constructs the coin spends. It is offline and pure: no keys, no network.
- Sign — the user's wallet (which holds the keys, not your app) signs them.
- Broadcast — combine into a spend bundle and push it to the network.
import { ChiaProvider } from "@dignetwork/dig-sdk";
import * as spend from "@dignetwork/dig-sdk/spend"; // the chip35 wasm builder
spend.init();
// 1. BUILD with the wasm — e.g. spend.mintStore(...) / spend.updateStoreMetadata(...) /
// spend.buildDigPayment(...). Pure + offline.
const coinSpends = /* spend.mintStore({ ... }) */ [];
// 2. SIGN with the wallet (keys live in the wallet, never in your app).
const provider = await ChiaProvider.connect({ mode: "auto" });
const aggregatedSignature = await provider.signCoinSpends(coinSpends);
// 3. BROADCAST — combine into a spend bundle and push it.