-
I'm currently trying to deploy randomipfsnft with a command:
When I run it I get this error:
I was unable to solve it by myself. I know that it's something with the VRFCoordinatorV2Mock, but I think it's deploying correctly, so I don't know why 02-deploy doesn't work. Here is my 02-deploy-random-ipfs-nft.js: const { ethers, network, deployments } = require('hardhat')
const { networkConfig, developmentChains } = require('../helper-hardhat-config')
const { verify } = require('../utils/verify')
const {
storeImages,
storeTokenUriMetadata,
} = require('../utils/uploadToPinata')
const imagesLocation = './images/randomNft'
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
// get ipfs hashes of our images
// with our own IPFS node
// or use Pinata
// or use nft storage (that uses filecoin)
if (process.env.UPLOAD_TO_PINATA == 'true') {
tokenUris = await handleTokenUris()
}
let vrfCoordinatorV2Address, subscriptionId, vrfCoordinatorV2Mock
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract(
'VRFCoordinatorV2Mock',
)
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait()
subscriptionId = transactionReceipt.events[0].args.subId
subscriptionId = txReceipt.events[0].args.subId
} else {
vrfCoordinatorV2Address = networkConfig[chainId].vrfCoordinatorV2
subscriptionId = networkConfig[chainId].subscriptionId
}
log('--------------------')
await storeImages(imagesLocation)
// const args = [
// vrfCoordinatorV2Address,
// subscriptionId,
// networkConfig[chainId].gasLane,
// networkConfig[chainId].callbackGasLimit,
// networkConfig[chainId].mintFee,
// ]
}
async function handleTokenUris() {
tokenUris = []
// store the Image in IPFS
// store the metadata in IPFS
return tokenUris
}
module.exports.tags = ['all', 'randomipfs', 'main'] Please let me know if repo is necessary. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
You are using ethers v6, and in v6 the address member is replaced by target, and the below line is giving error. vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address I recommend you to remove the ethers folder from node modules and do yarn add --dev ethers@5.7.2 With ethers v5.7.2, everything shown in the video will remain as it is, but there are certain changes done in v6. |
Beta Was this translation helpful? Give feedback.
I managed to solve the issue. I had to change few things for anyone with the same issue. Firstly, to prevent all the compatibility issues I just downloaded the latest versions with:
Then after searching for any informations about vrfCoordinatorV2Mock.address in the new ethers, I found out that the name has changed to
But then, I got another error with subscriptionId being undefined, resulting in "no emitted events" issue. I found a discussion from lesson 9 error and solved it by writing;