ERC721 sample project using Hardhat - Ethereum development environment - to understand how to:
- Write ERC721 solidity smart contract with openzeppelin library
- Deploy a contract on chain by Hardhat
- Verify contract code on explorer
- Test a smart contract
- Interact a smart contract by explorer and metamask chrome extension
- View a minted NFT token on opensea
- Install hardhat
npm install --save-dev hardhat
- Install packages:
npm install
- Install shorthand:
npm i -g hardhat-shorthand
after install can run hardhat command byhh
instead ofnpx hardhat
Get native coin for gas purpose at:
- rinkeby faucet
- ropsten faucet
- goerli faucet
- kovan faucet or chain.link
- polygon faucet
- bsc faucet
- one faucet
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 |
- Set env vars:
DEPLOY_TOKEN_NAME
,DEPLOY_TOKEN_SYMBOL
- Deploy contract:
hh run scripts/001_deploy.js --network <network>
- Verify contract:
hh verify <contract_address> <token_name> <token_symbol> --contract contracts/NFTSample.sol:NFTSample --network bsc_testnet
- Access
Write Contract
tab of sample contract on rinkeby explorer - Click
Connect to Web3
and select an account has some native coins on metamask chrome extension - Click
safeMint
then fillto (address)
to want to mint and tokenuri (string)
- token uri sample - CLick
Write
button - Click
Confirm
button on metamask popup to sign and send tx(transaction) on rinkeby testnet - Click
View your transaction
to see your mint token tx details. You can find yourtokenID
minted atTokens Transferred:
row - View minted token on opensea:
https://testnets.opensea.io/assets/<contract_address>/<tokenID>
hh test