Skip to main content

Module token_metadata_ix

Module token_metadata_ix 

Source
Expand description

Token-metadata and token-group interface instructions.

Both interfaces are implemented by Token-2022 itself (a mint that carries the TokenMetadata or TokenGroup extension is its own metadata or group account) and can be implemented by any other program, so every builder here targets Token-2022 from invoke() and any interface program from invoke_on_program.

Instructions are selected by an 8-byte discriminator (the first eight bytes of the SHA-256 of the interface’s hash input); the payload is Borsh: a string is a little-endian u32 length followed by its bytes, an Option<u64> is a tag byte and, when present, the value, and an optional address is 32 bytes that are all zero when absent.

The variable-length instructions are encoded on the stack. The whole instruction must fit MAX_METADATA_INSTRUCTION_DATA bytes; a longer one is refused with InvalidArgument before the CPI. Token-2022 reallocates the mint to hold the metadata and does not fund it: the caller transfers the additional rent to the mint first.

Modules§

encoders
Byte-exact encoders, shared by the builders and the tests.

Structs§

Data
A bounded instruction-data writer. Every push checks the remaining room, so an oversized string is an error, never a truncation.
EmitTokenMetadata
Emit: return the serialized metadata (or the start..end slice of it) as the program’s return data.
InitializeTokenGroup
InitializeGroup: make group (for Token-2022, the mint itself) a group of at most max_size members. The mint authority signs.
InitializeTokenGroupMember
InitializeMember: make member (for Token-2022, the member’s mint) a member of group. The member’s mint authority and the group’s update authority both sign.
InitializeTokenMetadata
Initialize: write the base metadata (name, symbol, URI) into metadata, which for Token-2022 is the mint itself. The mint authority signs. The account must already hold the rent for its new size.
RemoveMetadataKey
RemoveKey: remove an additional key. With idempotent a missing key is not an error.
UpdateMetadataAuthority
UpdateAuthority: hand the metadata’s update authority to new_authority, or remove it with None.
UpdateMetadataField
UpdateField: set the name, the symbol, the URI, or an additional key to value. A new key or a longer value grows the account, which must already hold the rent for it.
UpdateTokenGroupAuthority
UpdateGroupAuthority: hand the group’s update authority to new_authority, or remove it with None.
UpdateTokenGroupMaxSize
UpdateGroupMaxSize: change the largest number of members.

Enums§

MetadataField
The field an UpdateMetadataField writes: one of the three base fields or an additional key.

Constants§

DISC_GROUP_INITIALIZE
spl_token_group_interface:initialize_token_group.
DISC_GROUP_INITIALIZE_MEMBER
spl_token_group_interface:initialize_member.
DISC_GROUP_UPDATE_AUTHORITY
spl_token_group_interface:update_authority.
DISC_GROUP_UPDATE_MAX_SIZE
spl_token_group_interface:update_group_max_size.
DISC_METADATA_EMIT
spl_token_metadata_interface:emitter.
DISC_METADATA_INITIALIZE
spl_token_metadata_interface:initialize_account.
DISC_METADATA_REMOVE_KEY
spl_token_metadata_interface:remove_key_ix.
DISC_METADATA_UPDATE_AUTHORITY
spl_token_metadata_interface:update_the_authority.
DISC_METADATA_UPDATE_FIELD
spl_token_metadata_interface:updating_field.
MAX_METADATA_INSTRUCTION_DATA
The largest instruction data a metadata builder encodes.