SPL Token recipe

sunscreen scaffold spl-token <NAME> --program <PROGRAM> [FLAGS]

Generates an SPL Token mint+transfer slice inside an existing program.

Flags

FlagDefaultDescription
--program <name>requiredwhich program to scaffold into
--decimals <n>9mint decimals
--frontend-hookoffgenerate matching React/Solid hook
--dry-runoffprint plan only
--jsonoffsummary on stdout
--forceoffoverwrite marker content even on conflict

Generated files

For scaffold spl-token MyToken --program app:

PathStatus
programs/app/src/state/my_token.rscreated (mint metadata account)
programs/app/src/instructions/init_my_token.rscreated
programs/app/src/instructions/mint_my_token.rscreated
programs/app/src/instructions/transfer_my_token.rscreated
programs/app/src/instructions/mod.rspatched
programs/app/src/lib.rspatched (dispatch)
programs/app/src/events.rspatched
programs/app/src/errors.rspatched
tests/my_token.spec.tscreated

Generated instructions

InstructionEffect
init_my_tokenCreates the mint PDA, sets authority and decimals
mint_my_tokenMints amount to a destination token account (CPI to spl-token)
transfer_my_tokenTransfers amount between token accounts

Generated events

  • TokenInitialized { mint, authority, decimals }
  • TokenMinted { mint, recipient, amount }
  • TokenTransferred { from, to, amount }

Generated errors

  • MintUnauthorized
  • InsufficientBalance

Notes

  • This recipe uses the classic SPL Token program (Tokenkeg…). For SPL Token-2022, install the sunscreen-apps/spl-token-2022 plugin and use sunscreen scaffold spl-token-2022 ….
  • The mint is a PDA seeded by ["mint", name.as_bytes()], so the same name yields the same address per program.

Exit codes

CodeWhen
0success
4preflight conflict
5not in a workspace