Skip to content

Enforce a maximum ticket supply in the ticket contract #30

Description

@priscaenoch

Problem

ticket/src/lib.rs exposes mint_ticket and a tickets_sold counter, but there is no maximum supply: mint_ticket can be called indefinitely and tickets_sold only counts upward. For an event-ticketing contract, an uncapped supply means an organizer (or a bug) can mint beyond the intended allocation, and downstream consumers have no on-chain guarantee of scarcity.

What needs to be done

  • Add a maximum-supply parameter set at initialize (stored in instance storage).
  • Enforce it in mint_ticket: reject minting once tickets_sold reaches the maximum, returning a typed Error (add a "sold out"/"supply exceeded" variant).
  • Add a read-only getter for the configured maximum and the remaining supply.
  • Extend the instance TTL on the mint write and keep the existing event emissions.

Files

  • ticket/src/lib.rs

Acceptance deliverables

  • Minting beyond the configured maximum is rejected with a typed error.
  • The maximum and remaining supply are queryable on-chain.
  • All CI checks pass; the change cannot be merged until CI is green.

Tests to pass

  • Test: minting up to the maximum succeeds and the next mint returns the typed error.
  • Test: the remaining-supply getter decreases correctly as tickets are minted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions