Skip to content

Add optional max supply cap per creator at registration to enable enforced key scarcity #394

@Chucks1093

Description

@Chucks1093

Summary

Every creator on the platform currently has unlimited key supply determined only by demand. Some creators may want to hard-cap the number of keys that can ever exist for them — creating genuine scarcity that cannot be undone. Adding an optional max_supply field at registration gives creators this control at the contract level, enforced on-chain with no way for anyone to override it after the fact.

Scope

  • Add optional max_supply: Option<u32> parameter to register_creator
    • If None, supply is uncapped (current behavior, fully backwards-compatible)
    • If Some(n), the value is stored in creator state and n must be greater than zero
  • At the start of buy, check if current_supply + amount_to_buy > max_supply and panic with a new SupplyCapExceeded error if true
  • Add get_max_supply(creator_id) -> Option<u32> view function
  • The cap is immutable after registration — no function may update it

Acceptance Criteria

  • Registration with None behaves identically to current behavior
  • Registration with Some(0) is rejected with an appropriate error
  • Buy that would exceed the cap reverts with SupplyCapExceeded
  • Buy that stays within the cap succeeds normally
  • get_max_supply returns None for uncapped creators and the cap value for capped ones
  • No function exists that can update the cap after registration
  • Unit tests cover: uncapped buy, capped buy within limit, capped buy at limit, capped buy exceeding limit

Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions