What Are Group and Group Member Extensions?
A group is a mint that represents a collection. A group member is a mint that belongs to that collection. Use these extensions when one mint should represent the collection and other mints should represent items that belong to it. The Token Extension Program can store token group data directly on a mint with four related extensions:GroupPointerpoints a mint at the account that stores the group’s data.TokenGroupstores the group data itself, including the update authority, current size, and maximum size.GroupMemberPointerpoints a mint at the account that stores the member’s data.TokenGroupMemberstores the member’s group address and member number.
GroupPointer and GroupMemberPointer can reference any account owned
by a program implementing the
Token group interface.
The Token Extension Program also implements that interface directly through the
TokenGroup and TokenGroupMember mint extensions.
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 Groups and Members Stored on the Mint Account
To create groups and members stored on the mint account:- Create a group mint account and initialize
GroupPointer. - Initialize the group mint with
InitializeMint. - Initialize
TokenGroupon that same mint. - Create a member mint account and initialize
GroupMemberPointer. - Initialize the member mint with
InitializeMint. - Initialize
TokenGroupMemberon that same mint so it references the group mint.
1
Calculate group mint size and rent
Calculate the size and rent needed for the group mint.
2
Create and Initialize Group Mint
Create the group mint account, initialize
GroupPointer, initialize the
mint, and initialize TokenGroup in one transaction.3
Calculate member mint size and rent
Calculate the size and rent needed for the member mint.
4
Create and Initialize Member Mint
Create the member mint account, initialize
GroupMemberPointer, initialize
the mint, and initialize TokenGroupMember in one transaction.Pointers and Instruction Order
GroupPointer and GroupMemberPointer store the account address
where the group or member data lives. TokenGroup and
TokenGroupMember store the actual group or member data.GroupPointerInstruction::Initialize and
GroupMemberPointerInstruction::Initialize must come before
InitializeMint. TokenGroupInstruction::InitializeGroup and
TokenGroupInstruction::InitializeMember must come after
InitializeMint. For each mint, CreateAccount, the pointer initialize
instruction, and InitializeMint must be included in the same transaction.Source Reference
GroupPointer and GroupMemberPointer are pointer instructions in the
Token Extension Program. TokenGroup and TokenGroupMember follow the
Token group interface, which the Token Extension Program implements.
Group Pointer and Group Member Pointer
| Item | Description | Source |
|---|---|---|
GroupPointer | Mint extension that stores the authority and address for the account that stores a group’s data. | Source |
GroupMemberPointer | Mint extension that stores the authority and address for the account that stores a member’s data. | Source |
GroupPointerInstruction::Initialize | Initializes the group pointer extension before InitializeMint. | Source |
GroupPointerInstruction::Update | Updates the group address stored by the mint’s GroupPointer extension. | Source |
GroupMemberPointerInstruction::Initialize | Initializes the group member pointer extension before InitializeMint. | Source |
GroupMemberPointerInstruction::Update | Updates the member address stored by the mint’s GroupMemberPointer extension. | Source |
process_initialize (GroupPointer) | Writes the initial GroupPointer authority and group address onto the mint. | Source |
process_update (GroupPointer) | Validates the group pointer authority, then rewrites the mint’s stored group address. | Source |
process_initialize (GroupMemberPointer) | Writes the initial GroupMemberPointer authority and member address onto the mint. | Source |
process_update (GroupMemberPointer) | Validates the group member pointer authority, then rewrites the mint’s stored member address. | Source |
Token Group and Token Group Member
| Item | Description | Source |
|---|---|---|
TokenGroup | Token group interface state stored on the mint, including the update authority, current size, and maximum size. | Source |
TokenGroupMember | Token group member interface state stored on the mint, including the member mint, group address, and member number. | Source |
TokenGroupInstruction::InitializeGroup | Token group interface instruction supported by the Token Extension Program to initialize a new group for an already initialized mint. | Source |
TokenGroupInstruction::UpdateGroupMaxSize | Token group interface instruction supported by the Token Extension Program to update the maximum number of members allowed in a group. | Source |
TokenGroupInstruction::UpdateGroupAuthority | Token group interface instruction supported by the Token Extension Program to rotate or clear the group’s update authority. | Source |
TokenGroupInstruction::InitializeMember | Token group interface instruction supported by the Token Extension Program to initialize a new member for an already initialized group. | Source |
process_initialize_group | Validates the mint, checks that GroupPointer is present, and allocates the TokenGroup state on the group mint. | Source |
process_update_group_max_size | Validates the current update authority, then updates the group’s maximum size. | Source |
process_update_group_authority | Validates the current update authority, then rotates or clears the group’s update authority. | Source |
process_initialize_member | Validates the member mint and group authority, increments the group size, and allocates the TokenGroupMember state on the mint. | 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, including
its token group helpers.
@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