← Back to Home

Technical Specification

Sparkle Protocol v1.0.0 - JSON Schemas and Validation Rules

Version 1.0.0 | Last Updated: December 2025

Table of Contents

  1. sparkle_genesis - Collection Metadata
  2. sparkle_child - Per-Inscription Metadata
  3. sparkle_checkout - Lightning Checkout
  4. Validation Rules
  5. Sparkle Swap - Trustless Atomic Swaps
  6. Implementation Guidelines

1. sparkle_genesis

Collection-level metadata inscribed once per collection. This inscription acts as the canonical source for collection information.

1.1 JSON Schema

{
  "p": "sparkle",
  "op": "genesis",
  "version": 1,
  "collection": {
    "name": "Darkita",
    "symbol": "DARKITA",
    "description": "10K PFP collection with Lightning-ready checkout.",
    "supply": 10000,
    "creator": {
      "name": "Creator Name",
      "website": "https://example.com",
      "pubkey": "optional-hex-or-nostr-pubkey"
    }
  },
  "spark": {
    "enabled": true,
    "networks": ["spark", "ln-mainnet"]
  },
  "royalties": {
    "bps": 500,
    "recipients": [
      {
        "label": "creator",
        "lightning_address": "creator@example.com",
        "ln_node_pubkey": "optional-ln-node-pubkey"
      }
    ]
  }
}

1.2 Field Definitions

FieldTypeRequiredDescription
pstringYesProtocol identifier. Must be "sparkle".
opstringYesOperation type. Must be "genesis".
versionintegerYesProtocol version. Currently 1.
collection.namestringYesHuman-readable collection name.
collection.symbolstringYesShort uppercase ticker (3-10 characters).
collection.supplyintegerYesTotal number of NFTs. Soft commitment.
spark.enabledbooleanYesLightning/Spark checkout support.
royalties.bpsintegerNoRoyalty in basis points (500 = 5%).

1.3 Usage Notes

2. sparkle_child

Per-inscription metadata attached to each NFT in the collection.

2.1 JSON Schema

{
  "p": "sparkle",
  "op": "child",
  "version": 1,
  "collection_ref": "<GENESIS_INSCRIPTION_ID>",
  "token": {
    "id": 123,
    "name": "Darkita #123"
  },
  "media": {
    "type": "image/png",
    "recursive_parents": [
      "<PARENT_INSCRIPTION_ID_1>",
      "<PARENT_INSCRIPTION_ID_2>"
    ]
  },
  "traits": {
    "Background": "Yellow",
    "Eyes": "Glowing",
    "Accessory": "None"
  }
}

2.2 Field Definitions

FieldTypeRequiredDescription
collection_refstringYesGenesis inscription ID this NFT belongs to.
token.idintegerYes1-based index within collection (1 to supply).
token.namestringNoDisplay name for this specific NFT.
media.typestringNoMIME type of embedded media.
media.recursive_parentsarrayNoParent inscription IDs for recursive art.
traitsobjectNoKey-value pairs for marketplace filtering.

2.3 Usage Notes

3. sparkle_checkout

Lightning/Spark checkout object agreed upon by wallets, markets, and coordinators before payment.

3.1 JSON Schema

{
  "p": "sparkle",
  "op": "checkout",
  "version": 1,
  "inscription_id": "<INSCRIPTION_ID_BEING_BOUGHT>",
  "collection_ref": "<GENESIS_INSCRIPTION_ID>",
  "buyer": {
    "ord_address": "bc1p...buyer...",
    "lightning_address": "buyer@example.com",
    "ln_node_pubkey": "optional-ln-node-pubkey"
  },
  "network": "spark",
  "max_total_sats": 1500000,
  "pricing": {
    "seller_sats": 1400000,
    "creator_royalty_sats": 20000,
    "market_fee_sats": 30000,
    "estimated_l1_fee_sats": 50000
  },
  "market": {
    "id": "example.market",
    "name": "Example Market"
  },
  "expiry_block": 900000,
  "buyer_sig": "<optional-signature>"
}

3.2 Field Definitions

FieldTypeRequiredDescription
inscription_idstringYesOrdinal inscription being purchased.
buyer.ord_addressstringYesBitcoin address for Ordinal delivery.
networkstringYes"spark" or "ln-mainnet".
max_total_satsintegerYesMaximum sats buyer agrees to pay.
pricing.seller_satsintegerYesAmount to seller.
pricing.creator_royalty_satsintegerYesCreator royalty amount.
pricing.market_fee_satsintegerYesMarketplace fee.
pricing.estimated_l1_fee_satsintegerYesEstimated on-chain fee.
expiry_blockintegerNoBlock height when checkout expires.

4. Validation Rules

4.1 Rule 1: Sum Check

max_total_sats MUST equal the sum of all fields in pricing:

max_total_sats = seller_sats + creator_royalty_sats + market_fee_sats + estimated_l1_fee_sats

4.2 Rule 2: Royalty Check

creator_royalty_sats SHOULD be calculated based on the genesis bps value. Markets SHOULD warn if royalty exceeds genesis declaration.

4.3 Rule 3: Display Requirement

Wallets MUST display complete pricing breakdown before payment confirmation.

4.4 Rule 4: Network Match

Payment must be processed on the network specified in the network field.

5. Sparkle Swap - Trustless Atomic Swaps

Implementation Status: COMPLETE
TypeScript reference implementation available. All tests passing. Transaction sizes: Claim 142 vbytes, Refund 138 vbytes.

Sparkle Swap enables trustless ordinal trading using Taproot hashlock scripts. The atomic swap guarantees that either both parties get what they want, or nothing happens.

5.1 Security Model

5.2 Taproot Script Structure

// Buyer Claim Path (hashlock)
OP_SHA256 <payment_hash> OP_EQUALVERIFY <buyer_pubkey> OP_CHECKSIG

// Seller Refund Path (timelock)
<locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP <seller_pubkey> OP_CHECKSIG

5.3 Trade Flow

StepActorAction
1SellerCreates listing with ordinal details and price
2BuyerAccepts listing and pays 1% deposit via Lightning
3SellerSends ordinal to Taproot escrow address
4BuyerPays full price via Lightning, learns preimage
5BuyerClaims ordinal on-chain using preimage + signature

5.4 Delta-Safety Guarantee

To prevent race conditions during blockchain reorgs:

5.5 Lightning Compatibility

Sparkle Swap is Lightning-agnostic and works with:

6. Implementation Guidelines

6.1 For Creators

  1. Inscribe sparkle_genesis JSON as first collection inscription
  2. Record the genesis inscription ID
  3. Reference genesis ID in all sparkle_child inscriptions
  4. Set spark.enabled: true if supporting Lightning checkout

6.2 For Marketplaces

  1. Index inscriptions containing p: "sparkle"
  2. Build collection structures from genesis references
  3. Generate sparkle_checkout objects for listings
  4. Integrate with Sparkle Swap coordinator for trustless trades

6.3 For Wallets

  1. Parse and validate sparkle_checkout objects
  2. Display complete fee breakdown to users
  3. Warn if fees exceed genesis royalty declaration
  4. Process Lightning payments per network field

6.4 For Indexers

  1. Scan for inscriptions with p: "sparkle"
  2. Build collection graphs from collection_ref references
  3. Track child counts against declared supply
  4. Identify Lightning-enabled collections

References