mint.ts 715 B

123456789101112131415161718192021
  1. import { task } from "hardhat/config"
  2. /**
  3. Example:
  4. npx hardhat erc721-mint \
  5. --contract 0x77337983A7D1699FaF51a5f43b9907fB7B614097 \
  6. --recipient 0x73faDd7E476a9Bc2dA6D1512A528366A3E50c3cF \
  7. --network sepolia
  8. */
  9. task("erc721-mint", "Mint token for BasicERC721 Smart Contract")
  10. .addParam<string>("contract", "BasicERC721 Smart Contract Address")
  11. .addParam<string>("recipient", "NFT Token Recipient")
  12. .setAction(async (taskArgs, { ethers }) => {
  13. const contract = await ethers.getContractAt("BasicERC721", taskArgs.contract)
  14. const mintTrx = await contract.safeMint(taskArgs.recipient)
  15. console.log(`Transaction Hash: ${mintTrx.hash}`)
  16. await mintTrx.wait(2)
  17. console.log("Transaction confirmed")
  18. })