DEV Community

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

Collapse
 
gooseophocles profile image
Goose Gordon

Has anyone received the following error? Ran into it while trying out the UI locally after running the deploy script for the first time - have tried to look around the web for answers with minimal success so far:

Error: call revert exception (method="fetchMarketItems()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)

All of my code is the same as the source code currently, please let me know if anyone has any ideas as to why this is happening!

Collapse
 
technophile04 profile image
Shiv Bhonde

you need to re-deploy the contract and change nftContract address and nftMarket address in config.js

Collapse
 
afozbek profile image
Abdullah Furkan Özbek • Edited

Probably you deploy smart contract to local hardhat node and later you suspend it.
1- Make sure you installed hardhat
2- If you want to deploy on localhost, make sure run npx hardhat node in other terminal window.
3- Redeploy it either localhost node or test networks (no need to start node on local) like Mumbai

npx hardhat run scripts/deploy.js --network localhost

Collapse
 
sherazmaker profile image
sherazmaker

If you deploy contract on localhost on port:8545 then make sure to connect to same port in metamask. And also use only JsonRpcProvide() instead of matic or any other provider.

Collapse
 
blackbeltdegen profile image
blackbeltDegen

change your chainID to 31337 in your metamask wallet if you are deploying to the localhost testnet

Collapse
 
earnestgdata profile image
Earnest Grasshopper 🏴󠁧󠁢󠁳󠁣󠁴󠁿

This post is old so this response probably won't help the original poster but it might help anyone else with this same error as I had. It's possible if you have his error that you're using the latest version of Node i.e., 17 which prefers IPv6 in it's search order. So when you're asking hardhat to perform it's node operation and it's creating a loopback of http://::1:8545 (IPv6) vs 127.0.0.1 which is the IPv4 version of the loopback. When you run the deploy script command (while using the IPv6) you'll have to use that 'hardhat' modifier for the network vs localhost or the command will fail and you'll get this error in your marketplace. To fix it you can change the DNS search order in Node 17 or use NVM to install an earlier version of Node.js. happy hunting!

Collapse
 
impwong profile image
Matt

I updated my localhost to ipv6 nothing change

Collapse
 
binsta profile image
Binston-sukhael-cardoza

Delete artifacts folder and compile hardhat

Collapse
 
theindianappguy profile image
Sanskar Tiwari

"Delete artifacts folder and compile hardhat" this does not solved it for me

Thread Thread
 
faisalfh5 profile image
Faisal Hussain

Follow this instruction:

To force a compilation you can use the --force argument, or run npx hardhat clean to clear the cache and delete the artifacts.

Collapse
 
phoenixdevguru profile image
Legendary Phoenix • Edited

Hi folks, I think I found the solution.
You can find loadNFTs() function in pages/index.js. We use the JsonRpcProvider to get the provider. That's the point. You must provide RPC url of the testnet where you want to deploy NFT contracts. In my case, I targeted the bsctestnet, so I provide the RPC url of the bsctestnet to JsonRpcProvider constructor. Maybe you can keep the url in the config.js file. That's all. Cheers~

Thread Thread
 
theindianappguy profile image
Sanskar Tiwari

can you share code how? i am not clear

Thread Thread
 
phoenixdevguru profile image
Legendary Phoenix • Edited
// pages/index.js
export default function Home() {
    ... ... 
  async function loadNFTs() {    
    // update RPC url for the contracts deployed on testnet.
    const provider = new ethers.providers.JsonRpcProvider("https://data-seed-prebsc-1-s1.binance.org:8545")
    ... ...
  }
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
theindianappguy profile image
Sanskar Tiwari • Edited

from where to get this rpc url?

Thread Thread
 
phoenixdevguru profile image
Legendary Phoenix • Edited

In your metamask settings->networks.
Please check the screenshot.

Thread Thread
 
theindianappguy profile image
Sanskar Tiwari

sorry not able to understand

Thread Thread
 
phoenixdevguru profile image
Legendary Phoenix • Edited

Okay, let me show another screenshot.


If you are trying to find RPC url of ropsten testnet, click the network name and simply copy the RPC url

That's all. Hope this is helpful for you. Thanks.

Thread Thread
 
silviarainicorn profile image
Silvia Barros

Thank you! It has been a while since this post but I just wanted to thank you, this solved my problem when deploying it to a testnet (Rynkeby in my case!)

Thread Thread
 
sir_baller profile image
Sir Baller

@legendaryphoenixicarus I just created an account to thank you for the JsonRPCProvider code you posted above. I was struggling and this solved my problem. thanks so much!

Thread Thread
 
zkimhom profile image
Zkimhom

@Silvia Barros @Sir Baller @legendaryphoenixicarus
thanks for your suggestions. and i want to deploy it to a testnet (ropsten),after i follow these suggestions and change the code , i meet a question (also when i deploy it for mumbai) ,it likes this (Error HH8: There's one or more errors in your config file: * Invalid account: #0 for network: ropsten - Expected string, received undefined). can u help me solve the problem or share me the hardhat.config.js file? thank you.

Thread Thread
 
zkimhom profile image
Zkimhom
Thread Thread
 
phoenixdevguru profile image
Legendary Phoenix • Edited

@zkimhom

You should pass your wallet private key from .env file to the account property.

    ropsten: {
      url: `https://ropsten.infura.io/v3/${process.env.infuraId}`,
      accounts: [process.env.privateKey]
    },
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
zkimhom profile image
Zkimhom

ok i got it. thank you so much

Collapse
 
will_urban profile image
Willian Urban

Was having the same problem and going crazy, my code was exactly like the tutorial, but one thing: the hardhat version.

After downgrading the hardhat version from 2.6.0 to 2.4.1 the issue has been fixed. (don't forget to delete the artifacts folder and run compile hardhat)

Collapse
 
megabyte0x profile image
Megabyte

command please?

Thread Thread
 
yawnxyz profile image
Jan Z

I'm having no problems with version ^2.8.2 so I'd try that one first.

to change versions, do npm install hardhat@^2.8.2 and just replace the numbers at the end

Collapse
 
latonet profile image
latonet

i'm getting this error and also

TypeError: marketContract.fetchMarketItems is not a function.

I've managed to upload to vercel and get it working, can create an NFT but nothing is displayed in dashboard or my items or marketplace front page.

I don't think the images are being sent to IPFS.

Anyone help?

Collapse
 
latonet profile image
latonet

I've the same problem but no-one seems to be able to answer this. I can create NFTs but they don't show in marketplace to be able to buy

Collapse
 
megabyte0x profile image
Megabyte

Same Issue. Its saying "execution reverted: ERC721: transfer caller is not owner nor approved"

Thread Thread
 
latonet profile image
latonet

my error message is

Error: call revert exception (method="fetchMarketItems()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)

and others related to getting MarketItems.

Thread Thread
 
megabyte0x profile image
Megabyte • Edited

Yes for some reason the market.address (in the deploy.js file) doesnt console.log the address of your NFTMarket address but some random one (same thing for the NFT contract address). What you can do is look at the transaction created by your Mumbai wallet. Find this transactions then get the contract's addresses of these transactions and update them accordingly in your config.js file.
what you can do is redeploy on mumbai and instead of console.log address console.log(market.deployTransaction.hash) and console.log(nft.deployTransaction.hash) . This will give you the transactions hashes then go to mumbai.polygonscan.com/ and enter these transactions hashes in order to find the correct contracts addresses. Update your config.js accordingly.

dev-to-uploads.s3.amazonaws.com/up...

Thread Thread
 
latonet profile image
latonet

Hi, thanks for the reply and image, i've got it to work by adding the adding the package.json and package-lock.json from the repository then npm i, after npm run dev to localhost 3000 got a 'network RPC' but that went when i added the chainstack link to index.js for loadNFTs

const provider = new ethers.providers.JsonRpcProvider("matic-mumbai.chainstacklabs.com").

I can now create NFTs and these show in the dashboard for any user and after making changes above also in the marketplace, but i can't click on the Buy button, nothing happens.

Thanks

Thread Thread
 
megabyte0x profile image
Megabyte

can you please share your git repo, I am having issues in the NFT contract.

Thread Thread
 
latonet profile image
latonet

Hi, i don't have a git repo for my site, i used localhost then vercel cli

Thread Thread
 
megabyte0x profile image
Megabyte

can you share it somehow please then?

Thread Thread
 
latonet profile image
latonet

I've not changed the NFT contracts. They're the same as in the git repo from dabit3 here github.com/dabit3/polygon-ethereum....

I got the solution i tried from a discussion on the dabit repo github.com/dabit3/polygon-ethereum...

Thread Thread
 
latonet profile image
latonet

I use github and do send files to it bit for some reason they don't upload to the selected repository, i have about 23 repositories i use for various things but this website, and others, are cloned locally then edited and uploaded to vercel by CLI, i can't get them to work on netlify or heroku

Collapse
 
yawnxyz profile image
Jan Z

This is happening because of a Mumbai error, outputting the wrong contract address. This causes the NFT contract to not approve the Marketplace's contract address to sell the NFTs. Redeploy with this script, by replacing 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
Thread Thread
 
latonet profile image
latonet

Thanks for this, i've replied to your same post in github.

Thread Thread
 
jfreddy82s profile image
jfreddy82s

Thanks this work for me for nonce error on deploy multiple contracts

Collapse
 
megabyte0x profile image
Megabyte • Edited

I am getting this Error after createItem function (on click Create an Asset button). I have same RPC in Metamask and the JSONRpc. Please guide me through this. Tried to do with different accounts but didn't work.

dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
si3mshady profile image
Elliott Arnold

yes!1

Collapse
 
iidajun profile image
JI

I had the same problem.

The problem was solved by resetting the saved data by executing the following command described in the GitHub repository> README.

npx hardhat node
npx hardhat run scripts/deploy.js --network localhost
npm run dev
Enter fullscreen mode Exit fullscreen mode

Probably the error is due to some problem with the saved data.

Collapse
 
theindianappguy profile image
Sanskar Tiwari

but i want to deploy this to ropsten not localhost so other can interact with it