Skip to content

​What Is Immutable Owner?

The Token Extension Program’s ImmutableOwner account extension makes a token account’s owner permanent. Once a token account is initialized with ImmutableOwner, later SetAuthority instructions cannot change its AccountOwner authority.
Associated Token AccountsAssociated token accounts created through the Associated Token Program for the Token Extension Program automatically initialize ImmutableOwner on the token account.

​Before you start

The examples on this page run against a local validator at http://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 Initialize an Immutable Owner Account

To initialize an immutable owner account:
  1. Create and initialize a mint.
  2. Create a token account with enough space for ImmutableOwner.
  3. Initialize ImmutableOwner on the token account before InitializeAccount.
  4. Attempting to change the account owner later with SetAuthority fails with TokenError::ImmutableOwner.
1

Calculate token account size

Calculate the token account size for the base token account plus the ImmutableOwner extension. This is the size used in CreateAccount.
Example
2

Calculate rent

Calculate rent using the token account size needed for the ImmutableOwner extension.
Example
3

Create the token account

Create the token account with the calculated space and lamports.
Example
4

Initialize ImmutableOwner

Initialize the ImmutableOwner extension on the token account.
Example
5

Initialize the token account

Initialize the token account with InitializeAccount in the same transaction.
Example
Instruction OrderInitializeImmutableOwner must come before InitializeAccount. CreateAccount, InitializeImmutableOwner, and InitializeAccount must be included in the same transaction.

​Source Reference

ItemDescriptionSource
ImmutableOwnerAccount extension that marks a token account owner as immutable.Source
InitializeImmutableOwnerInstruction that initializes the immutable-owner extension on an uninitialized token account.Source
process_initialize_immutable_ownerProcessor logic that allocates and initializes ImmutableOwner on the account.Source
SetAuthorityBase token instruction used to change authorities, including a token account owner.Source
process_set_authorityProcessor logic that rejects owner changes when the token account has ImmutableOwner enabled.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 to Cargo.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