Skip to content
This tutorial builds one token in three steps. It ends with a Token-2022 mint whose accounts start frozen, whose holders are gated by an onchain allowlist, and whose pause, forced-transfer, burn, and metadata powers sit on separate keys. The design decisions behind that mint are set out in choosing token controls. Each step is a short script that reads key files from ~/.config/solana and the mint’s addresses from environment variables, so you run them one after another from a terminal. Every code block on these pages is tested. Most steps are shown in all four implementations; where a step is shown only for some of them, the page says so. The output under it is what that script printed on a local test network (Surfpool).

​Before you start

You need the Solana CLI for key files and transfers, and Node.js 20.18 or later for the TypeScript implementations or a Rust toolchain for the Rust one.

​1. Create the project

The scripts use top-level await, so the project must be an ES module project. The Mosaic SDK and the Token ACL clients it uses declare @solana/kit 6 and older Token-2022 clients; the overrides keep the project on one copy of Kit 8 and its @solana/sysvars, and give the Token ACL client the Token-2022 client built for Kit 8.
Terminal
The Mosaic SDK and the Token ACL clients are pre-1.0, and a minor release can change their APIs. These tutorials are tested against @solana/mosaic-sdk 0.2.0, @solana/token-acl-sdk 0.4.0, and @solana/token-acl-gate-sdk 0.3.1. Keep those versions pinned in anything that depends on them, and check the Mosaic and Token ACL repositories before you upgrade.

​2. Generate the issuer’s keys

The fee payer, tokenization-demo.json, creates the mint and holds the mint authority. Create the four operational keys now as well; the next page explains what each one controls.
Terminal

​3. Pick a network

The scripts read the network from two environment variables and use devnet when they are unset.
  • Local: install the Surfpool CLI (1.6 or later) and run surfpool start. In the terminal you run the scripts from, set the two variables:
    Terminal
  • Devnet: leave both unset.
Then fund the fee payer.
  • Local: airdrop SOL from Surfpool:
    Terminal
  • Devnet: the public devnet RPC no longer serves airdrops. Print the fee payer’s address with solana-keygen pubkey ~/.config/solana/tokenization-demo.json and request devnet SOL for it from the Solana Faucet.

​4. Add the shared helpers

Save this as common.ts (in Rust, src/lib.rs). Every script imports it: it creates the connection, loads key files, reads $MINT and $LIST, and sends transactions. When a transaction is rejected, it prints the failing program’s error and exits with a non-zero code.
The Kit, Web3.js v3, and Rust implementations build the Token ACL instructions themselves, so they need one more file: save this as gate.ts (in Rust, src/acl.rs). New accounts on the mint start frozen, and openThroughGate (open_through_gate in Rust) returns the instructions that create a holder’s account and thaw it through the gate. The thaw is permissionless: anyone can send it, and the gate program approves it only for a wallet on the allowlist. The Mosaic SDK does the same inside its transaction builders.
Mosaic also publishes a CLI, @solana/mosaic-cli. Its write commands do not send transactions in version 0.2.0 (October 2026), so these tutorials use the SDK.

​Next steps

  • Create the mint: a Token-2022 mint with its operational authorities on separate keys