mint-nft.js
file and add the following lines of code:mint-nft.js
file:mint-nft.js
and see your ABI printed to the console navigate to your terminal and runmintNFT
smart contract function takes in a tokenURI parameter that should resolve to a JSON document describing the NFT's metadata— which is really what brings the NFT to life, allowing it to have configurable properties, such as a name, description, image, and other attributes.Interplanetary File System (IPFS) is a decentralized protocol and peer-to-peer network for storing and sharing data in a distributed file system.
0x81c587EB0fE773404c42c1d2666b5f557C470eED.
mint-nft.js
file, add the following:.env
filenonce
(will explain below)..env
file —if you completed part 1 of the tutorial, our .env
file should now look like this:mintNFT(tokenData)
and create our transaction by doing the following:PRIVATE_KEY
and PUBLIC_KEY
from the .env file.nonce
. The nonce specification is used to keep track of the number of transactions sent from your address— which we need for security purposes and to prevent replay attacks. To get the number of transactions sent from your address, we use getTransactionCount.transaction
with the following info:'from': PUBLIC_KEY
: The origin of our transaction is our public address'to': contractAddress
: The contract we wish to interact with and send the transaction'nonce': nonce
: The account nonce with the number of transactions sent from our address'gas': estimatedGas
: The estimated gas needed to complete the transaction'maxPriorityFeePerGas': estimatedFee
: The estimated fee to bid per gas.'data': nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()
: The computation we wish to perform in this transaction— which in this case is minting an NFTmint-nft.js
file should look like this now:x
number of NFTs in a single command, we can use a simple for loop
running from 0
to x-1
within a function wrapping the minting process. This would allow us to effectively mint x
NFTs every time the wrapper mint function is called.web3.eth.sendSignedTransaction
will give us the transaction hash, which we can use to make sure our transaction was mined and didn't get dropped by the network. You'll notice in the transaction signing section, we've added some error checking so we know if our transaction successfully went through.mintNFT
and run node scripts/mint-nft.js
mintNFT
https://gateway.pinata.cloud/ipfs/<metadata-hash-code>node scripts/mint-nft.js
to deploy your NFT. After a couple of seconds, you should see a response like this in your terminal :mint-nft.js
you can mint as many NFT's as your heart (and wallet) desires! Just be sure to pass in a new tokenURI
describing the NFT's metadata --otherwise, you'll just end up making a bunch of identical ones with different IDs.