The Edition NFT template generates a contract that can mint edition-based NFTs.
In this model, a contract can define multiple NFT editions. All NFTs in an edition share the same metadata; only their serial numbers are different.
The template requires the following inputs when generating a contract:
contractName
- the name of the contract.fields
- the metadata fields to include on the contract.views
- the metadata views to include on the contract.saveAdminResourceToContractAccount
- a special boolean flag that indicates whether theAdmin
resource should be saved to the contract account at mint time. If false, the deployer must pass to the contract initializer anAuthAccount
that will receive theAdmin
resource.
This template has an accompanying TypeScript wrapper in @freshmint/core
implemented in EditionNFTContract.ts
.
The wrapper contains functions to generate a cotnract, deploy a contract, create editions and mint NFTs.
See the Edition NFTs section in the Node.js documentation for more documentation and examples.
Before minting NFTs, you must create an edition and add it to the contract. This acts a blueprint for all NFTs that will exist in the edition.
Editions are created in batches. Use the create_editions.cdc
transaction to create one or more editions.
This transaction is generated to accept one argument for each metadata field defined in your schema.
After creating an edition, use the mint.cdc
transaction to
mint NFTs into an edition.
Because you added the metadata when creating the edition, this transaction only needs to know the edition ID and number of NFTs to mint.
Tests are implemented in TypeScript in EditionNFTContract.test.ts
and use @onflow/flow-js-testing
to run on the Flow Emulator.