To better support gaming applications, the Token Metadata program supports the concept of "token usage". That means, any token — fungible or not — can be loaded with a certain amount of uses that will decrease over time until it has no uses left.
This feature has been added to the Token Metadata program in version 1.1.
The Uses field
To support this feature, the Metadata account contains an optional
Uses field. When this field is set to
None, it means the token is not leveraging this feature. When this field is set, it contains further nested fields that define the token's usage. Namely, it contains the following fields:
Use Method: This field is an enum that defines a "token usage" strategy. It can be one of the following:
Burn: This strategy allows a token to be used once and then burned forever.
Single: This strategy allows a single use but does not burn the token.
Multiple(u64): This strategy allows a pre-defined amount of uses of the token. The specific amount of uses is stored using a
Remaining: This field holds the number of uses remaining for the token.
Available: This field holds the number of uses initially available for the token.
Uses field is set up, we may "use the token" by calling the following instruction:
Delegating the Use Authority
By default, only the owner of the NFT is allowed to reduce the number of uses of a token. However, it is possible to delegate this responsibility to other trusted authorities. These delegated "Use Authorities" can then reduce the number of uses via the instruction mentioned in the previous section.
The following instructions enable us to approve and reject a Use Authority:
Note that this is very similar to the Collection Authority system but the party who can approve and revoke authorities is the current token holder of the NFT, as opposed to the Update Authority for collections.