DEV Community

Discussion on: How to Build a Full Stack NFT Marketplace - V2 (2022)

Collapse
 
yawnxyz profile image
Jan Z • Edited

Hey all, there's currently a bug on Mumbai causing deployed addresses to be incorrect. This is causing the constructor of the NFT contract to approve the wrong address for NFT purchases (because it uses the address of the Market deployment for approval) — causing the annoying "execution reverted: ERC721: approve caller is not owner nor approved for all" error.

Try using Mainnet (yes, you'll have to use real money) but it works!

Reference: github.com/nomiclabs/hardhat/issue...

Here's a workaround deploy script that will make it work on Mumbai. 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);
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
megabyte0x profile image
Megabyte

Thank you so much, finally it solved after 3 days of suffering.
Thank You again.

Collapse
 
si3mshady profile image
Elliott Arnold

what did you do?