What Are Non-Transferable Tokens?
The Token Extension Program’sNonTransferable mint extension makes every
token account for that mint non-transferable. After tokens are minted, token
holders cannot move them to another token account with Transfer or
TransferChecked.
This pattern is useful for assets that should stay attached to one wallet.
Non-transferable tokens can still be:
- Minted by the mint authority
- Burned by the token account owner or an authorized delegate
- Token accounts can be closed after the balance reaches zero
Token Account ExtensionsWhen a token account is initialized for a mint with
NonTransferable, the
token account is initialized with NonTransferableAccount and
ImmutableOwner. When the token account is created through the
Associated Token
Program,
the required account size is calculated and the token account is created with
the required size and rent-exempt lamports.Before you start
The examples on this page run against a local validator athttp://localhost:8899 (WebSocket ws://localhost:8900) and fund their
accounts with airdrops from it. Start one in a separate terminal with
Surfpool (surfpool start) or
solana-test-validator.
Each code section below lists the packages or crates it needs. The TypeScript
examples use top-level await, so run them as ES modules, for example with
npx tsx index.ts in a project whose package.json sets "type": "module".
How to Create a Non-Transferable Mint
To create a non-transferable mint:- Calculate the mint account size and rent needed for the mint and the
NonTransferableextension. - Create the mint account with
CreateAccount, initializeNonTransferable, and initialize the mint withInitializeMint. - Create token accounts for the mint.
NonTransferableAccountandImmutableOwnerare automatically enabled for token accounts. TransferandTransferCheckedfail withTokenError::NonTransferable.
1
Calculate account size
Calculate the mint account size for the base mint plus the
NonTransferable
extension. This is the size used in CreateAccount.2
Calculate rent
Calculate rent using the size needed for the mint plus the
NonTransferable
extension.3
Create the mint account
Create the mint account with the calculated space and lamports.
4
Initialize NonTransferable
Initialize the
NonTransferable extension on the mint.5
Initialize the mint
Initialize the mint with
InitializeMint in the same transaction.Instruction Order
InitializeNonTransferableMint must come before InitializeMint.
CreateAccount, InitializeNonTransferableMint, and
InitializeMint must be included in the same transaction.Source Reference
| Item | Description | Source |
|---|---|---|
NonTransferable | Mint extension that marks tokens from the mint as non-transferable. | Source |
NonTransferableAccount | Token account extension added to token accounts for non-transferable mints. | Source |
ImmutableOwner | Token account extension that prevents ownership changes and is required for non-transferable token accounts. | Source |
InitializeNonTransferableMint | Instruction that initializes the mint-level non-transferable extension before InitializeMint. | Source |
process_initialize_non_transferable_mint | Processor logic that initializes the NonTransferable mint extension on an uninitialized mint. | Source |
get_required_init_account_extensions | Used to automatically add token account extensions when token accounts are initialized based on extensions enabled on the mint. For NonTransferable mints, it adds NonTransferableAccount and ImmutableOwner. | Source |
Kit
These examples use the generated Token-2022 instructions directly.Terminal
Instructions
Web3.js v3
These examples use the class-based@solana/web3.js v3 API with
@solana-program instruction builders.
Terminal
Instructions
Rust
Add these dependencies toCargo.toml (tested with Rust 1.89, 1.98, and 1.99):
Cargo.toml
Rust
Web3.js (legacy)
These examples use legacy@solana/web3.js with @solana/spl-token.
@solana/web3.js 1.x is no longer actively maintainedIt receives critical fixes only. Use Kit for new code. To migrate existing code, follow the Kit upgrade guide, or the web3.js v3 migration guide to keep the class-based API.To run this code, install 1.x with npm install @solana/web3.js@1. A plain npm install @solana/web3.js installs v3, which this code doesn’t run on.Terminal
Instructions