{
  "address": "EQkRJkgLqNQkS4hJKieeTFpW6mAbFDKQpagj2PFZ2mzw",
  "metadata": {
    "name": "bitfauna_core",
    "version": "0.1.0",
    "spec": "0.1.0",
    "description": "BitFauna Core — Metaplex Core NFT with on-chain pixel canvas"
  },
  "instructions": [
    {
      "name": "burn_for_ap",
      "docs": [
        "Burn one of your Core Assets to gain AP on another one you own.",
        "AP gain = pixelcount × percent × 2 / 100  (Burn-Tier-Formel)",
        "Tier 0 (≤490px): 1–4% | Tier 1 (491–890px): 2–4% | Tier 2 (891+px): 3–6%",
        "The burned Core Asset is destroyed; AssetMeta + PixelAccount are closed."
      ],
      "discriminator": [
        60,
        229,
        49,
        173,
        13,
        95,
        53,
        172
      ],
      "accounts": [
        {
          "name": "owner",
          "docs": [
            "Aktueller Besitzer beider Assets (muss unterschreiben)"
          ],
          "writable": true,
          "signer": true
        },
        {
          "name": "burn_asset",
          "docs": [
            "Core Asset das geburnt wird. Owner in handler via Raw-Bytes geprüft."
          ],
          "writable": true
        },
        {
          "name": "burn_asset_meta",
          "docs": [
            "AssetMeta des gebrannten Assets — wird nach Burn geschlossen, Rent → owner"
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  109,
                  101,
                  116,
                  97
                ]
              },
              {
                "kind": "account",
                "path": "burn_asset"
              }
            ]
          }
        },
        {
          "name": "burn_pixel_account",
          "docs": [
            "PixelAccount des gebrannten Assets — wird geschlossen falls vorhanden.",
            "SystemProgram ID übergeben falls das Token nie bearbeitet wurde."
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  112,
                  105,
                  120,
                  101,
                  108,
                  115
                ]
              },
              {
                "kind": "account",
                "path": "burn_asset"
              }
            ]
          }
        },
        {
          "name": "receiver_asset",
          "docs": [
            "Core Asset das die AP erhält. Owner ebenfalls in handler geprüft."
          ]
        },
        {
          "name": "receiver_asset_meta",
          "docs": [
            "AssetMeta des Empfängers — AP werden hier gutgeschrieben"
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  109,
                  101,
                  116,
                  97
                ]
              },
              {
                "kind": "account",
                "path": "receiver_asset"
              }
            ]
          }
        },
        {
          "name": "config",
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        },
        {
          "name": "traits_store",
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  116,
                  114,
                  97,
                  105,
                  116,
                  115
                ]
              }
            ]
          }
        },
        {
          "name": "collection",
          "docs": [
            "Core Collection — von mpl-core BurnV1 benötigt wenn Asset in einer Collection ist"
          ],
          "writable": true
        },
        {
          "name": "mpl_core_program",
          "address": "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
        },
        {
          "name": "slot_hashes",
          "docs": [
            "SlotHashes Sysvar — liefert On-Chain-Entropie für die Tier-Prozentberechnung"
          ],
          "address": "SysvarS1otHashes111111111111111111111111111"
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": []
    },
    {
      "name": "create_asset",
      "docs": [
        "Create one Core Asset + AssetMeta PDA. Authority-only.",
        "For Magic Eden / Tensor launchpad integration, they mint using their",
        "Candy Machine and reference our collection address — this instruction",
        "is for admin/test minting on devnet.",
        "`api_base` → e.g. \"https://api.bitfauna.art\""
      ],
      "discriminator": [
        28,
        42,
        120,
        51,
        7,
        38,
        156,
        136
      ],
      "accounts": [
        {
          "name": "authority",
          "docs": [
            "Program authority — only the admin may mint on behalf of launchpad"
          ],
          "writable": true,
          "signer": true,
          "relations": [
            "config"
          ]
        },
        {
          "name": "payer",
          "docs": [
            "Rent payer (may be same as authority or a separate treasury wallet)"
          ],
          "writable": true,
          "signer": true
        },
        {
          "name": "config",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        },
        {
          "name": "traits_store",
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  116,
                  114,
                  97,
                  105,
                  116,
                  115
                ]
              }
            ]
          }
        },
        {
          "name": "asset",
          "docs": [
            "New keypair — becomes the permanent Core Asset address.",
            "Generate with `Keypair.generate()` and include as signer."
          ],
          "writable": true,
          "signer": true
        },
        {
          "name": "collection",
          "docs": [
            "Core Collection — must match config.collection"
          ],
          "writable": true
        },
        {
          "name": "owner",
          "docs": [
            "Initial owner of the minted NFT (the buyer's wallet)"
          ]
        },
        {
          "name": "asset_meta",
          "docs": [
            "AssetMeta PDA — created here, stores trait_index + AP for lifetime of this asset"
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  109,
                  101,
                  116,
                  97
                ]
              },
              {
                "kind": "account",
                "path": "asset"
              }
            ]
          }
        },
        {
          "name": "mpl_core_program",
          "address": "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": [
        {
          "name": "api_base",
          "type": "string"
        }
      ]
    },
    {
      "name": "edit_pixels",
      "docs": [
        "Edit pixel data for a Core Asset.",
        "Ownership is verified directly from the Core Asset account (bytes 1..33).",
        "After an NFT transfer, the new owner can edit immediately —",
        "no claim_ownership call needed."
      ],
      "discriminator": [
        27,
        217,
        207,
        175,
        19,
        4,
        169,
        81
      ],
      "accounts": [
        {
          "name": "signer",
          "writable": true,
          "signer": true
        },
        {
          "name": "core_asset",
          "docs": [
            "Core Asset account — we read the `owner` field directly from raw bytes.",
            "No on-chain authority needed: ownership is tracked by mpl-core itself."
          ]
        },
        {
          "name": "asset_meta",
          "docs": [
            "Per-asset metadata — provides trait_index (→ base color) and AP budget."
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  109,
                  101,
                  116,
                  97
                ]
              },
              {
                "kind": "account",
                "path": "core_asset"
              }
            ]
          }
        },
        {
          "name": "traits_store",
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  116,
                  114,
                  97,
                  105,
                  116,
                  115
                ]
              }
            ]
          }
        },
        {
          "name": "pixel_account",
          "docs": [
            "Pixel canvas — lazy init on first edit."
          ],
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  112,
                  105,
                  120,
                  101,
                  108,
                  115
                ]
              },
              {
                "kind": "account",
                "path": "core_asset"
              }
            ]
          }
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": [
        {
          "name": "changes",
          "type": {
            "vec": {
              "defined": {
                "name": "PixelChange"
              }
            }
          }
        }
      ]
    },
    {
      "name": "initialize",
      "docs": [
        "Creates Config PDA + TraitsStore PDA. Run once after deploy."
      ],
      "discriminator": [
        175,
        175,
        109,
        31,
        13,
        152,
        155,
        237
      ],
      "accounts": [
        {
          "name": "authority",
          "writable": true,
          "signer": true
        },
        {
          "name": "config",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        },
        {
          "name": "traits_store",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  116,
                  114,
                  97,
                  105,
                  116,
                  115
                ]
              }
            ]
          }
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": []
    },
    {
      "name": "initialize_collection",
      "docs": [
        "Create the Metaplex Core Collection with 5% Royalties plugin.",
        "`collection_uri` → your collection-level metadata JSON URL."
      ],
      "discriminator": [
        112,
        62,
        53,
        139,
        173,
        152,
        98,
        93
      ],
      "accounts": [
        {
          "name": "authority",
          "writable": true,
          "signer": true,
          "relations": [
            "config"
          ]
        },
        {
          "name": "config",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        },
        {
          "name": "collection",
          "docs": [
            "New keypair — becomes the permanent Core Collection address.",
            "Generate with `solana-keygen new` and sign this TX with it."
          ],
          "writable": true,
          "signer": true
        },
        {
          "name": "mpl_core_program",
          "address": "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": [
        {
          "name": "collection_uri",
          "type": "string"
        }
      ]
    },
    {
      "name": "load_traits",
      "docs": [
        "Load trait data from traits.json in batches of ~50. Authority-only."
      ],
      "discriminator": [
        97,
        16,
        55,
        246,
        52,
        107,
        123,
        16
      ],
      "accounts": [
        {
          "name": "authority",
          "signer": true,
          "relations": [
            "config"
          ]
        },
        {
          "name": "config",
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        },
        {
          "name": "traits_store",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  116,
                  114,
                  97,
                  105,
                  116,
                  115
                ]
              }
            ]
          }
        }
      ],
      "args": [
        {
          "name": "start_idx",
          "type": "u32"
        },
        {
          "name": "entries",
          "type": {
            "vec": {
              "defined": {
                "name": "TraitEntryInput"
              }
            }
          }
        }
      ]
    },
    {
      "name": "set_authority",
      "discriminator": [
        133,
        250,
        37,
        21,
        110,
        163,
        26,
        121
      ],
      "accounts": [
        {
          "name": "authority",
          "signer": true,
          "relations": [
            "config"
          ]
        },
        {
          "name": "config",
          "writable": true,
          "pda": {
            "seeds": [
              {
                "kind": "const",
                "value": [
                  99,
                  111,
                  110,
                  102,
                  105,
                  103
                ]
              }
            ]
          }
        }
      ],
      "args": [
        {
          "name": "new_authority",
          "type": "pubkey"
        }
      ]
    }
  ],
  "accounts": [
    {
      "name": "AssetMeta",
      "discriminator": [
        27,
        233,
        213,
        152,
        111,
        28,
        0,
        94
      ]
    },
    {
      "name": "Config",
      "discriminator": [
        155,
        12,
        170,
        224,
        30,
        250,
        204,
        130
      ]
    },
    {
      "name": "PixelAccount",
      "discriminator": [
        150,
        134,
        150,
        182,
        153,
        85,
        89,
        224
      ]
    },
    {
      "name": "TraitsStore",
      "discriminator": [
        22,
        43,
        163,
        71,
        28,
        249,
        209,
        160
      ]
    }
  ],
  "errors": [
    {
      "code": 6000,
      "name": "NotAuthorized",
      "msg": "Not the owner of this Core Asset"
    },
    {
      "code": 6001,
      "name": "InvalidAsset",
      "msg": "Invalid Core Asset account"
    },
    {
      "code": 6002,
      "name": "AssetNotRegistered",
      "msg": "Asset not registered in this program"
    },
    {
      "code": 6003,
      "name": "InsufficientActionPoints",
      "msg": "Insufficient Action Points"
    },
    {
      "code": 6004,
      "name": "InvalidFlatIndex",
      "msg": "Pixel flat_index out of range (0..=1599)"
    },
    {
      "code": 6005,
      "name": "InvalidColor",
      "msg": "Color value must be 0–3"
    },
    {
      "code": 6006,
      "name": "MaxSupplyReached",
      "msg": "Max supply reached"
    },
    {
      "code": 6007,
      "name": "CollectionNotSet",
      "msg": "Collection not initialized — call initialize_collection first"
    },
    {
      "code": 6008,
      "name": "Unauthorized",
      "msg": "Unauthorized — caller is not the program authority"
    }
  ],
  "types": [
    {
      "name": "AssetMeta",
      "docs": [
        "Per-asset metadata PDA — seeds: [\"meta\", core_asset_pubkey]",
        "",
        "Created in create_asset. Tracks trait index (→ TraitsStore for base color)",
        "and action points (AP) budget."
      ],
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "core_asset",
            "type": "pubkey"
          },
          {
            "name": "trait_index",
            "type": "u16"
          },
          {
            "name": "action_points",
            "type": "u64"
          },
          {
            "name": "bump",
            "type": "u8"
          }
        ]
      }
    },
    {
      "name": "Config",
      "docs": [
        "Global config PDA — seeds: [\"config\"]"
      ],
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "authority",
            "type": "pubkey"
          },
          {
            "name": "collection",
            "type": "pubkey"
          },
          {
            "name": "next_trait_id",
            "type": "u32"
          },
          {
            "name": "bump",
            "type": "u8"
          }
        ]
      }
    },
    {
      "name": "PixelAccount",
      "docs": [
        "On-chain pixel canvas for one Core Asset — seeds: [\"pixels\", core_asset_pubkey]",
        "",
        "LAZY: created on the first edit_pixels call, not at mint time.",
        "Linked to the Core Asset address (permanent) so ownership transfers",
        "automatically — the new wallet can edit immediately."
      ],
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "core_asset",
            "type": "pubkey"
          },
          {
            "name": "pixel_data",
            "type": {
              "array": [
                "u8",
                400
              ]
            }
          },
          {
            "name": "bump",
            "type": "u8"
          }
        ]
      }
    },
    {
      "name": "PixelChange",
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "flat_index",
            "type": "u16"
          },
          {
            "name": "color",
            "type": "u8"
          }
        ]
      }
    },
    {
      "name": "TraitEntry",
      "docs": [
        "Trait data for a single NFT (packed 4 bytes)."
      ],
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "color_index",
            "type": "u8"
          },
          {
            "name": "pixelcount",
            "type": "u16"
          },
          {
            "name": "edited",
            "type": "bool"
          }
        ]
      }
    },
    {
      "name": "TraitEntryInput",
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "color_index",
            "type": "u8"
          },
          {
            "name": "pixelcount",
            "type": "u16"
          }
        ]
      }
    },
    {
      "name": "TraitsStore",
      "docs": [
        "All 1111 trait entries — seeds: [\"traits\"]"
      ],
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "entries",
            "type": {
              "vec": {
                "defined": {
                  "name": "TraitEntry"
                }
              }
            }
          }
        ]
      }
    }
  ]
}