1_23

const fs = require("fs") // file system let { networkConfig } = require('../helper-hardhat-config') // 异步函数 // async await // async function abc(){} // abc() return promise // await abd() module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = await getChainId() log("---------------------------------------") const SVGNFT = await deploy("SVGNFT", { from: deployer, log: true }) log(`You have deployed an NFT contract to ${SVGNFT.address}`) let filepath = "./img/circle.svg" let svg = fs.readFileSync(filepath, { encoding: "utf8" }) const svgNFTContract = await ethers.getContractFactory("SVGNFT") //get info of contract // hardhat runtime environment const accounts = await hre.ethers.getSigners() const signer = accounts[0] const svgNFT = new ethers.Contract(SVGNFT.address, svgNFTContract.interface, signer) const networkName = networkConfig[chainId]['name'] log(`Verify with \n npx hardhat verify --network ${networkName} ${svgNFT.address}`) let transactionResponse = await svgNFT.create(svg) let receipt = await transactionResponse.wait(1) log(`You have made an NFT!`) log(`You can view the tokenURI here ${await svgNFT.tokenURI(0)}`) log(`${receipt}`) }
 
typescript