Skip to main content

Crate chip35_dl_coin

Crate chip35_dl_coin 

Source
Expand description

§chip35-dl-coin

Isolated CHIP-0035 Chia DataLayer store coin driver. Provides the offline spend builders to mint, update, and burn (melt) DataLayer stores, plus keyless spend-bundle serialization helpers. No networking, no signing, no key derivation — those are the caller’s responsibility.

Structs§

Attribute
A single CHIP-0007 attribute (trait) on an NFT item.
BulkMintResponse
The result of a bulk mint: the coin spends + the launcher id of every minted NFT (in order).
Bytes
Cat
Contains all information needed to spend the outer puzzles of CAT coins. The CatInfo is used to construct the puzzle, but the LineageProof is needed for the solution.
CatInfo
Information needed to construct the outer puzzle of a CAT. This includes the CatLayer and RevocationLayer if present. However, it does not include the inner puzzle, which must be stored separately.
Chip0007Metadata
A CHIP-0007 metadata document (the off-chain JSON an NFT’s metadata_uris point at).
Coin
CoinSelection
A successful selection: the chosen coins (descending by amount, tie-broken by coin id) plus the selected total and the change over target. coins[0] is the largest — the natural lead coin for the builders, which spend element 0 as the lead.
CoinSpend
Collection
A CHIP-0007 collection definition: the shared identity + economics across every item.
CollectionAttribute
A single CHIP-0007 collection-level attribute (icon/banner/website/twitter/etc).
CollectionRef
The collection block embedded in a CHIP-0007 item, linking the item to its Collection.
CreateDidResponse
The result of creating a DID: the coin spends + the new DID’s identifiers for storage/attribution.
DataStore
Everything that is required to spend a Datastore coin.
DataStoreInfo
DataStoreMetadata
DidAttribution
DID attribution for a mint: ties the NFT to a creator-identity DID so collectors can verify who minted it (roadmap #38’s building block). The DID owner must authorize the mint elsewhere in the bundle (the DID spend); here it only supplies the on-chain TransferNft condition.
DidInfo
Information needed to construct the outer puzzle of a DID. It does not include the inner puzzle, which must be stored separately.
EveProof
HashedPtr
IssueCatResponse
The result of issuing a CAT: the coin spends + the permanent asset id + the issued CAT coins.
LazyMintClaimResponse
The result of a claim: the unroll+mint coin spends + the minted NFT identifiers.
LazyMintCommitResponse
The result of a commit: the single DID spend + the precomputed per-item identifiers.
LazyMintItem
One precommitted item: its on-chain media metadata (URN + https fallback URIs + hashes) and its royalty. The recipient/royalty puzzle hash come from the Collection (shared across items).
LazyMintTreeDescriptor
A keyless, serializable handle a caller PERSISTS after a commit so a claimer — who never saw the commit call — can rebuild the exact item i claim spend. It captures everything the claim needs: the creator DID coin id (the commitment coins’ parent), the committed collection + items + policy + optional allowlist root, and the precomputed per-item commitment coins + launcher ids.
LineageProof
ManifestItem
One item in a parsed traits manifest. The toolkit produces this from a CSV/JSON manifest + the per-item capsule hashes; this crate consumes the parsed form only (no file IO).
ManifestMedia
The on-chain media fields for a manifest item (mirrors NftMediaMetadata in a serde-friendly, hex-hash shape for the parsed manifest).
MerkleMembershipProof
A merkle membership proof for an allowlist-gated claim. The shape mirrors chia_sdk_types::MerkleProof (and the on-chain merkle_utils.clib proof shape): a path of direction bits and the proof sibling hashes along the path.
NftMediaMetadata
The on-chain NFT metadata fields, with hashes already computed from the real bytes (#36).
NftMintParams
Everything needed to mint one NFT (a single-item mint; bulk mint is in [crate::collection]).
NftMintResponse
The result of a mint: the coin spends to sign + a summary of the minted NFT for chaining/storage.
NftOwnershipProof
The facts a successful proof establishes about an NFT (all read from the chain, none asserted).
ObservedPayment
What an observed payment looks like to the verifier (the paywall) once it has read the chain.
PaymentReceipt
A verifiable description of the on-chain commitment a payment makes. The dapp/SDK keeps this and, once the spend confirms, checks the owner actually received a coin matching it (see verify_payment_receipt). It is the receipt a paywall verifies — it pins WHO is paid (owner puzzle hash), HOW MUCH, in WHICH asset, and the unlock NONCE.
PaymentResponse
The result of building a payment: the coin spends to sign + the receipt to verify after confirm.
Program
PublicKey
SecretKey
Signature
SpendBundle
SubscriptionTerms
The terms of a subscription a buyer authorizes once: pay amount_per_period of asset to payee_puzzle_hash every period_seconds, for at most max_periods.
SuccessResponse
Result of a store-creating/updating spend: the coin spends plus the resulting on-chain store state to feed into the next update.

Enums§

DataStoreInnerSpend
Which delegated role authorizes a store update, carrying that role’s public key.
DelegatedPuzzle
Error
Errors produced by the DataLayer store spend builders.
GatingError
The reasons an NFT gate can fail — actionable so a dapp can tell the user why access was denied.
LazyMintPolicy
Who a claim mints to, and whether a claim must pay.
MetadataError
Errors from CHIP-0007 metadata building/validation. Distinct from the spend-builder Error so JS gets actionable, metadata-specific messages.
PaymentAsset
Which asset a payment settles in.
PaywallError
The reasons a paywall check can fail — actionable so the dapp/SDK can tell the user precisely what is wrong rather than a generic “access denied”.
Proof
SelectCoinsResult
The discriminated outcome of select_coins. NeedsConsolidation is deliberately distinct from InsufficientFunds: the former means “the money is here but too fragmented”, the latter means “not enough money”. Every failure carries the counts the caller needs to drive a consolidation loop or an honest error.

Constants§

CHIP0007_FORMAT
The canonical CHIP-0007 format discriminator value.
DATASTORE_LAUNCHER_HINT
DEFAULT_COIN_CAP
The default maximum number of coins a single selection (and thus a single spend bundle) will use. Chosen to keep a spend bundle comfortably within block/mempool cost limits; a caller may override it per selection.
DIGSTORE_OWNER_HINT_DOMAIN
Domain tag for the digstore-scoped owner DISCOVERY hint. Scoping the hint to digstores (rather than hinting the raw owner puzzle hash) means a coinset get_coin_records_by_hint(digstore_owner_hint(owner_ph)) query returns ONLY the owner’s DataLayer store launcher coins — never their ordinary XCH coins, which are hinted with the raw puzzle hash. Versioned so the derivation can evolve without ambiguity.
DIG_ASSET_ID
DIG CAT asset id (TAIL hash) on Chia mainnet. The single token a capsule (commit) is paid in.
DIG_TREASURY_INNER_PUZZLE_HASH
The DIG treasury’s INNER (standard) puzzle hash — the recipient of every per-capsule DIG payment.

Functions§

add_fee
Build coin spends that reserve fee mojos from the spender’s own XCH coins, asserting concurrent spend of coin_ids (e.g. the singleton being updated/melted), returning change to the spender. Lets a singleton-only op (update/melt) carry a fee.
admin_delegated_puzzle_from_key
Build the Admin delegated puzzle for a synthetic key (hub Teams #43 — a team admin).
build_bulk_mint
Build the spend bundle that bulk-mints every item in items into collection, attributed to did, authorized by a single DID spend.
build_bulk_mint_funded
Build a MULTI-item DID-attributed bulk mint FUNDED by a separate XCH coin (#221).
build_bulk_mint_funded_no_did
Build a NON-DID MULTI-item (N>=1) bulk mint FUNDED by a COIN SET with a SINGLE network fee (#1132).
build_cat_consolidation
Build the keyless spends that merge up to cap of the smallest CAT cats (all of ONE asset id) into ONE output CAT coin of total back to the owner (self-send) (epic #410).
build_cat_payment
Build the spends for a buyer to pay the dapp owner amount base units of a CAT (incl. DIG) (roadmap #46).
build_coin_consolidation
Build the keyless spends that merge up to cap of the smallest XCH coins into ONE output coin back to the owner (self-send of total - fee), reserving an optional network fee (epic #410).
build_dig_store_payment
Build the (UNSIGNED) DIG-CAT coin spends that pay amount base units of $DIG to the DIG treasury for a capsule (commit) — the canonical per-capsule store payment.
build_lazy_mint_claim
A NON-owner unrolls + mints item index on demand, funding the 1-mojo launcher (+ fee) from claimer_coins. No DID involvement — the claim is authorized by the precommit alone.
build_lazy_mint_commit
The creator DID spends ONCE to precommit items into collection, attributed by lineage to did.
build_subscription_authorization
TODO(#46 subscriptions): build the one-time spend that FUNDS a subscription — locking terms.amount_per_period * terms.max_periods into a time-locked / pre-authorized puzzle the dapp can claim one period at a time, with a buyer clawback path. Requires the recurring puzzle (see the module docs); NOT yet implemented. Returns WalletError::Parse until the puzzle ships.
build_subscription_claim
TODO(#46 subscriptions): build the spend the DAPP runs each period to CLAIM that period’s amount_per_period from a funded subscription (after period_seconds elapsed). Requires the recurring puzzle; NOT yet implemented.
build_xch_payment
Build the spends for a buyer to pay the dapp owner amount mojos of XCH (roadmap #46).
create_did
Build the spend bundle that creates a simple DID (one verification, no recovery list) owned by the minter.
datastore_from_spend
Reconstruct a DataStore from the coin spend that CREATED its current coin. For an eve store (no updates) this is the launcher coin’s spend; for an updated store it is the latest update spend. Lets a client MELT a store it did not mint in-session (it fetches the creating spend from a full node, then rebuilds the DataStore here). prev_delegated is the parent’s delegated-puzzle set ([] for an eve/owner-only store). Returns the reconstructed DataStore, or a Parse error if the spend is not a DataStore spend.
decode_offer
Decode canonical offer text (offer1...) into its spend bundle.
dig_treasury_payment_coin
The DIG CAT payment coin a capsule (commit) pays to the treasury — what build_dig_store_payment emits.
digstore_owner_hint
Derive the digstore-scoped owner discovery hint = sha256(DOMAIN || owner_puzzle_hash). It is emitted as the FIRST (indexed) memo on the launch CREATE_COIN so the store is discoverable on-chain by owner. The client (JS) and the digstore CLI MUST compute this identically (same domain tag, same byte order) or detection misses stores.
encode_offer
Encode a spend bundle into canonical offer text (offer1...).
generate_item_metadata
Generate the per-item CHIP-0007 metadata documents for a collection from a parsed manifest.
hex_spend_bundle_to_coin_spends
Decode a hex-encoded spend bundle into its coin spends (keyless).
issue_cat
Build the spend bundle that issues a single-issuance (fixed-supply) CAT.
master_to_wallet_unhardened
melt_store
Build the spend that BURNS (melts) a store singleton, removing it from the chain.
merkle_membership_root
Recompute the merkle root implied by a leaf + its membership proof, using the EXACT algorithm of chia_sdk_types::MerkleTree and the on-chain include/merkle_utils.clib: leaves are hashed sha256(0x01 || leaf), internal nodes sha256(0x02 || left || right), and at each step the path’s low bit selects whether the running hash is the right child (1) or the left child (0). A caller can compare the result against a known allowlist root to verify membership.
mint_nft
Build the spend bundle that mints a single NFT whose media lives in a DIG capsule.
mint_nft_with_did
Mint a single NFT authorized by + attributed to a creator DID (roadmap #38).
mint_store
Build the spend bundle that LAUNCHES a new DataLayer store singleton.
oracle_delegated_puzzle
Build the Oracle delegated puzzle: anyone may spend the store for the fixed oracle_fee, paid to oracle_puzzle_hash. Unlike admin/writer it is keyed by a payment puzzle hash, not a public key — there is no signer; the fee is the gate.
oracle_spend
Build the spend that exercises a store’s ORACLE delegated puzzle.
payment_nonce
Derive a 32-byte unlock nonce from arbitrary request bytes (e.g. dapp_id || resource || user).
prove_collection_membership
Prove an NFT held by claimed_owner_puzzle_hash is a member of the collection/creator identified by required_did (roadmap #46 collection-gating).
prove_nft_ownership
Prove an NFT is owned by claimed_owner_puzzle_hash (roadmap #46 NFT-gating).
read_nft_ownership
Reconstruct the CURRENT NftOwnershipProof for an NFT from the coin spend that created its latest coin.
select_coins
Select coins high-value-first to cover target, using at most cap coins.
sha256
SHA-256 of arbitrary bytes → the 32-byte hash pinned on-chain. The one true hash primitive for data_hash, metadata_hash, and license_hash.
spend_bundle_to_hex
Serialize a spend bundle to hex (keyless).
synthetic_puzzle_hash
Compute the standard puzzle hash for a synthetic key — the convenience used to default the bulk-mint recipient to the minter’s own wallet.
update_store_metadata
Build the spend that updates a store’s metadata (root hash, label, description, size, and optional size-proof program_hash).
update_store_ownership
Build the spend that transfers store ownership and/or replaces its delegated-puzzle set.
validate_uri_hash
Validate URI↔hash agreement for one asset: the on-chain expected hash MUST equal sha256(bytes) of what the URI actually serves. which is “data” | “metadata” | “license” for error reporting. This is the footgun-closing check roadmap #36 calls for — the on-chain hash must match the served bytes, or every verifying client rejects the NFT.
verify_merkle_membership
Verify that leaf is a member of the merkle tree whose root is root, given a membership proof. Returns true iff merkle_membership_root(leaf, proof) == root. Constant in the proof length; does no allocation beyond the running hash.
verify_payment_receipt
Verify an observed payment unlocks a paywall: it must pay the required owner_puzzle_hash, in the required asset, at least min_amount, and (when require_nonce is set) carry that nonce (roadmap #46, pay-to-unlock).
writer_delegated_puzzle_from_key
Build the Writer delegated puzzle for a synthetic key (a revocable deploy token #17 / a hub Teams writer #43).

Type Aliases§

Bytes32
Did
Contains all information needed to spend the outer puzzles of DID coins. The DidInfo is used to construct the puzzle, but the Proof is needed for the solution.
WalletError
Alias so the copied driver bodies (which reference WalletError) compile unchanged.