I am doing an Nft Marketplace contract and was trying to run npx hardhat run scripts/mint-and-list.js --network goerli
to mint the NFT that was already being deployed on IPFS.
However, I have a pending transaction whereby it cannot pass through the code mintNftTx.wait(1)
to get the transaction receipt. The transaction was stuck for like hours and even I tried to run the code again, I still faced the same problem.
** I have 0.4771 GoerliETH in my wallet.
Below is the output of my console after running npx hardhat run scripts/mint-and-list.js --network goerli
Gas Price: 0.000000040682008677 eth
basicnft address: 0x75a99cE9D0E55448d5842947342FE0E39af9C9e0
nftmarketplace address: 0xb8d1afcAC26Ec587472962c5676758ba3348007C
49577ddeb35bed9684a4b708","v":46,"creates":null,"chainId":5}
Minted but getting transaction receipt...
Below is the mint-and-list.js file
const { ethers } = require("hardhat")
async function main() {
const alchemy = new ethers.providers.JsonRpcProvider(
process.env.GOERLI_RPC_URL
)
const gasPrice = await alchemy.getGasPrice()
console.log("Gas Price:", ethers.utils.formatEther(gasPrice), "eth")
const PRICE = ethers.utils.parseEther("0.1")
const BasicNft = await ethers.getContract("BasicNft") //
// const BasicNft = BasicNftContract.connect(deployer)
const NftMarketplace = await ethers.getContract("NftMarketplace") //
console.log(`basicnft address: ${BasicNft.address}`)
console.log(`nftmarketplace address: ${NftMarketplace.address}`)
// const NftMarketplace = NftMarketplaceContract.connect(deployer)
console.log("Minting Nft...")
const mintNftTx = await BasicNft.mintNFT() //
console.log(`mintNftTx:${JSON.stringify(mintNftTx)}`)
console.log("Minted but getting transaction receipt...")
const mintNftReceipt = await mintNftTx.wait(1) //
const tokenId = mintNftReceipt.events[0].args.tokenId.toString()
console.log(`Nft was minted with tokenId of ${tokenId}`)
console.log("Approving NftMarketplace to operate the token...")
const approveTx = await BasicNft.approve(NftMarketplace.address, tokenId)
await approveTx.wait(1)
console.log("NftMarketplace was approved!")
console.log("Listing Nft on the marketplace...")
const listNftTx = await NftMarketplace.listItem(
BasicNft.address,
tokenId,
PRICE
)
await listNftTx.wait(1)
console.log("Nft was listed!")
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})