Features

Managing Collections

What are Collections?

Collections are a group of Assets that belong together, part of the same series, or group. In order to group Assets together, we must first create a Collection Asset whose purpose is to store any metadata related to that collection such as collection name and collection image. The Collection Asset acts as a front cover to your collection and can also store collection wide plugins.

The data that is stored and accessible from the Collection Asset is as follows;

AccountsDescription
keyThe account key discriminator
updateAuthorityThe authority of the new asset.
nameThe collection name.
uriThe uri to the collections off-chain metadata.
num mintedThe number of assets minted in the collection.
current sizeThe number of assets currently in the collection.

Creating a Collection

To create a Core Collection you can use the CreateCollection instruction like this:

Creating a Simple Collection

The following snippet creates a simple collection without Plugins or anything special.

Create a MPL Core Collection

import { generateSigner } from '@metaplex-foundation/umi'
import { createCollectionV1 } from '@metaplex-foundation/mpl-core'

const collectionSigner = generateSigner(umi)

await createCollectionV1(umi, {
  collection: collectionSigner,
  name: 'My Collection',
  uri: 'https://example.com/my-collection.json',
})

Creating a Collection with Plugins

The following snippet creates a collection with the Royalties Plugin attached. You can attach additional plugins as described here.

Create a MPL Core Collection with Plugin

import { generateSigner, publicKey } from '@metaplex-foundation/umi'
import {
  createCollectionV1,
  pluginAuthorityPair,
  ruleSet,
} from '@metaplex-foundation/core'

const collectionSigner = generateSigner(umi)

const creator1 = publicKey('11111111111111111111111111111111')
const creator2 = publicKey('22222222222222222222222222222222')

await createCollectionV1(umi, {
  collection: collectionSigner,
  name: 'My NFT',
  uri: 'https://example.com/my-nft.json',
  plugins: [
    pluginAuthorityPair({
      type: 'Royalties',
      data: {
        basisPoints: 500,
        creators: [
          {
            address: creator1,
            percentage: 20,
          },
          {
            address: creator2,
            percentage: 80,
          },
        ],
        ruleSet: ruleSet('None'), // Compatibility rule set
      },
    }),
  ],
}).sendAndConfirm(umi)

Updating a Collection

To update the data of a Core Collection use the UpdateCollection instruction. For example, you use this instruction to change the name of a collection.

Updating a Collection

import { publicKey } from '@metaplex-foundation/umi'
import { updateCollectionV1 } from '@metaplex-foundation/mpl-core'

const collectionAddress = publicKey('1111111111111111111111111111111')

await updateCollectionV1(umi, {
  collection: collectionAddress,
  newName: 'my-nft',
  newUri: 'https://exmaple.com/new-uri',
}).sendAndConfirm(umi)

Updating a Collection Plugin

If you want to change the behaviour of a plugin that is attached to a Core Collection you may want to use the updateCollectionPlugin instruction.

Updating a Collection Plugin

import { publicKey } from '@metaplex-foundation/umi'
import {
  updateCollectionPluginV1,
  createPlugin,
  ruleSet,
} from '@metaplex-foundation/mpl-core'

const collectionAddress = publicKey('1111111111111111111111111111111')

const newCreator = publicKey('5555555555555555555555555555555')

await updateCollectionPluginV1(umi, {
  collection: collectionAddress,
  plugin: createPlugin({
    type: 'Royalties',
    data: {
      basisPoints: 400,
      creators: [{ address: newCreator, percentage: 100 }],
      ruleSet: ruleSet('None'),
    },
  }),
}).sendAndConfirm(umi)
Previous
Burning Assets