Cashu-TS - v4.0.0-rc3
    Preparing search index...

    Function deserializeProofs

    • Deserializes proofs from JSON back into typed Proof objects, restoring amount as bigint without silent precision loss.

      • Pass a string[] (individual proof JSON strings) when reading from NutZap proof tags or a database.
      • Pass a string (a JSON array) when reading from a single stored blob e.g. localStorage.

      Parameters

      • json: string | string[]

      Returns Proof[]

      // NutZap proof tags
      const proofs = deserializeProofs(
      event.tags.filter((t) => t[0] === 'proof').map((t) => t[1]),
      );

      // localStorage
      const proofs = deserializeProofs(JSON.parse(localStorage.getItem('proofs') ?? '[]'));