Phantasma NFT Creation
A developers guide to creating Phantasma NFTs compatible with GhostMarket
Introduction
This page provides step-by-step instructions for deploying GhostMarket compatible NFTs on the Phantasma blockchain.
The NFT creation process requires interaction with the blockchain. For retrieving existing NFT metadata, see Accessing NFT data, which uses the GhostMarket APIs.
The code snippets also assume a node.js environment.
See our Metadata Reference for full details and requirements of GhostMarket NFT metadata.
NFT Creation
The NFT creation process on all blockchains broadly consists of the following steps.
Prepare Off-Chain Metadata and persist it.
Assemble On-Chain Metadata and build a transaction.
Sign the transaction.
Broadcast to the blockchain.
1. Prepare Off-Chain Metadata
The preferred decentralised platform for persisting image/media data for your NFT is IPFS.
This guide will use Pinãta to upload and pin your images to IPFS.
Set up a Pinata account and get started here.
You can either manually upload you metadata, noting the IPFS hash, or dive into the Pinata js-sdk to interract with Pinata programatically.
Note the IPFS hash of the uploaded metadata, you will need it in the next step.
2. Assemble On-Chain Metadata
Ghostmarket Phantasma NFT contract stores all metadata on-chain, so you must assemble it into a Phantasma transaction script.
We will use the phantasma-ts npm module to work with the Phantasma blockchain.
Install the module
Import the library
The Minting Data is sent to the contract as an array. The following table specifies the contents of the array.
All elements must be provided.
Phantasma "ghost" mint contract parameters
0
editionId
number
0 for new series // != 0 for existing series
1
editionMax
number
Maximum number possible
2
editionMode
number
1 = duplicated, 2 = unique // only allow duplicate for now
3
creator
address
Address of the creator
4
royalties
number
Royalties in BPS (0.01%) - must be integer
5
mintTicker
string
6
numOfNfts
number
number to mint
7
name
string
Short name of the NFT
8
description
string
long descriptive name of the NFT
9
type
number/integer
Genre of the NFT - see Genre reference
10
imageURL
string
URL of the image - ipfs://<hash>
11
infoURL
string
Currently unused
12
attrT1
string
First attribute Type/Key, e.g. "Color"
13
attrV1
string
First attribute Value, e.g. "Red"
14
attrT2
string
Second attribute Type/Key
15
attrV2
string
Second attribute Value
16
attrT3
string
Third attribute Type/Key
17
attrV3
string
Third attribute Value
18
lockedContent
string
String containing the encrypted content
19
listPrice
number
If listing with Mint, the listing price
20
listPriceCurrency
string
If listing with Mint, the listing currency, e.g. "KCAL"
21
listLastEndDate
timestamp
If listing with Mint, the Unix Epoch end time of listing
22
infusedAsset
string
If infusing, the asset being infused e.g. "KCAL", otherwise ""
23
infusedAmount
number
If infusing , the amount of infusedAsset to infuse, otherwise 0
24
hasLocked
bool
True if lockedContent is specified, otherwise false
Assemble the Minting Parameter Array
3. Build the transaction script
3. Construct & Sign the transaction
4. Broadcast to the blockchain
Finally, broadcast the transaction
Congratulations! you have successfully deployed a GhostMarket compatible NFT to the "ghost" contract on the Phantasma blockchain.
For clarity, all of the above snippets exclude error and promise handling for clarity. Production code should include thorough exception management and handle promises appropriately.
Last updated