Skip to content

Latest commit

 

History

History
219 lines (120 loc) · 11.1 KB

nft.md

File metadata and controls

219 lines (120 loc) · 11.1 KB

OVERVIEW

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, deploying smart contract XDC Network.

XDC Network

The XDC Network ($XDC) is an enterprise-ready, open-source, hybrid blockchain protocol specializing in tokenization for real-world decentralized finance.

XDCPay

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 a full XDC node. While doing transactions on the blockchain network, it uses computing power known as gas cost. To pay the gas cost, you will need a wallet that handles your money and that's where XDCPay comes in.

NFTs

NFTs and digital collectibles are growing popular 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.

OpenZeppelin

Tools like the OpenZeppelin Wizard that offers developers click and write functionalities to create composable and secure smart contracts in no time

XDC Remix

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.

IPFS

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.

1. Open Zeppelin

  • First of all, let’s go to OpenZeppelin, then on the Wizard tab, click on ERC721. All NFTs are ERC721 tokens.
  • We want our tokens to be Mintable, have Enumerable and URI Storage as the features. Name your token as per your wish and also enter the desired symbol.(You can also add more features as your requirements)

nft 2

Select all code and copy the code.

nft 3

Now, Open XDC Remix . It will open the Remix IDE.

nft 4

nft 5

nft 6

nft 7

nft 8

In order to get started deploying new contracts on XDC Mainnet and/or Apothem, we need to have XDCPay wallet to sign our transactions and store XDC tokens.

  • First we have to install the chrome extension of XDCPay.

  • 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 Phrase to 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.

⚒ Adding Testnet XDC to Development Wallet

Initially, our account would be empty, and we would require some XDC tokens to initiate blockchain transactions. We would use a faucet to fill our wallet with test XDC tokens for this. These tokens are worthless in and of themselves. 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 like xdc057ac7de8ad6f21c7bb0dcc6a389ff9161b3b943. These account address are interchangeable with Ethereum network. We can access these accounts on Ethereum network by simply changing the initial xdc with 0x.

  • After that, navigate to the XDC faucet.
  • Enter your XDC account address and request for Test XDC here.

  • 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.

4.Deploy the NFT Smart Contract

On Remix, go to Deploy and select Injected Web3 as the Environment. It will get connected to you network automatically. You will get the address of your XDCPay wallet along with the balance. Select your smart contract in the Contract Tab and click on Deploy.

nft9

nft 10

It will show a XDCPay popup asking you to pay the fees. Click on Confirm and wait for 10 seconds. It will add the deployed contract in the Remix!

nft 11

Or you can manually add deployed contract by exploring MainNet Explorer , Testnet Explorer

nft 12

5. Formatting the NFT Metadata

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", "properties": [], "royalty": 0, "creator": [], "image": "https://ipfs.io/ipfs/<ypur_image_cid>", "fileType": "image/jpeg", "preview": "" }

Copy the metadata structure. Paste it in json online editor and edit the description according to your wish. According to the Block Explorer APIs, the NFT Metadata should be stored in a .json file and structured as above.

6. Creating and Uploading the Metadata on IPFS

  • Now that we have a brief understanding of what will be contained in your NFT metadata, let’s learn how to create it and store it on IPFS- Inter Planetary File System.
  • Go to Pinata, and make an account there. Verify your email and login. Now, we need to click on upload , upload your NFT image, copy cid and paste it in metadata file image section.

nft pinata 13

Save the JSON file in the name of metadata.json and upload it on Pinata. Copy the cid of metadata.json and a prefix of https://ipfs.io/ipfs/<your_metadata.json_cid>

nft pinata 14

7. Mint Your NFT

Then head on over to Remix. Orange methods are methods that actually write on the blockchain whereas 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:

https://ipfs.io/ipfs/<your_metadata.json_cid>

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.

8. verify NFT contract on Block Explorer

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.

9. View the NFT on Block Explorer

Now we are viewing our minted NFT on Block Explorer.

nft 21

nft 22

nft 23

nft 24

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.