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.
- Emit
Token Metadata Emit: return the serialized metadata (or thestart..endslice of it) as the program’s return data.- Initialize
Token Group InitializeGroup: makegroup(for Token-2022, the mint itself) a group of at mostmax_sizemembers. The mint authority signs.- Initialize
Token Group Member InitializeMember: makemember(for Token-2022, the member’s mint) a member ofgroup. The member’s mint authority and the group’s update authority both sign.- Initialize
Token Metadata Initialize: write the base metadata (name, symbol, URI) intometadata, which for Token-2022 is the mint itself. The mint authority signs. The account must already hold the rent for its new size.- Remove
Metadata Key RemoveKey: remove an additional key. Withidempotenta missing key is not an error.- Update
Metadata Authority UpdateAuthority: hand the metadata’s update authority tonew_authority, or remove it withNone.- Update
Metadata Field UpdateField: set the name, the symbol, the URI, or an additional key tovalue. A new key or a longer value grows the account, which must already hold the rent for it.- Update
Token Group Authority UpdateGroupAuthority: hand the group’s update authority tonew_authority, or remove it withNone.- Update
Token Group MaxSize UpdateGroupMaxSize: change the largest number of members.
Enums§
- Metadata
Field - The field an
UpdateMetadataFieldwrites: 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.