Lesson 14: Error deploying RandomIpfsNft to Testnet #2854
Replies: 4 comments 3 replies
-
// Random IPFS NFT
const randomIpfsNft = await ethers.getContract("RandomIpfsNft", deployer)
const mintFee = await randomIpfsNft.getMintFee()
// Need to listen for response
await new Promise(async (resolve, reject) => {
setTimeout(resolve, 300000) // 5 minute timeout time
// setup listener for our event
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)}`
) const randomIpfsNftMintTx = await randomIpfsNft.requestNft({
value: mintFee.toString(),
})
const randomIpfsNftMintTxReceipt = await randomIpfsNftMintTx.wait(1) These lines should be above promise Updated code // Random IPFS NFT
const randomIpfsNft = await ethers.getContract("RandomIpfsNft", deployer)
const mintFee = await randomIpfsNft.getMintFee()
const randomIpfsNftMintTx = await randomIpfsNft.requestNft({
value: mintFee.toString(),
})
const randomIpfsNftMintTxReceipt = await randomIpfsNftMintTx.wait(1)
// Need to listen for response
await new Promise(async (resolve, reject) => {
setTimeout(resolve, 300000) // 5 minute timeout time
// setup listener for our event
randomIpfsNft.once("NftMinted", async () => {
resolve()
})
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)}`
) |
Beta Was this translation helpful? Give feedback.
-
Still getting "ERC721: invalid token ID" after deploying. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
@JR-Vickers @santi-nihany Make sure your VRF subscribtion is funded with enough LINK. If there isn't enough it will be pending until the promise timesout and the mint will fail. |
Beta Was this translation helpful? Give feedback.
-
I had the same error. It was due to the fact that I have added the wrong Consumer at https://vrf.chain.link/. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm at the end of the lesson where we deploy the contract to Rinkeby/Goerli. The basic NFT and the Dynamic SVG NFT both deploy just fine, but I get an error when I get to the random SVG NFT:
My code can be found here.
Beta Was this translation helpful? Give feedback.
All reactions