Comment on page
How to Create and Deploy An NFT Using Remix and Open Zeppelin
In this article, we will guide you through the procedure of creating your first XRC-721 (NFT) contract on Remix IDE with Open Zeppelin, deploying NFTs image/metadata on IPFS, and deploying smart contracts on the XDC Network.
The XDC Network ($XDC) is an enterprise-ready, open-source, hybrid blockchain protocol specializing in tokenization for real-world decentralized finance.
XDCPay is a bridge that allows you to visit the distributed web of tomorrow in your browser today. It allows you to run XDC dApps right in your browser without running an XDC node. While doing transactions on the blockchain network, it uses computing power in the form of gas fees. To pay the gas fees, you will need a wallet that handles your assets and that's where XDCPay comes in.
NFTs and digital collectibles are growing in popularity as the Web3 space continues to make significant advancements in the blockchain arena. The enormous popularity of NFTs like Cryptokitties and Bored APE pushed investors to purchase ERC721-compatible digital collectibles.
Tools like the OpenZeppelin Wizard offer developers click-and-write functionality to create composable and secure smart contracts in no time.
XDC Remix is a web browser-based integrated development environment that allows users to write, compile, deploy, and run Solidity smart contracts on the XDC Network.
The InterPlanetary File System is a protocol, hypermedia, and file sharing peer-to-peer network for storing and sharing data in a distributed file system. IPFS uses content-addressing to uniquely identify each file in a global namespace connecting IPFS hosts.
- You'll want your tokens to be Mintable and have Enumerable and URI Storage as the features. Name your token as you'd like and enter the desired symbol. You can add more features as you need them.
Select all code and copy it.
In order to get started deploying new contracts on XDC Mainnet and/or Apothem, you'll need to have an XDCPay wallet to sign your transactions, and to you your store XDC tokens.
- Open the Chrome extension after it has been successfully installed.
- Agree to the Terms of Service.
- Create a new XDCPay wallet by setting up a strong password or use an existing Seed Phrase
12 or 24-Word Mnemonic Phraseto recover your existing wallet here.
- Keep the seed phrase safe. 🚨 Do not share the seed phrase with anyone or you can risk losing your assets and/or the ownership of your smart contracts! 🚨
- Verify recovery phrase
- Your XDCPay wallet has been successfully created
Initially, your account will be empty, and you'll need XDC tokens to initiate blockchain transactions. You'll use a faucet to fill our wallet with test XDC tokens for this. These tokens hold no value. They are simply used to test your contracts on the testnet in order to avoid losing your real money.
- First, make a copy of your wallet address. Your wallet address would look something like
xdc057ac7de8ad6f21c7bb0dcc6a389ff9161b3b943. These account address are interchangeable with the Ethereum network. You can access these accounts on the Ethereum network by simply changing the initial
- If your request is approved, you will be credited with the XDC in your wallet.
- If you can't see the XDC in your wallet, make sure you're connected to the XDC Apothem Testnet or the XDC Mainnet.
- If you are currently connected to the XDC Mainnet, switch to the XDC Apothem Testnet.
In Remix, go to deploy and select Injected Web3 as the Environment. It will connect to your network automatically, and you will receive the address of your XDCPay wallet along with the balance. Select your smart contract in the Contract tab and click on Deploy.
You will see an XDCPay popup asking you to pay the fees. Click Confirm and wait 10 seconds as it adds the deployed contract in Remix!
To pull in off-chain metadata for XRC721 tokens, the contract will need to return a URI pointing to the hosted metadata. To find this URI, XDsea and other popular marketplaces will use the tokenURI method contained in the ERC721Uristorage standard.
"name": "Mogi TheHurt",
"description": "Mogali is a fictional character",
Copy the metadata structure before pasting it in json online editor and editing the description as you'd like it to read. According to the Block Explorer APIs, the NFT Metadata should be stored in a .json file and structured as shown above.
- Now that you have a brief understanding of what will be contained in your NFT metadata, you'll learn how to create it and store it on the Inter Planetary File System (IPFS).
nft pinata 13
Save the JSON file as metadata.json and upload it to Pinata. Copy the cid of metadata.json and a prefix of
nft pinata 14
Next, head on over to Remix. It's important to know that orange methods are methods that actually write on the blockchain while blue methods are methods learning from the blockchain.
Click on the safeMint method dropdown icon and paste your address and the following string into the uri field:
Clicking on transact will create a XDCPay popup prompting you to pay the gas fees. Click on “submit” and go on minting your first NFT!
nft mint 15
- Enter your address in the balanceOf button and enter your address. Run it — it should show you have 1 NFT.
- Do the same with the tokenUri method, inserting “0” as the id argument — it should display your tokenURI.
- Great! You just minted your first NFT! 🎉 Now it’s time to move to Block Explorer to check if the metadata is read.
Now go to the Block Explorer and paste your NFT contract in search box.
nft verify 16
To verify contract we need source code, so go to XDC Remix and add FLATTENER Plugin.
nft flattner plugin 17
FLATTENER created a file, copy all code from this file.
nft flattner 18
Paste code in big box.
nft verify submit 19
nft verify success 20
🎉 We succussfully verified our contract.
Now we are viewing our minted NFT in Block Explorer.
Congratulations! You have successfully created, modified, and deployed your first NFT smart contract, minted your first NFT, and published your image on IPFS!
Thanks for reading.