Token Metadata uses a delegation system where specific actors are granted powers to perform actions on assets or collections. There are two primary types of delegates:
1. Token Delegates
These operate at the token level (similar to spl-token delegates) and allow operations like burning, transferring, or freezing.
- Storage: Information is stored on a
TokenRecord account (a PDA with seeds ["metadata", program_id, mint_id, "token_record", token_account_id]). - Constraint: There can only be one token delegate at a time. To set a new one, the current delegate must be revoked.
- Roles: Common roles include
Sale, Transfer, LockedTransfer, Utility, Staking, and Migration. - Special Roles:
Migration: A temporary role created during the transition from NFT to pNFT. It can transfer and perform utility actions, but once used, it is cleared and cannot be replaced.LockedTransfer: Can lock/unlock a pNFT and transfer it to a specific locked_address defined at creation.
2. Metadata Delegates
These operate at the metadata level and are represented by a MetadataDelegateRecord PDA (seeds ["metadata", program_id, mint_id, delegate_role, update_authority_id, delegate_id]). Unlike token delegates, you can have multiple metadata delegates.
- Collection: Can set and verify NFTs within a collection.
- Update: Can perform updates on the metadata account.
- Use: Allows an actor to "use" the asset and decrement an on-chain usage counter.
// TokenRecord structure for Token Delegates
pub struct TokenRecord {
pub key: Key,
pub bump: u8,
pub state: TokenState,
pub rule_set_revision: Option<u64>,
pub delegate: Option<Pubkey>,
pub delegate_role: Option<TokenDelegateRole>,
pub locked_transfer: Option<Pubkey>,
}
// MetadataDelegateRecord structure for Metadata Delegates
pub struct MetadataDelegateRecord {
pub key: Key,
pub bump: u8,
pub mint: Pubkey,
pub delegate: Pubkey,
pub update_authority: Pubkey,
}