Lesson 14 - Error: Transaction Failed when trying to mint an NFT #2415
-
Hello, I ran into a problem when I tried to mint an NFT on the rinkeby (on hardhat network it works) using the
//04-mint.js file
const { ethers, network } = require("hardhat")
const { developmentChains } = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts }) => {
const { deployer } = await getNamedAccounts()
//Basic NFT
const basicNft = await ethers.getContract("BasicNft", deployer)
const basicMintTx = await basicNft.mintNft()
await basicMintTx.wait(1)
console.log(`Basic NFT index 0 has tokenURI: ${await basicNft.tokenURI(0)}`)
//Random IPFS NFT
const randomIpfsNft = await ethers.getContract("RandomIpfsNft", deployer)
const mintFee = await randomIpfsNft.getMintFee()
await new Promise(async (resolve, reject) => {
setTimeout(resolve, 300000) //5 mins
randomIpfsNft.once("NftMinted", async () => resolve())
const randomIpfsNftMintTx = await randomIpfsNft.requestNft({ value: mintFee.toString() })
const randomIpfsNftMintTxReceipt = await randomIpfsNftMintTx.wait(1)
if (developmentChains.includes(network.name)) {
const requestId = randomIpfsNftMintTxReceipt.events[1].args.requestId.toString()
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
await vrfCoordinatorV2Mock.fulfillRandomWords(requestId, randomIpfsNft.address)
}
console.log(`Random IPFS NFT index 0 tokenURI: ${await randomIpfsNft.tokenURI(0)}`)
})
//Dynamic SVG NFT
const highValue = ethers.utils.parseEther("1900")
const dynamicSvgNft = await ethers.getContract("DynamicSvgNft", deployer)
const dynamicSvgNftMintTx = await dynamicSvgNft.mintNft(highValue.toString())
await dynamicSvgNftMintTx.wait(1)
console.log(`Dynamic SVG NFT index 0 has tokenURI: ${await dynamicSvgNft.tokenURI(0)}`)
}
module.exports.tags = ["all", "mint"]
Here is the project repo |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@boringslav : I have solved similar problem in another discussion : Refer to the discussion #2291 |
Beta Was this translation helpful? Give feedback.
@boringslav : I have solved similar problem in another discussion : Refer to the discussion #2291