Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mumbai deployment issue prevents the demo from working on Mumbai testnet #30

Open
janzheng opened this issue Jan 19, 2022 · 6 comments
Open

Comments

@janzheng
Copy link

janzheng commented Jan 19, 2022

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);
}
@janzheng janzheng changed the title Mumbai deployment issue prevents the demo from working on Mumbai Mumbai deployment issue prevents the demo from working on Mumbai testnet Jan 19, 2022
@latonet
Copy link

latonet commented Jan 20, 2022

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?

@ljinkai
Copy link

ljinkai commented Jan 20, 2022

This is fix my big problem, thx

@latonet
Copy link

latonet commented Jan 20, 2022

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

@latonet
Copy link

latonet commented Jan 21, 2022

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

@latonet
Copy link

latonet commented Jan 21, 2022

This is fix my big problem, thx

Didn't fix Buy for me, what did you do?

@ljinkai
Copy link

ljinkai commented Jan 25, 2022

This is fix my big problem, thx

Didn't fix Buy for me, what did you do?

@latonet I just fix this problem. Not you mentioned situation. #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants