This specification defines how Sparkle Protocol handles upgrades, reinscriptions, and conflicting metadata. It establishes deterministic rules for ownership verification, parent/child ordering, and replay protection.
NFT owners need the ability to upgrade Lightning configuration or metadata without re-inscribing the entire NFT. Without clear upgrade rules, indexers will disagree on which metadata is authoritative.
An upgrade inscription MUST:
{
  "p": "sparkle",
  "v": 1,
  "op": "config",
  "parent": "abc123...i0",
  "lightning": {
    "enabled": false
  }
}
        When multiple upgrades exist for the same parent:
function isValidUpgrade(upgrade, parent, blockHeight) {
  // 1. Check parent reference
  if (upgrade.parent !== parent.inscriptionId) {
    return false;
  }
  // 2. Get parent owner at upgrade block
  const parentOwner = getOwnerAtBlock(parent, blockHeight);
  // 3. Check upgrade inscriber matches parent owner
  const upgradeInscriber = getInscriptionAddress(upgrade);
  return upgradeInscriber === parentOwner;
}
        To prevent cross-network replay attacks:
When applying an upgrade:
// Genesis inscription (block 100)
{
  "p": "sparkle",
  "v": 1,
  "op": "deploy",
  "layers": [{"id": "layer1...i0", "z": 0}],
  "lightning": {"enabled": true, "network": "mainnet"},
  "meta": {"name": "NFT #1"}
}
// Upgrade inscription (block 200)
{
  "p": "sparkle",
  "v": 1,
  "op": "config",
  "parent": "genesis...i0",
  "lightning": {"enabled": false}
}
// Effective state after block 200
{
  "p": "sparkle",
  "v": 1,
  "layers": [{"id": "layer1...i0", "z": 0}],  // inherited
  "lightning": {"enabled": false, "network": "mainnet"},  // merged
  "meta": {"name": "NFT #1"}  // inherited
}
        This upgrade mechanism is forwards-compatible. Indexers that don't implement SIP-2 will treat upgrades as independent inscriptions, which degrades gracefully.