Skip to content

Gated mint program#456

Open
pileks wants to merge 12 commits intopileks/launchpad-v8from
pileks/met-339-private-token
Open

Gated mint program#456
pileks wants to merge 12 commits intopileks/launchpad-v8from
pileks/met-339-private-token

Conversation

@pileks
Copy link
Copy Markdown
Contributor

@pileks pileks commented May 1, 2026

Introduces gated_mint, a new program that gates an SPL Mint behind an admin-managed whitelist by holding the mint's freeze authority. Whitelisted users move tokens through gated_invoke, which thaws relevant token accounts before a CPI into a whitelisted target program and re-freezes them after. Couples into v08_launchpad: any base mint with a freeze authority must point it at the deterministic gated_mint_config PDA.

This PR stacks on pileks/launchpad-v8; the launchpad_v8 program/SDK/tests are part of this diff against develop but land via that PR. The net new scope here is the gated_mint program, its SDK module, its tests, and the 19-line freeze-authority check in initialize_launch.

Instructions

Instruction Role
initialize_gated_mint Moves the mint's freeze authority into the gated_mint_config PDA (seed ["gated_mint_config", mint]) via set_authority CPI; stores per-mint admin.
add_whitelisted_user Admin-gated; creates a WhitelistedUser PDA at ["whitelisted_user", mint, user].
gated_invoke Whitelisted-user-only; for each mint token account in remaining_accounts, thaws if frozen, runs invoke on target_program (must be in WHITELISTED_PROGRAMS, must not be gated_mint::ID), then re-freezes any account left in Initialized state.
disable_gating Admin-only one-way switch; blocks gated_invoke and add_whitelisted_user, unlocks permissionless thaw_account.
thaw_account Permissionless unwind path callable only after disable_gating; thaws a single token account of the gated mint.

Other Changes

  • v08_launchpad::initialize_launch now requires that, if base_mint.freeze_authority is set, it equals the canonical gated_mint_config PDA derived from base_mint. This is a pure on-chain find_program_address check, no CPI into gated_mint. Mints without a freeze authority continue to work unchanged.
  • SDK: new @metadaoproject/programs/gated_mint (v0.1) module with GatedMintClient, PDA helpers, and generated types; re-exported from the package root.
  • Tests: unit tests for each gated_mint instruction plus tests/integration/gatedLaunchpadV8.test.ts exercising the full lifecycle: init gated mint → init/start/fund/settle launchpad_v8 launch → claim (frozen ATAs thawed and re-frozen via gated_invoke) → disable gating → permissionless thaw_account.

@pileks pileks changed the title Pileks/met 339 private token Gated mint program May 5, 2026
@pileks pileks requested a review from metaproph3t May 5, 2026 17:23
@pileks pileks self-assigned this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant