Skip to content

add pinocchio transfer-tokens example#596

Merged
Perelyn-sama merged 2 commits into
solana-foundation:mainfrom
MarkFeder:tokens-transfer-tokens-pinocchio
Jun 21, 2026
Merged

add pinocchio transfer-tokens example#596
Perelyn-sama merged 2 commits into
solana-foundation:mainfrom
MarkFeder:tokens-transfer-tokens-pinocchio

Conversation

@MarkFeder

Copy link
Copy Markdown
Contributor

What

Adds a Pinocchio implementation of tokens/transfer-tokens, covering the core SPL flow:

  1. CreateToken — create and initialize an SPL token mint
  2. MintTokens — create the recipient's associated token account (idempotent) and mint to it
  3. TransferTokens — transfer tokens between associated token accounts

This is the first Pinocchio example under tokens/, following the pattern of the recently merged pinocchio examples.

How

The program dispatches three instructions by a leading discriminator byte (0=CreateToken, 1=MintTokens, 2=TransferTokens), using pinocchio-token, pinocchio-associated-token-account, and pinocchio-system.

A solana-bankrun test exercises the full create → mint 150 → transfer 50 flow and asserts the resulting 100 / 50 balances. The legacy SPL Token and Associated Token Account programs are bundled with bankrun, so no extra fixtures are loaded.

The package.json / pnpm-lock.yaml / tsconfig.json are copied from basics/repository-layout/pinocchio so --frozen-lockfile passes (only deps already present in the lockfile are used).

Checks run locally

  • cargo fmt --check
  • cargo clippy -- -D warnings
  • biome check

Add a Pinocchio implementation of tokens/transfer-tokens covering the
core SPL flow: create a mint, mint tokens to an associated token
account, and transfer tokens between wallets.

The program dispatches three instructions by a leading discriminator
byte (0=CreateToken, 1=MintTokens, 2=TransferTokens) using
pinocchio-token, pinocchio-associated-token-account, and
pinocchio-system. A bankrun test exercises the full create -> mint 150
-> transfer 50 flow and asserts the resulting 100/50 balances.
@MarkFeder MarkFeder force-pushed the tokens-transfer-tokens-pinocchio branch from 479683d to 62c8661 Compare June 20, 2026 12:17
The whole-repo `biome check ./` (TypeScript CI job) was failing on three
files unrelated to this PR, which kept the check red:

- basics/cross-program-invocation/pinocchio/tests/test.ts: remove an unused
  discriminator constant and replace non-null assertions with explicit null
  guards
- tokens/token-swap/anchor/tests/deposit-liquidity.ts: apply the biome formatter
- tokens/token-2022/.../app/public/{next,vercel}.svg: add a <title> element
  (noSvgWithoutTitle)
@Perelyn-sama Perelyn-sama merged commit fe68bb6 into solana-foundation:main Jun 21, 2026
15 checks passed
@MarkFeder MarkFeder deleted the tokens-transfer-tokens-pinocchio branch June 21, 2026 21:01
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.

2 participants