Skip to content

Gated mint program#456

Open
pileks wants to merge 143 commits into
developfrom
pileks/met-339-private-token
Open

Gated mint program#456
pileks wants to merge 143 commits into
developfrom
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.

The gated_mint_config PDA stores two authorities: a privileged admin (set once at init, controls everything) and an optional whitelist_admin (a delegated role that can only add whitelisted users). The admin can rotate or clear the whitelist_admin at any time.

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 and an optional whitelist_admin (must differ from admin).
add_whitelisted_user Callable by either admin or the configured whitelist_admin; creates a WhitelistedUser PDA at ["whitelisted_user", mint, user].
set_whitelist_admin Admin-only; sets, rotates, or clears the optional whitelist_admin on gated_mint_config. New value must differ from admin. Blocked once gating_disabled is true.
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, add_whitelisted_user, and set_whitelist_admin, 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 (including set_whitelist_admin coverage and whitelist_admin-signed paths in add_whitelisted_user) 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 and others added 30 commits January 8, 2026 22:34
…e proposal has already passed but not been finalized yet
…AOproject/programs into pileks/met-5-optimistic-governance
@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
@pileks pileks changed the base branch from pileks/launchpad-v8 to develop May 6, 2026 16:15
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