Skip to content

dtthaison/nft-sample

Repository files navigation

NFT Sample

ERC721 sample project using Hardhat - Ethereum development environment - to understand how to:

Setup project with hardhat

  1. Install hardhat npm install --save-dev hardhat
  2. Install packages: npm install
  3. Install shorthand: npm i -g hardhat-shorthand after install can run hardhat command by hh instead of npx hardhat

Compile, deploy and verify smart contract

Get native coin for gas purpose at:

Networks supported:

  • ropsten
  • goerli
  • matic
  • matic_testnet
  • bsc
  • bsc_testnet

env vars:

key description
PRIVATE_KEY private key of deployer's account, ignore if when deploy on hardhat local. The account should have native coin to run deploy contract scripts
ROPSTEN_URL, RINKEBY_URL, GOERLI_URL network gateway, get at: infura, moralis
ETHERSCAN_API_KEY explorer api key, get at: etherscan, bscscan, polygonscan...
DEPLOY_TOKEN_NAME token name
DEPLOY_TOKEN_SYMBOL token symbol

Deploy:

  1. Set env vars: DEPLOY_TOKEN_NAME, DEPLOY_TOKEN_SYMBOL
  2. Deploy contract: hh run scripts/001_deploy.js --network <network>
  3. Verify contract: hh verify <contract_address> <token_name> <token_symbol> --contract contracts/NFTSample.sol:NFTSample --network bsc_testnet

Sample contracts

Mint token by rinkeby explorer and view on opensea testnet

  1. Access Write Contract tab of sample contract on rinkeby explorer
  2. Click Connect to Web3 and select an account has some native coins on metamask chrome extension
  3. Click safeMint then fill to (address) to want to mint and token uri (string) - token uri sample
  4. CLick Write button
  5. Click Confirm button on metamask popup to sign and send tx(transaction) on rinkeby testnet
  6. Click View your transaction to see your mint token tx details. You can find your tokenID minted at Tokens Transferred: row
  7. View minted token on opensea: https://testnets.opensea.io/assets/<contract_address>/<tokenID>

Testing

hh test

About

NFT sample contract with hardhat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published