GhostMarket
  • Welcome
    • Quick Navigation
  • User Guides
    • Getting Started
      • NFTs Explained
      • Supported Blockchains
      • Supported Wallets
      • Connecting Wallets
      • Editing User Profiles
      • Editing Collection Profiles
      • Viewing Owned NFTs
      • Profile Verification
      • Collection Verification
      • Enabling Email Notifications
      • Platform Fees
    • Creating & Managing NFTs
      • Creating NFTs
      • Burning NFTs
      • Transferring NFTs
    • Buying & Selling NFTs
      • Browsing NFTs
      • Buying NFTs
      • Selling NFTs
      • Viewing Site Activity
      • Listing Types
    • Platform Features & Tools
      • Bulk Buying
      • Full DEX Swap Support
      • EVM Swap + Buy
      • Favorites
      • Gas Tracker
      • Instant Sell
      • NFT Explorer
      • Self-Minting Platform
      • Sweep Mode
    • GhostMarket Incentives
      • GFUND
      • Staking Incentives
      • Trading Incentives
  • Developer Guides
    • Accessing NFT Data
    • API
    • Blockchain Short Names
    • Configuring Royalties
    • Metadata Specification
    • Minting Tokens
      • EVM NFT Creation
      • Neo N3 NFT Creation
      • Phantasma NFT Creation
    • Neo N3 NFT Contract Template
    • Refreshing Metadata
    • SDK
    • Storing Metadata - IPFS
  • Smart Contracts
    • Trading contracts
    • NFT contracts
    • Fungible Token contracts
    • Royalties contracts
    • Incentives contracts
    • Staking contracts
    • Vesting contract
    • Liquidity Provider Staking contracts
    • Proxy Contracts
    • Wrapper Contracts
    • Audits
  • GhostMarket Token (GM)
  • Roadmap
  • Media Kit
  • Social Media Links
    • 💬 Discord
    • 💬 Telegram
    • 📣 X (Twitter)
    • 📷 Instagram
    • 📖 Medium
    • 🪙CoinMarketCap
    • 🪙CoinGecko
Powered by GitBook
On this page
  • Introduction
  • NFT Creation
  • 1. Prepare Off-Chain Metadata
  • 2. Assemble On-Chain Metadata
  • 3. Build the transaction script
  • 3. Construct & Sign the transaction
  • 4. Broadcast to the blockchain
  1. Developer Guides
  2. Minting Tokens

Phantasma NFT Creation

A developers guide to creating Phantasma NFTs compatible with GhostMarket

PreviousNeo N3 NFT CreationNextNeo N3 NFT Contract Template

Last updated 1 year ago

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 data, which uses the GhostMarket APIs.

The code snippets also assume a environment.

See our for full details and requirements of GhostMarket NFT metadata.

NFT Creation

The NFT creation process on all blockchains broadly consists of the following steps.

  1. Prepare Off-Chain Metadata and persist it.

  2. Assemble On-Chain Metadata and build a transaction.

  3. Sign the transaction.

  4. Broadcast to the blockchain.

1. Prepare Off-Chain Metadata

The preferred decentralised platform for persisting image/media data for your NFT is .

This guide will use Pinãta to upload and pin your images to IPFS.

Set up a Pinata account and get started .

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.

Install the module

% npm install phantasma-ts

Import the library

const { phantasmaJS } = require("phantasma-ts");

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

index
name
type
descr

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

let creatorAdd = "<my Phantasma address>";

mintParamArrayGhost = [
  0, // editionID
  100, // editionMax
  1, // editionMode
  creatorAdd, // creator - address
  2000, // royalties - 20% expressed as BPS (0.01%)
  "GHOST", // mintTicker - string
  1, // numOfNfts - Mint one NFT
  "My Shiny NFT", // name
  "This NFT will be a classic", // description
  1, // type - See Metadata Reference "Genre"
  "ipfs://QmTy8w65yBXgyfG2ZBg5TrfB2hPjrDQH3RCQFJGkARStJb", // imageURL - from step 1
  "", // infoURL - not used
  "color", // attrT1
  "red", // attrV1
  "size", // attrT2
  "small", // attrV2
  "", // attrT3 - empty string if unused
  "", // attrV3 - empty string if unused
  "This is your mystery content", // lockedContent
  0, // listPrice - we can list later, not now
  "", // listPriceCurrency - not listing with mint
  0, // listLastEndDate - not listing
  "", // infusedAsset - string
  0, // infusedAmount - number
  true, // hasLocked - true
];

3. Build the transaction script

//Create a new Script Builder Object
let sb = new phantasmaJS.ScriptBuilder();

// Assemble the Script
sb.callContract("gas", "AllowGas", [
  "fromAddress",
  sb.nullAddress,
  "100000",
  "900",
])
  .callContract("ghost", "mintToken", mintParamArrayGhost)
  .callContract("gas", "SpendGas", ["fromAddress"])
  .endScript();

3. Construct & Sign the transaction

// stringify the script
let script = sb.str;
let privateKey = "Your Private Key";

//build an expiration date for the transaction of 5 minutes
let expiration = 5; //Expiration time, in minutes
let getTime = new Date();
let expDate = new Date(getTime() + expiration * 60000);

//Creating New Transaction Object
let transaction = new phantasmaJS.Transaction(
  "mainnet", //Nexus Name
  "main", //Chain
  script, //In string format
  date, //Expiration Date
  ""
); //Extra Info to attach to Transaction in Serialized Hex - not needed

//Sign's Transaction with Private Key
await transaction.sign(privateKey);

4. Broadcast to the blockchain

Finally, broadcast the transaction

//Send Transaction
let txHash = await RPC.sendRawTransaction(transaction.toString(true));

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.

You can either manually upload you metadata, noting the IPFS hash, or dive into the to interract with Pinata programatically.

We will use the module to work with the Phantasma blockchain.

Accessing NFT
node.js
Metadata Reference
IPFS
here
Pinata js-sdk
phantasma-ts npm