Bitflags
Bitflags are used to encode information about collections and minting settings. You will need to learn how they work when creating applications that interact with the NFTs pallet.
Collection settings
Collection settings are defined by a bit-field encoding information for:
- Changing deposit requirements
- Modifying max supply
- Modifying attributes
- Locking collection metadata
- Item transferrability
This is also the order of which bits each configuration corresponds to from left to right.
For example, the corresponding binary value for a default collection setting is 00000
(or 0
as an integer).
This would be the equivalent of constructing a collectionConfig
object defined as:
const collectionConfig = {
settings: 0, // <- this integer specifies default settings
maxSupply: undefined,
mintSettings: {
mintType: "Issuer",
price: undefined,
startBlock: undefined,
endBlock: undefined,
defaultItemSettings: 0,
}
};
To make items non-transferrable upon the creation of a collection, the settings would be equivalent to 1
or 00001
in binary. To both lock the collection metadata and make items non-transferrable we would specify the setting as 3
or 00011
in binary.
Item settings
When creating a collection, you also can specify settings for individual items.
const collectionConfig = {
settings: 0,
maxSupply: undefined,
mintSettings: {
mintType: "Issuer",
price: undefined,
startBlock: undefined,
endBlock: undefined,
defaultItemSettings: 0, // <- this field encodes the item settings
}
};
Item settings are defined by 3-bit values for:
- Making attributes editable (this cannot be changed once set)
- Making metadata editable (this cannot be changed once set)
- Transferability (in the sense of freezing or unfreezing which could be changed by admin)
This is also the order of which bits each configuration corresponds to from left to right.
For example, to lock the metadata of an item the item setting would be the integer 2
or 010
in binary.
💡 Use the Codesandbox below to try out the different collection settings you can make.