General
Print Editions with MPL Core
Introduction
What is an Edition?
An Edition is a copy of the same "Master Edition". To understand the concept it can be helpful to think of physical Paintings: The Master Edition is the initial Painting, the Editions, also known as prints, are copies of that painting.
Editions with Core
MPL Core Edition support was added close after to the mainnet release. Different to Token Metadata Editions the Edition Numbers and Supply are not enforced, but informational.
To achieve the Edition concept in Core two Plugins are used: Master Edition in the Collection and Edition in the Asset, which are the prints. The hierarchy looks like this:
Create Editions using Candy Machine
The easiest method to create and sell Edition is by leveraging Core Candy Machine.
The following Code creates a Master Edition Collection and the Candy Machine that prints the Editions for you.
Create a Candy Machine with Edition Guard and Master Edition Collection
First all the required functions are imported and Umi set up with your RPC and Wallet:
import {
create,
mplCandyMachine,
} from "@metaplex-foundation/mpl-core-candy-machine";
import {
createCollectionV1,
pluginAuthorityPair,
ruleSet
} from "@metaplex-foundation/mpl-core";
import crypto from "crypto";
import {
generateSigner,
keypairIdentity,
} from "@metaplex-foundation/umi";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
// Use the RPC endpoint of your choice.
const umi = createUmi("http://127.0.0.1:8899").use(mplCandyMachine());
// use your keypair or Wallet Adapter here.
const keypair = generateSigner(umi);
umi.use(keypairIdentity(keypair));
After this setup we can create the Collection with Master Edition Plugin. The maxSupply
field determines how many Editions you want to print. The name
and uri
fields in the Plugin can be used in addition to the Collection Name and uri.
For ease of use we also add the Royalty Plugin.
const collectionSigner = generateSigner(umi);
await createCollectionV1(umi, {
collection: collectionSigner,
name: "Master Edition",
uri: "https://example.com/master-edition.json",
plugins: [
pluginAuthorityPair({
type: "MasterEdition",
data: {
maxSupply: 100,
name: null,
uri: null,
},
}),
pluginAuthorityPair({
type: "Royalties",
data: {
basisPoints: 500,
creators: [{ address: umi.identity.publicKey, percentage: 100 }],
ruleSet: ruleSet("None"),
},
}),
],
}).sendAndConfirm(umi);
After the creation of the Collection we can create the candy machine using hiddenSettings
and the edition
guard.
hiddenSettings
are used to assign the same, or similar, Name and Metadata to all Assets minted. You can use a$ID$
variable that will be replaced by the index of the minted Asset on mint.- The
edition
Guard is used to add the Edition Plugin to the Assets. The Edition number is increasing for each minted Asset, starting with the number ineditionStartOffset
.
// The Name and off chain Metadata of your Editions
const editionData = {
name: "Edition Name",
uri: "https://example.com/edition-asset.json",
};
// This creates a hash that editions do not
// use but the Candy Machine requires
const string = JSON.stringify(editionData);
const hash = crypto.createHash("sha256").update(string).digest();
const candyMachine = generateSigner(umi);
const createIx = await create(umi, {
candyMachine,
collection: collectionSigner.publicKey,
collectionUpdateAuthority: umi.identity,
itemsAvailable: 100,
hiddenSettings: {
name: editionData.name,
uri: editionData.uri,
hash,
},
guards: {
edition: { editionStartOffset: 0 },
// ... additional Guards
},
})
await createIx.sendAndConfirm(umi);
That's it!
Now users can mint editions from your candy machine.
Create Editions without Core Candy Machine
We strongly recommend to use Core Candy Machine for MPL Core Editions. Candy Machine handles the creation and also the correct numbering of the editions for you.
To create an Edition without Core Candy Machine you would:
- Create a Collection using the Master Edition Plugin
Create a MPL Core Collection with Master Edition 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: 'MasterEdition',
data: {
maxSupply: 100,
name: 'My Master Edition',
uri: 'https://example.com/my-master-edition',
},
}),
],
}).sendAndConfirm(umi)
- Create Assets with the Edition Plugin. Remember to increase the number in the plugin.
Creating an MPL Core Asset with the Edition Plugin
import { publicKey } from '@metaplex-foundation/umi'
import {
createV1,
pluginAuthorityPair
} from '@metaplex-foundation/mpl-core'
const asset = generateSigner(umi)
const result = createV1(umi, {
asset: asset,
name: 'My Nft',
uri: 'https://example.com/my-nft',
plugins: [
pluginAuthorityPair({
type: 'Edition',
data: { number: 1 },
}),
],
}).sendAndConfirm(umi)