Mumbai deployment issue prevents the demo from working on Mumbai testnet
janzheng opened this issue · comments
There's currently a bug on Mumbai where the deployed address is incorrectly output (NomicFoundation/hardhat#2162)
This is causing deploy.js
to use the wrong address for deploying the NFT, which is causing setApprovalForAll(contractAddress, true);
to be incorrect, because the NFT marketplace contract address is wrong. This is causing a problem when buying NFTs, because the market contract's address is never approved — causing lots of questions on the dev.to article.
This is happening across Infura, maticvigil, and other nodes.
Edit: the workaround here seems to get the right address: NomicFoundation/hardhat#2162 (comment)
Edit 2: The workaround deploy script works! Link: https://gist.github.com/janzheng/99813c042adb83581d0cb3b2d40d6541
Replace main()
in deploy.js
with:
async function main() {
const [deployer] = await hre.ethers.getSigners();
console.log(
"Deploying contracts with the account:",
deployer.address
);
let txHash, txReceipt
const NFTMarket = await hre.ethers.getContractFactory("NFTMarket");
const nftMarket = await NFTMarket.deploy();
await nftMarket.deployed();
txHash = nftMarket.deployTransaction.hash;
txReceipt = await ethers.provider.waitForTransaction(txHash);
let nftMarketAddress = txReceipt.contractAddress
console.log("nftMarket deployed to:", nftMarketAddress);
const NFT = await hre.ethers.getContractFactory("NFT");
const nft = await NFT.deploy(nftMarketAddress);
await nft.deployed();
txHash = nft.deployTransaction.hash;
// console.log(`NFT hash: ${txHash}\nWaiting for transaction to be mined...`);
txReceipt = await ethers.provider.waitForTransaction(txHash);
let nftAddress = txReceipt.contractAddress
console.log("nft deployed to:", nftAddress);
}
Thanks for this. Will the change also work if the script is deployed to the polygon mainnet?
How do I redeploy to the same contract addresses?
How did dabit3 show the original script working at the end of the tutorial?
This is fix my big problem, thx
Hi, still can't Buy, nothing happens. I updated deploy.js with your code, it deployed to new contract addresses, works like before but i can't Buy, only creates NFT in marketplace and can see it in created items.
This is the Buy buttton code: <button class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-full" onClick={() => buyNft(nft)}>Buy</button>
Thanks
Just noticed the transaction hash output for me is for the NFT contract not the Market contract ........ how can i check the transaction hash for the Market contract?
I updated deploy.js, reinstalled dependencies and deleted artifacts folder, recompiled. Still can't buy from marketplace, can create NFTs to show in it.
How do i redeploy to the same contract? When i run the script it creates a new contract with same problems.
Thanks
This is fix my big problem, thx
Didn't fix Buy for me, what did you do?