EVM NFT Creation
A developers guide to creating NFTs on EVM blockchains which are compatible with GhostMarket
Last updated
A developers guide to creating NFTs on EVM blockchains which are compatible with GhostMarket
Last updated
This page provides a step-by-step guide for deploying GhostMarket compatible NFTs on supported EVM compatible blockchains (Avalanche, BSC, Polygon, Ethereum, Base).
The NFT creation process requires interaction with the blockchain. For retrieving existing NFT metadata, see data, which uses the GhostMarket APIs.
The snippets used in this guide are javascript and the contract addresses used are for the BSC contracts. For other EVM chains, please adjust using the appropriate contract addresses specified in the page.
The code snippets also assume a environment.
See our for full details and requirements of GhostMarket NFT metadata.
The NFT creation process on all blockchains broadly consists of the following steps.
Prepare Off-Chain Media and persist it
Assemble On/Off-Chain Metadata
Persist Off-Chain metadata
Build a transaction
Sign the transaction
Broadcast to the blockchain
This guide will use Piñata to upload and pin your images to IPFS.
Be sure to note the IPFS hash of the uploaded metadata, you will need it in the following step.
Install the web3 javascript module
Import the Web3 module and set up Web3
This sample assumes node.js, for browser and metamask development, adapt the provider and wallet connection appropriately.
After downloading the contract ABI, be sure to edit the file so it contains only the value of the "result" object
e.g. [{ "anonymous" true ... }]
GhostMarket supports both ERC721 and ERC1155 NFT token standards on EVM platforms. The metadata setup is identical, however the contract parameters differ. We highlight these differences below.
GhostMarket EVM NFT contracts provide the option to store metadata on, or off chain as a JSON string. However, because of the high cost of storing Metadata on-chain, we will be storing the metadata off-chain.
Build the metadata:
Since this example uses Off-chain persistence of the NFT metadata. Upload the metadata to IPFS using the same process as persisting the media and again.
Be sure to note the IPFS hash, we will use this below.
The royalties and lockedContent are parameters to the contract method, so these are prepared first.
This code snippet constructs the contract & method objects for both the ERC721 & ERC1155 contracts. Use the contract which corresponds to your use case.
Not needed here. In this sample, signing is done as part of the Web3 Broadcast.
That's it, you've created and persisted a GhostMarket compatible NFT.
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.
The preferred decentralized platform for persisting image/media data for your NFT is .
Set up a Piñata account and get started .
You can either manually upload you metadata, noting the IPFS hash, or dive into the to interact with Piñata programatically.
Download and save the contact ABI using the relevant explorer (e.g. ) and store it locally. Node.js allows us to "require" it directly into the ABI objects.