NFT

Deploy your first NFT

Deploy your First NFT on OpenSea

Ref:

Build your first Tradable NFT from Scratch

We will accomplish the following here under:

  • Structuring your ERC721 contract

  • Structuring you off-chain metadata

  • View your items on OpenSea

  • testing out the auction flow for your items.

Step 1: ERC721 Contract preparation

ERC721 is the latest standard in non-fungible tokens. ERC-721 defines a minimum interface a smart contract must implement to allow unique tokens to be managed, owned, and traded.

// ! you need to have a special version of node.js to make their script work: See here to change to v12.18.4 of node.js supported: https://app.gitbook.com/@marcantoine-lemaire/s/programming-languages/javascript-programming

Project Git: https://github.com/ProjectOpenSea/opensea-creatures (as illustration on OpenSea NFT platform integration)

To see NFT on OpenSea testnet: https://testnets.opensea.io/assets

// Clone Git Repo:
$ git clone https://github.com/ProjectOpenSea/opensea-creatures.git

// Use a specific Version of Node.js v12.18.4
// https://app.gitbook.com/@marcantoine-lemaire/s/programming-languages/javascript-programming

// Install it
$ yarn

// Prepare variable needed to deploy SC on Rinkeby:
$ export INFURA_KEY=="<your_INFURA_project_id>"
export MNEMONIC="<metamask>"
export NETWORK="rinkeby"

// Install Truffle
// https://www.trufflesuite.com/docs/truffle/getting-started/installation
$ npm install -g truffle
// or you can install locally with
$ yarn add truffle

// Potential issue because Truffle last version 5.3.5 require node 14.0.0 min
// but here core working on node 12.18

// Install in the project Repo the truffle-hdwallet-provider
// To install the npm package
$ sudo npm install -g @truffle/hdwallet-provider

$ truffle deploy --network rinkeby
// or 
$ DEPLOY_CREATURES_SALE=1 yarn truffle deploy --network rinkeby
// Create contract deployed to 0x7096AF553Cc6C98b4198C9f4d05C0a9A0FBDA6F5
// CreatureFactory deployed to 0xe6E5Fa4DD83446F6f20bfA7202A3352C6d2C9dEe
// From account: 0x7C584e710fE6afA5369A8Bffee47Fc98D76535a5

// Check transaction on Rinkeby
https://rinkeby.etherscan.io/address/0x7c584e710fe6afa5369a8bffee47fc98d76535a5

Next, we'll want to mint new assets to our newly-deployed ERC721 contracts! We'll mint these assets into an account that we control so that we can test the OpenSea auction flow for our items.

// Minting the NFT Token
export OWNER_ADDRESS="0x7C584e710fE6afA5369A8Bffee47Fc98D76535a5"
export NFT_CONTRACT_ADDRESS="0x7096AF553Cc6C98b4198C9f4d05C0a9A0FBDA6F5"
node scripts/mint.js

export OWNER_ADDRESS="0x7C584e710fE6afA5369A8Bffee47Fc98D76535a5"
export NFT_CONTRACT_ADDRESS="0x7096AF553Cc6C98b4198C9f4d05C0a9A0FBDA6F5"
export FACTORY_CONTRACT_ADDRESS="0xe6E5Fa4DD83446F6f20bfA7202A3352C6d2C9dEe"
export NETWORK="rinkeby"
node scripts/mint.js

Then Visit a Market place to add you NFT Inside of it: https://testnets.opensea.io/get-listed/step-two

Enter there the Address ot your NFT-Contract

You can now see your NFT objects:

Then put in sales the NFT with the owner address

Buy it with another address

Look at the transaction: https://rinkeby.etherscan.io/tx/0xf526b6d9f22cc4a4723c4cea9d5ca534bc4700f325862cd5da0d82e6b42fadf1

Creature attribute are defined in https://opensea-creatures-api.herokuapp.com/api/creature/1

That URL is defined on the Creature.sol: https://github.com/ProjectOpenSea/opensea-creatures/blob/a0db5ede13ffb2d43b3ebfc2c50f99968f0d1bbb/contracts/Creature.sol#L14

At this point, we've deployed our first smart contract on the Rinkeby network and minted some new OpenSea creatures on our contract. You should be able to visit rinkeby.opensea.io and view your new creatures as NFTs inside your wallet!

Step2: Adding MetaData to the NFT Token

The default metadata for the creatures is provided by https://opensea-creatures-api.herokuapp.com/api/creature/{token_id}, which is set here. Next, you'll need create your custom metadata API.

This is where off-chain metadata comes in to play! Each token identifier in your ERC721 contract will have corresponding metadata URI that returns additional important information about the item, such as the item's name, image, description, etc

So to change your MetaData of your NFT, change the creature.sol and use another URL corresponding to your API

Step3: Embed on your Web Site a NFT

https://opensea.io/blog/announcements/announcing-embeddable-nfts/

NTF with Polkadot

Pallet named Unique that Gavin is developping: https://github.com/paritytech/substrate/tree/master/frame/uniques

Last updated