Code Monkey home page Code Monkey logo

nft-tutorial's Introduction

NFT-Tutorial

Deploy an NFT project on Ethereum

This Tutorial assumes you have installed nodejs and npm

Start Hardhat Project

Create a new directory and install hardhat

mkdir NFTutorial
cd NFTutorial
npm install --save-dev hardhat

We recommend reviewing the hardhat documentation and tutorial.

Next, start a hardhat project

npx hardhat

Select "Create a sample hardhat project". You can say yes to everything.

Now you have a hardhat project ready to go!

Write NFT Contract Code

First, install Open Zeppelin contracts

npm install @openzeppelin/contracts

You can delete Greeter.sol.

In the contracts folder, create a new solidity file called NFTee.sol and add the code from the sample NFTee.sol contract in this repo.

Try customizing the solidity code with the name of your NFT.

Compile the contract

To compile the contract, just go

npx hardhat compile

Configuring Deployment

We are going to deploy the NFT contract on the Rinkeby Testnet.

First, make sure you get some rinkeby testnet Ether. You can get some here: https://faucet.rinkeby.io/

Next, set up a rinkeby provider. You can get one from alchemyapi.io It should look like: https://eth-rinkeby.alchemyapi.io/v2/......

Next, configure module.exports in hardhat.config.js

defaultNetwork: "rinkeby",
networks: {
  hardhat: {
  },
  rinkeby: {
    url: "",
    accounts: [""]
  }
},
solidity: {
  version: "0.8.0"
},
paths: {
  sources: "./contracts",
  tests: "./test",
  cache: "./cache",
  artifacts: "./artifacts"
},
mocha: {
  timeout: 20000
}

You must add your own account private key and provider url to the config

Deploy Contract

First, you must write a deploy script. Go to deploy.js in the scripts folder.

Inside function main(), add the code to deploy your contract similar to deploy.js in this repo

async function main() {
  // We get the contract to deploy
  const GameItem = await ethers.getContractFactory("GameItem");
  const gameItem = await GameItem.deploy();
}

If everything is configured properly, you can now deploy. In your terminal, run the deploy command

npx hardhat run --network rinkeby scripts/deploy.js

To see if your contract has been deployed, check your account in etherscan.io. A new transaction should appear, and the transaction should deploy a new contract!

Verify on Etherscan

To verify your contract on etherscan, you must first flatten your entire contract.

npx hardhat flatten

Take the code, and clean it up, then verify it on etherscan.

Play with your new NFT contract

  • Mint token
  • Transfer Token

View your NFT on OpenSea

  • get a metadata link
  • Upload to Opensea
  • view on opensea

nft-tutorial's People

Contributors

vgotcheva avatar antron3000 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.