Metaplex Program Library

repository·master·Indexed 20 days ago

https://github.com/metaplex-foundation/metaplex-program-library

A collection of core smart contracts and SDKs for the Metaplex ecosystem on Solana. It enables advanced NFT and token functionalities, including the Auction House (mpl-auction-house), Candy Machine (mpl-candy-machine), Fixed Price Sale (mpl-fixed-price-sale), and Hydra (mpl-hydra), along with core utility libraries like mpl-utils.

Tokens
90.7K
Snippets
283
Records
372
Agent score
68%

What's inside metaplex-program-library

  1. Overview of Metaplex Program Library

    master
    The Metaplex Program Library is a collection of smart contracts and SDKs designed for the Metaplex ecosystem. It provides various specialized programs for NFT and token management, including Auction House, Candy Machine, Bubblegum, and Token Metadata. Developers can consume these capabilities via Rust crates for on-chain/low-level development or npm packages for high-level SDK integration.
  2. Access the Metaplex Candy Machine V3 (Candy Machine Core) repository

    master

    The Candy Machine Core program and its associated Solita library have been moved to a dedicated repository. For all programs, clients, and SDKs related to Candy Machine V3, use the mpl-candy-machine repository.

    • Repository: https://github.com/metaplex-foundation/mpl-candy-machine
    • Program Documentation: Located within the programs/candy-machine-core directory of the new repository.
    • Solita SDK: Available via NPM as part of the mpl-candy-machine client packages.
  3. How Metaplex NFT packs work

    master

    Metaplex NFT packs allow for the creation of "mystery" packages of NFTs. Users purchase a voucher (an Edition) and then undergo a two-step redemption process: first, they request a card to determine which specific NFT they receive, and second, they claim that card to mint the new Edition to their wallet.

    The Redemption Lifecycle

    1. Request Card (RequestCardForRedeem): The user calls this to receive a specific card index. The program burns the user's voucher token account and uses a combination of slot hash, timestamp, and recent slot hash to calculate probability based on the pack's distribution type. The result is recorded in a ProvingProcess account.
    2. Claim (ClaimPack): After receiving an index, the user calls this instruction to mint the actual Edition to their wallet.

    Pack States

    • Not Activated: Initial state; admin is setting up the pack.
    • Activated: Users can begin the redemption process. Admin cannot change pack data.
    • Deactivated: Users cannot interact with the pack, but the admin can modify data (e.g., Edit pack).
    • Ended/Closed: The pack is finished. Admin can perform cleanup by deleting cards, vouchers, and finally the pack itself.
  4. Configure NFT pack distribution types

    master

    When initializing a pack, you must choose one of three distribution types which dictate how cards are revealed and their supply limits:

    TypeProbabilitySupplyDescription
    UnlimitedSet by user via card weightsUnlimitedCards never run out. Users cannot specify a fixed amount of each card type.
    WeightedSet by user via card weightsLimitedUsers choose the specific amount of each card type available in the pack.
    SupplyAutomatically calculated based on supplyLimitedUsers choose the specific amount of each card type available.

    Note: Both Weighted and Supply types can include cards with 'unlimited' editions if the max_supply is set accordingly.

  5. Manage NFT pack lifecycle and administration

    master

    Administrators can manage the lifecycle of an NFT pack using the following actions:

    Setup and Content

    • Admin init a pack: Initializes the PackSet PDA. Seeds: ["nft-pack", nft_pack_program_id, store, pack_admin_key, pack_name].
    • Add cards: Transfers a MasterEdition to the program account. Each card is a PDA with seeds [pack_key, "card", index].
    • Add voucher: Saves MasterEdition data to the pack. Vouchers are PDAs with seeds [pack_key, "voucher", index]. Users who own an Edition from the associated Master can open the pack.

    State Transitions

    • Activate: Moves the pack to an activated state where users can start redeeming. Data becomes immutable.
    • Deactivate: Allows users to stop interacting so the admin can modify pack details.
    • Edit pack: (Only in deactivated state) Allows changing name, description, URI (wallpaper), and mutable status.
    • Close pack: Irreversible state change. Can be called if there is no end date, or if the end date has passed. Returns EndDateNotArrived if called too early.

    Cleanup

    • CleanUp: Sorts the weights Vec in the PackConfig account. This should be called once users have requested cards to ensure probability calculations remain accurate.
    • Delete card/voucher/pack: Can only be performed when the pack is in a closed state. Deleting a card transfers the MasterEdition back to the admin.
  6. Regenerate the Auction House SDK

    master

    If the underlying Rust contract has been updated, you must regenerate the SDK to ensure the JavaScript/TypeScript definitions match the new contract logic.

    Currently, running the generation command produces the IDL (Interface Definition Language) JSON file. Future updates to this process will also automatically generate TypeScript definitions and full SDK code derived from that IDL.

    yarn api:gen