DEV Community

Cover image for How to Build a Full Stack NFT Marketplace - V2 (2022)

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

Nader Dabit on July 06, 2021

Building an NFT marketplace with Polygon, Next.js, Tailwind, Solidity, Hardhat, Ethers.js, and IPFS To view the video course for this t...

Displaying a subset of the total comments. Please sign in to view all comments on this post.

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
 
binsta profile image
Binston-sukhael-cardoza

Delete artifacts folder and compile hardhat

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?

Collapse
 
arielbk profile image
arielbk

I ran into issues with Infura, and with ipfs http server.

Infura requires you to create a billable account to use Polygon now, and you'll need to make another project on there for the IPFS part to get a project id and key specifically for IPFS.

After reading docs, I ended up going with the latest version of ipfs http server (^55.0.0 at time of writing) and doing the following:

import { create } from 'ipfs-http-client'

const projectId = process.env.NEXT_PUBLIC_INFURA_IPFS_PROJECT_ID
const projectSecret = process.env.NEXT_PUBLIC_INFURA_IPFS_PROJECT_SECRET
const projectIdAndSecret = `${projectId}:${projectSecret}`

const client = create({
  host: 'ipfs.infura.io',
  port: 5001,
  protocol: 'https',
  headers: {
    authorization: `Basic ${Buffer.from(projectIdAndSecret).toString(
      'base64'
    )}`,
  },
})
Enter fullscreen mode Exit fullscreen mode

I guess things are changing quickly! 😄

Collapse
 
phoenixdevguru profile image
Legendary Phoenix

Thanks @arielbk, The public IPFS gateway was deprecated by INFURA in August 10 2022.

Please read the details here.

I've created the PR for uploading Files on IPFS using Pinata Gateway.
It's absolutely free to create your own project on Pinata and you can get the key pairs for your project.

Collapse
 
yawnxyz profile image
Jan Z

I ended up signing up for an account at maticvigil.com which doesn't need a credit card

Collapse
 
samreenkazi profile image
Samreen Kazi

Hey, can you please show an example on how you did that ?

Collapse
 
akumthek profile image
akumthek

and so how do the IPFS API url s change? do they also use Projet ID and secret KEY stuff? This will be immensely useful.............thanks in advance

Collapse
 
zonezter_bas profile image
Bas

Could you please show an example text on how to get this in the code? I don´t really understand it. I think I´m having the IPFS problems as well.

Collapse
 
btandayamo profile image
Bertil Tandayamo • Edited

I had same issue with JsonRpcProvider, so I did

//index.js
const provider = new ethers.providers.JsonRpcProvider('https://rpc-mainnet.maticvigil.com')
Enter fullscreen mode Exit fullscreen mode

Deploy again on mumbai test net, copy new contract address to config file and voila
PSD. Remember to have same url in metamask wallet, hardhat config file and index.js

Collapse
 
will_urban profile image
Willian Urban

There is a small bug when buying an item when the tokenId and itemId do not match.

How to reproduce:

1- Go to /create-item, mint an item A with price X, but do not list it.
2- Mint an Item B with price Y, then list it.
3- Go to index and try to buy item B.
Result: "Please submit the asking price in order to complete the purchase".
Expected result:
Purchase successful.

Fix:

1- In index.js on the function loadNFTS add itemId: item.itemId.toNumber(), to the object item.
2- When calling createMarketSale the second argument should be nft.itemId.

As I've finished typing all this I've noticed that it has been fixed in the github repo github.com/dabit3/polygon-ethereum...

Well, at least now you know if you are looking for a solution here

Collapse
 
authenticfake profile image
authenticfake

yes correct, the same fix applied!

Collapse
 
will_urban profile image
Willian Urban • Edited

If you are going though this tutorial, I've build a slightly more cooler NFT Marketplace based on this blog post that helped me land a job 6 months ago, and for that I thank Nader and several other free content providers.

Granted it was my first time playing with Next, and there are several things I would have done differently, but hey have a look, its not bad:

nft-marketplace-dusky.vercel.app/c...
github.com/UrbanWill/nft-marketplace

Collapse
 
fidalmathew profile image
Fidal Mathew

Thank you! Appreciate the help!!

Collapse
 
ssf profile image
Sione

if you have a setForSell function in the Market contract say after a user buys then decides to sell again, will you then need to transfer the token to the market address? like IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId). Because I have tried this and it is giving me error 'ERC721: transfer caller is not owner nor approved' but the owner of the token is the one making the transfer. Maybe im not doing something right. Please help

Collapse
 
mateusasferreira profile image
Mateus Ferreira

Hey, I posted my entire solution for this issue, if somebody is still facing it:
dev.to/mateusasferreira/how-to-cre...
Hope it helps ;)

Collapse
 
yawnxyz profile image
Jan Z

There's a way to change the deploy script w/o changing the contract itself. 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
Collapse
 
mateusasferreira profile image
Mateus Ferreira

Hey, I'm having the same problem :( were you able to solve it since you posted this?

Collapse
 
ssf profile image
Sione

I have not. Still looking for a solution

Thread Thread
 
mateusasferreira profile image
Mateus Ferreira

Solved my issue yesterday by writing a custom function to tranfer tokens on my NFT contract. Like this:

contract NFT is ERC721URIStorage {
    (...)
    function transferToken(address from, address to, uint256 tokenId) external {
        require(ownerOf(tokenId) == from, "From address must be token owner");
        _transfer(from, to, tokenId);
    }
}
Enter fullscreen mode Exit fullscreen mode

And in my Market Contract:

import "./NFT.sol";

contract NFTMarket is ReentrancyGuard {
    (...)
    function putItemToResell(address nftContract, uint256 itemId, uint256 newPrice)
        public
        payable
        nonReentrant
        onlyItemOwner(itemId)
    {
        (...)
        uint256 tokenId = idToMarketItem[itemId].tokenId;

        NFT tokenContract = NFT(nftContract);

        tokenContract.transferToken(msg.sender, address(this), tokenId);        
    }

}
Enter fullscreen mode Exit fullscreen mode

Don't know all the implications of this solutions and if it may fail or cause security issues somehow but it solved my problem for know.

Collapse
 
giuseppecrj profile image
G.

Amazing article as always @dabit3

One small error I found is on sample-test.js instead of:

        tokenId: i.price.toString(),
Enter fullscreen mode Exit fullscreen mode

it should be

        tokenId: i.tokenId.toString(),
Enter fullscreen mode Exit fullscreen mode
Collapse
 
dabit3 profile image
Nader Dabit Edge and Node

Thank you! And thanks for the heads up, fixing this now!

Collapse
 
coderbang1 profile image
coderbang1 • Edited

i can create items, but when i try to buy nothing happens.

console shows this error: MetaMask - RPC Error: Internal JSON-RPC error.
Object { code: -32603, message: "Internal JSON-RPC error.
(code: 3, message: "execution reverted: Please submit the asking price in order to complete the purchase")

and this one: Uncaught (in promise)

[Note that: its not on matic. i have deploy it to bsc testnet. ]

Collapse
 
will_urban profile image
Willian Urban
Collapse
 
x777 profile image
YD

Any solution?

Collapse
 
sumeetchawla profile image
Sumeet Chawla

Hey Nader! This is such a brilliant article and a youtube video. I tried my hands at it and am falling in love with Blockchain.

So, if I am understanding it right, the listing fees should reflect in the owner's account when a certain sale happens right? But I am unable to see it. I will try to revisit the code and figure out why it isn't happening.

Collapse
 
dabit3 profile image
Nader Dabit Edge and Node

Amazing to hear! Yes! This should be the case. Maybe consider bumping the listing fee up high to see it show up, maybe something like equivalent of 100 or 1000 Matic

Collapse
 
sumeetchawla profile image
Sumeet Chawla

Thank you so much for replying. Yes, I did try it with 1000 matic. But it was still not working. It was a very stupid mistake from my end. Out of the three accounts on metamask, one was actually not imported using the keys generated in the hardhat node command 😅 I used that account's private key to initialise the market contract lol.

I was tearing my hair in trying to figure out why it wasn't working as the code made perfect sense.

Great work though. Looking forward to the next article. :D How to create a yield farm 🙈

Thread Thread
 
d2vin profile image
d2vin

Hi, I too was having this issue and using the hardhat private key worked for me as well. Now my question is how do get this functionality to work with my personal ethereum account?

Collapse
 
d2vin profile image
d2vin

Hi, I too was having this issue and using the hardhat private key worked for me as well. Now my question is how do get this functionality to work with my personal ethereum account?

Collapse
 
ayumirage profile image
Ayumirage • Edited

im stuck on this error:

./pages/index.js:10:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
8 |
9 | import NFT from "../artifacts/contracts/NFT.sol/NFT.json";

10 | import Market from "../artifacts/contracts/Market.sol/NFTMarket.json";
11 |
12 | export default function Home() {
13 | const [nfts, setNfts] = useState([]);

Collapse
 
sumeetchawla profile image
Sumeet Chawla

If you are running on local, you haven't compiled or tested your code and hence the artifacts are not generated.

If you are trying to build on vercel, this will come cause again the artifacts are missing. The general practice is not to commit those. Add a compile (or test) command to your build script before building nextjs.

Collapse
 
barryhewitt profile image
Baz-Cloud

Hi, please could you help me with this, i've been following this course for days now and I'm totally stuck on this.

Once i type npm run dev this is what i get

BarryH@EPT-LT23 MINGW64 ~/digital-marketplace (main)
$ npm run dev

digital-marketplace@0.1.0 dev
next dev

ready - started server on 0.0.0.0:3000, url: localhost:3000
info - Using webpack 5. Reason: Enabled by default nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /
wait - compiling...
error - ./pages/index.js:11:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
9 |
10 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

11 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | export default function Home() {
14 | const [nfts, setNfts] = useState([])

Import trace for requested module:

nextjs.org/docs/messages/module-no...
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./pages/index.js:11:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
9 |
10 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

11 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | export default function Home() {
14 | const [nfts, setNfts] = useState([])

Import trace for requested module:

nextjs.org/docs/messages/module-no...
wait - compiling...
event - compiled successfully

Collapse
 
btandayamo profile image
Bertil Tandayamo

Please elaborate

Collapse
 
barryhewitt profile image
Baz-Cloud

Hi, i'm really stuck on this and have been trying to figure it out for hours, did you manage to figure it out?

Collapse
 
vitustockholm profile image
Vitus

hm, did You try figure out this: '' error - ./pages/index.js:11:0 '' *** index.js 11 code line

time is the master , and time could be disaster .. .
for me worked good enough to go and make tests :

' 'change => '../artifacts/contracts/Market.sol/NFTMarket.json' to ...... '../artifacts/contracts/NFTMarket.sol/NFTMarket.json' ''

Collapse
 
genie_anabelle profile image
Genie Anabelle • Edited

Hi, I'm having a runtime error in create-item.js when clicking to create the listing! Would appreciate any help, thank you!

The error is regarding: let value = event.args[2]

Collapse
 
ksteigerwald profile image
Kris Steigerwald • Edited

Restart your hardhat node, Redeploy your contracts, update your config.js with new contract addresses. Set MetaMask custom nounce to 0 (I had to do this to deal w/ another error) and then update the nounce with each following transaction.

hth

Collapse
 
insivika profile image
Philipp A. • Edited

Thank you this worked. I also had a misconfiguration in my metamask account. Can you please explain why I have to manually set the nonce? How could I expect an actual user to do this?

Thread Thread
 
yawnxyz profile image
Jan Z

if you get the "nonce too high" error, do this: medium.com/@thelasthash/solved-non...

Collapse
 
gullinburstilab profile image
Jose Lopez Jr

When I redeploy the contract, I dont get any of the console logs, but it says "Done in 1.71s.", is there any reason I am unable to see the addresses?

Collapse
 
cryptobeginner profile image
CryptoBeginner

Hi i having this same event.args[2] you found any solution?

Collapse
 
nan141979 profile image
Skrillx

Nader, I'm having this problem after having a lot of Nft No market place...

Error: call revert exception (method="fetchMarketItems()", errorArgs=[{"type":"BigNumber","hex":"0x32"}], errorName="Panic", errorSignature="Panic(uint256)" , reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)

It's a new mistake I've never seen anything like it. What can it be?

Collapse
 
josiahabrown profile image
JosiahABrown

I had the same problem. If you are testing on Mumbai I suggest changing the RPC provider in both index.js and your metamask account to matic-mumbai.chainstacklabs.com/ instead of rpc-mumbai.matic.today/ . That fixed it for me.

Collapse
 
amo profile image
amo

Hi, did you find a solution to this error?
I am having the same issue. 😥

Collapse
 
theindianappguy profile image
Sanskar Tiwari

i am facing the same if found solution please share

Thread Thread
 
amo profile image
amo

I honestly cant recall what was the problem, but I think you should compare the code in the video & this article for differences (there are a lot). I had to do line by line debugging to solve some of the errors. it took me more than 2 days to finish this 2 hours tutorial.

all the best.

Collapse
 
arcticmatt profile image
Matt Lim

For this part

let tx = await transaction.wait()
let event = tx.events[0]
let value = event.args[2]
Enter fullscreen mode Exit fullscreen mode

it seems like the intention is to get the MarketItemCreated event (otherwise I think that event goes unused)? But it actually gets the Transfer event. Functionally it's equivalent because both have tokenId as their third arg, but it's a little unclear what the intention is.

Collapse
 
chaun profile image
Chaun

Hi Matt,

Did you manage to find a solution to this error?

Hope to hear from you

Collapse
 
amo profile image
amo • Edited

Hi, I had the same error it was because I wasn't connected to the correct account in Metamask.

Make sure your metamask local network is on the same port provided when you run "npx hardhat node" probably " 127.0.0.1:8545/" and then import the an account to metamask using any of the private keys given and test it again

Thread Thread
 
99bits profile image
99bits

Hi Amo,

I followed your instructions but still having the same issue.

Collapse
 
blackbeltdegen profile image
blackbeltDegen

Hey Guys,

So i managed to create a nft listing and do a successful ttransaction. The issue i am having now is thatevertime i go to home i get the following errors:

"Unhandled Runtime Error
Error: Request failed with status code 400

Call Stack
createError
node_modules\axios\lib\core\createError.js (16:0)

settle
node_modules\axios\lib\core\settel.js(17:0)

XMLHttpRequest .onloadend
node+modules\axios\lib\adapters\xhr.js (66:0)"

Anyone experience this same issue and get it resolved? if so what was your solution ?

Collapse
 
jtstephens18 profile image
JTStephens18 • Edited

I am also experiencing this error. The ambiguity makes it difficult to debug. Any assistance would be appreciated. @dabit3

Collapse
 
adityakaklij profile image
Aditya kaklij

Try to install axios using yarn
yarn add axios

I install it and it works properly

Thread Thread
 
blackbeltdegen profile image
blackbeltDegen

that did not work :(

Collapse
 
adityakaklij profile image
Aditya kaklij

Try to install axios using yarn
yarn add axios

I install it and it works properly

Collapse
 
priyexh profile image
Priyesh Gohil • Edited

did you fix it? as im also facing same error

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?

Collapse
 
sonnyk37 profile image
SonnyK

Anyone get this error:

Error: Transaction reverted: function selector was not recognized and there's no fallback function

Various forums online seem to suggest that I need a receiver function, but that doesn't fix the problem for me. Any help would be greatly appreciated!

Collapse
 
kanishksharma8 profile image
KanishkSharma8

why is this error coming have you figured it out yet? because I was facing the same error but it probably was due to some another reason.

Collapse
 
si3mshady profile image
Elliott Arnold

It's still happening...

Collapse
 
thapelo505 profile image
thapelo505

someone please help me sove these, i ran npm audit and got the same message
is it the package versions?

44 vulnerabilities (11 low, 4 moderate, 29 high)

To address issues that do not require attention, run:
npm audit fix

Some issues need review, and may require choosing
a different dependency.

digital-marketplace>npm list
digital-marketplace@0.1.0 C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace
+-- @nomiclabs/hardhat-ethers@2.0.2
+-- @nomiclabs/hardhat-waffle@2.0.1
+-- @openzeppelin/contracts@4.3.1
+-- autoprefixer@10.3.4
+-- axios@0.21.4
+-- chai@4.3.4
+-- ethereum-waffle@3.4.0
+-- ethers@5.4.6
+-- ipfs-http-client@52.0.3
+-- next@11.1.2
+-- postcss@8.3.6
+-- react-dom@17.0.2
+-- react@17.0.2
+-- tailwindcss@2.2.10
`-- web3modal@1.9.4

Collapse
 
chaun profile image
Chaun

Run npm audit fix

Collapse
 
thapelo505 profile image
thapelo505

i tried it but it still gives me the same

Thread Thread
 
0xshinobi profile image
Eric

use yarn instead

Collapse
 
ahmadxali profile image
AhmadxAli

npm audit fix --force

Collapse
 
zonezter_bas profile image
Bas

I have tried everything when it comes to this error:
Error: call revert exception (method="fetchMarketItems()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)

Everybody else here seems to have fixed it by providing the RPC url in the
const provider = new ethers.providers.JsonRpcProvider

But for some reason I keep getting the same error anyway, anybody have any idea where to look? :(

Collapse
 
skimaharvey profile image
Skima Harvey • 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.

Collapse
 
zonezter_bas profile image
Bas

Thank you very much! How do I look at the transactions created by the Mumbai wallet?

Thread Thread
 
skimaharvey profile image
Skima Harvey

what you can do is redeploy on mumba 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

Thread Thread
 
zonezter_bas profile image
Bas • Edited

This fixed it. I now have it deployed the project and its working on mumbai. Once again, thank you so much! I have been going crazy trying to figure this out.

Thread Thread
 
skimaharvey profile image
Skima Harvey

Sure np. Ran into this issue last night as well. Just weird that nft.address logs another address...

Collapse
 
kritzheng profile image
KritzHeng

I'm stuck on this error

Unhandled Runtime Error
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.3.1)

Source
.next\static\chunks\pages\index.js (173:0) @ Logger.makeError

171 | }
172 | // @todo: Any??

173 | const error = new Error(message);
174 | error.reason = reason;
175 | error.code = code;
176 | Object.keys(params).forEach(function (key) {
Call Stack
Logger.throwError
/_next/static/chunks/pages/index.js (7889:20)
JsonRpcProvider.
.next\static\chunks\pages\index.js (334:0)
Generator.throw

rejected
/_next/static/chunks/pages/index.js (12104:65)

Collapse
 
phantomhaze profile image
Alex Hernandez

The issue may be because of this line:
const provider = new ethers.providers.JsonRpcProvider()

I read the ethers docs, and they recommend JsonRpcProvider() for local nodes, for others they recommend getDefaultProvider() or Web3Provider(web3.currentProvider).
The other pages use Web3Provider, it's only index.js that uses the bad one.
So the fix for me was to make this change to index.js:
const provider = new ethers.providers.Web3Provider(web3.currentProvider)
And now I'm connected to and playing with the network!

Collapse
 
yosi profile image
yosi • Edited

You need to define networkId to the provider - ethers.getDefaultProvider('ropsten')

Collapse
 
nan141979 profile image
Skrillx

Hey Nader, I wanted to thank you so much for this post and for this wonderful job!

I'm learning a lot and demonstrating to my close friends... Do you have any complete courses?

I was able to run perfectly and execute, I wanted to know how I could implement it so that the assets that were bought can have their prices changed and sell again.

From what I understand after you buy the NFT you have nothing to do with it anymore.

That's right??

Collapse
 
rakveli profile image
rakveli

Have you been able to find a solution to this ?

Collapse
 
solaxds profile image
solaxds • Edited

I keep getting the following error under my pages, when attempting to deploy to Vercel - but I'm not sure how to resolve it, since I added my 'artifacts' folder to my .gitignore file:

Module not found: Can't resolve '../artifacts/contracts/NFTMarket.sol/NFTMarket.json' in '/vercel/path0/pages'

Would love some assistance, please

Collapse
 
mataspigaga profile image
Matas Pigaga

So the only thing I have been able to figure out for deployment is to ignore the artifacts folder (not sure why, probably it's a security issue) except for the two JSON files. I added this to my .gitignore to make it work:

#Hardhat files
cache
artifacts/*
!artifacts/contracts
!artifacts/contracts/*
!artifacts/contracts/NFT.sol
artifacts/contracts/NFT.sol/*
!artifacts/contracts/NFT.sol/NFT.json
!artifacts/contracts/NFTMarket.sol
artifacts/contracts/NFTMarket.sol/*
!artifacts/contracts/NFTMarket.sol/NFTMarket.json

Hope that helps!

Collapse
 
solaxds profile image
solaxds

Thanks @mataspigaga. I forgot I that also posted on dev.to - but thankfully, I did manage to figure out what was causing the deploy to error out in my own instance. See the following link:

github.com/vercel/next.js/discussi...

Collapse
 
thapelo505 profile image
thapelo505

i have really tried everything

npm audit report

elliptic <6.5.4
Severity: moderate
Use of a Broken or Risky Cryptographic Algorithm - npmjs.com/advisories/1648
fix available via npm audit fix
node_modules/ganache-core/node_modules/elliptic
@ethersproject/signing-key <=5.0.9
Depends on vulnerable versions of elliptic
node_modules/ganache-core/node_modules/@ethersproject/signing-key

lodash <4.17.21
Severity: high
Command Injection - https://npmjs.com/advisories/1673
No fix available
node_modules/ganache-core/node_modules/lodash
ganache-core *
Depends on vulnerable versions of lodash
Depends on vulnerable versions of web3
Depends on vulnerable versions of web3-provider-engine
node_modules/ganache-core
@ethereum-waffle/provider *
Depends on vulnerable versions of @ethereum-waffle/ens
Depends on vulnerable versions of ganache-core
node_modules/@ethereum-waffle/provider
@ethereum-waffle/chai >=2.5.0
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/@ethereum-waffle/chai
ethereum-waffle >=2.3.0-istanbul.0
Depends on vulnerable versions of @ethereum-waffle/chai
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/ethereum-waffle
@nomiclabs/hardhat-waffle *
Depends on vulnerable versions of ethereum-waffle
node_modules/@nomiclabs/hardhat-waffle

node-fetch <=2.6.0 || 3.0.0-beta.1 - 3.0.0-beta.8
Denial of Service - npmjs.com/advisories/1556
No fix available
node_modules/ganache-core/node_modules/fetch-ponyfill/node_modules/node-fetch
node_modules/ganache-core/node_modules/node-fetch
cross-fetch <=2.2.3 || 3.0.0 - 3.0.5
Depends on vulnerable versions of node-fetch
node_modules/ganache-core/node_modules/cross-fetch
fetch-ponyfill 1.0.0 - 6.0.2
Depends on vulnerable versions of node-fetch
node_modules/ganache-core/node_modules/fetch-ponyfill
eth-json-rpc-middleware 1.1.0 - 5.0.2
Depends on vulnerable versions of fetch-ponyfill
node_modules/ganache-core/node_modules/eth-json-rpc-middleware
eth-json-rpc-infura <=5.0.0
Depends on vulnerable versions of eth-json-rpc-middleware
node_modules/ganache-core/node_modules/eth-json-rpc-infura
web3-provider-engine 14.0.0 - 15.0.12
Depends on vulnerable versions of eth-json-rpc-infura
node_modules/ganache-core/node_modules/web3-provider-engine
ganache-core *
Depends on vulnerable versions of lodash
Depends on vulnerable versions of web3
Depends on vulnerable versions of web3-provider-engine
node_modules/ganache-core
@ethereum-waffle/provider *
Depends on vulnerable versions of @ethereum-waffle/ens
Depends on vulnerable versions of ganache-core
node_modules/@ethereum-waffle/provider
@ethereum-waffle/chai >=2.5.0
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/@ethereum-waffle/chai
ethereum-waffle >=2.3.0-istanbul.0
Depends on vulnerable versions of @ethereum-waffle/chai
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/ethereum-waffle
@nomiclabs/hardhat-waffle *
Depends on vulnerable versions of ethereum-waffle
node_modules/@nomiclabs/hardhat-waffle

normalize-url 4.3.0 - 4.5.0 || 5.0.0 - 5.3.0 || 6.0.0
Severity: high
Regular Expression Denial of Service - npmjs.com/advisories/1755
fix available via npm audit fix
node_modules/ganache-core/node_modules/normalize-url

path-parse <1.0.7
Severity: moderate
Regular Expression Denial of Service in path-parse - npmjs.com/advisories/1773
fix available via npm audit fix
node_modules/ganache-core/node_modules/path-parse

tar <=4.4.17 || 5.0.0 - 5.0.9 || 6.0.0 - 6.1.8
Severity: high
Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization - npmjs.com/advisories/1770
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning - npmjs.com/advisories/1771
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links - npmjs.com/advisories/1779
Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization - npmjs.com/advisories/1781
fix available via npm audit fix
node_modules/ganache-core/node_modules/tar

underscore 1.3.2 - 1.12.0
Severity: high
Arbitrary Code Execution - npmjs.com/advisories/1674
No fix available
node_modules/ganache-core/node_modules/underscore
web3-bzz <=1.3.5
Depends on vulnerable versions of underscore
node_modules/ganache-core/node_modules/web3-bzz
web3 *
Depends on vulnerable versions of web3-bzz
Depends on vulnerable versions of web3-eth
node_modules/ganache-core/node_modules/web3
ganache-core *
Depends on vulnerable versions of lodash
Depends on vulnerable versions of web3
Depends on vulnerable versions of web3-provider-engine
node_modules/ganache-core
@ethereum-waffle/provider *
Depends on vulnerable versions of @ethereum-waffle/ens
Depends on vulnerable versions of ganache-core
node_modules/@ethereum-waffle/provider
@ethereum-waffle/chai >=2.5.0
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/@ethereum-waffle/chai
ethereum-waffle >=2.3.0-istanbul.0
Depends on vulnerable versions of @ethereum-waffle/chai
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/ethereum-waffle
@nomiclabs/hardhat-waffle *
Depends on vulnerable versions of ethereum-waffle
node_modules/@nomiclabs/hardhat-waffle
web3-core-helpers <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-utils
node_modules/ganache-core/node_modules/web3-core-helpers
web3-core <=1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-core
web3-eth-ens <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-eth-ens
web3-eth <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
Depends on vulnerable versions of web3-eth-ens
node_modules/ganache-core/node_modules/web3-eth
web3-core-method <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-core-method
web3-net 1.2.0 - 1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of web3-core-method
node_modules/ganache-core/node_modules/web3-net
web3-eth-personal <=1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of web3-core-helpers
Depends on vulnerable versions of web3-net
node_modules/ganache-core/node_modules/web3-eth-personal
web3-shh <=1.3.5
Depends on vulnerable versions of web3-core-method
Depends on vulnerable versions of web3-net
node_modules/ganache-core/node_modules/web3-shh
web3-core-subscriptions <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-core-subscriptions
web3-eth-contract <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-eth-contract
web3-providers-http <=1.0.0 || 1.2.0 - 1.3.5 || 3.0.0-rc.0 - 3.0.0-rc.4
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-providers-http
web3-providers-ipc <=1.3.6-rc.2 || >=3.0.0-rc.0
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-providers-ipc
web3-providers-ws <=1.3.6-rc.2 || 3.0.0-rc.0 - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-core-helpers
node_modules/ganache-core/node_modules/web3-providers-ws
web3-core-requestmanager <=1.3.5 || 3.0.0-rc.0 - 3.0.0-rc.4
Depends on vulnerable versions of underscore
node_modules/ganache-core/node_modules/web3-core-requestmanager
web3-eth-abi <=1.3.6-rc.2 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
Depends on vulnerable versions of web3-utils
node_modules/ganache-core/node_modules/web3-eth-abi
web3-eth-accounts <=1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
node_modules/ganache-core/node_modules/web3-eth-accounts
web3-utils 1.0.0-beta.8 - 1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of underscore
node_modules/ganache-core/node_modules/web3-utils
web3-eth-iban <=1.3.5 || 2.0.0-alpha - 3.0.0-rc.4
Depends on vulnerable versions of web3-utils
node_modules/ganache-core/node_modules/web3-eth-iban

web3 *
Severity: high
Insecure Credential Storage - npmjs.com/advisories/877
Depends on vulnerable versions of web3-bzz
Depends on vulnerable versions of web3-eth
No fix available
node_modules/ganache-core/node_modules/web3
ganache-core *
Depends on vulnerable versions of lodash
Depends on vulnerable versions of web3
Depends on vulnerable versions of web3-provider-engine
node_modules/ganache-core
@ethereum-waffle/provider *
Depends on vulnerable versions of @ethereum-waffle/ens
Depends on vulnerable versions of ganache-core
node_modules/@ethereum-waffle/provider
@ethereum-waffle/chai >=2.5.0
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/@ethereum-waffle/chai
ethereum-waffle >=2.3.0-istanbul.0
Depends on vulnerable versions of @ethereum-waffle/chai
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/ethereum-waffle
@nomiclabs/hardhat-waffle *
Depends on vulnerable versions of ethereum-waffle
node_modules/@nomiclabs/hardhat-waffle

ws 5.0.0 - 5.2.2 || 6.0.0 - 6.2.1 || 7.0.0 - 7.4.5
Severity: moderate
Regular Expression Denial of Service - npmjs.com/advisories/1748
fix available via npm audit fix
node_modules/ganache-core/node_modules/web3-provider-engine/node_modules/ws

yargs-parser <=13.1.1 || 14.0.0 - 15.0.0 || 16.0.0 - 18.1.1
Prototype Pollution - npmjs.com/advisories/1500
No fix available
node_modules/@ensdomains/ens/node_modules/yargs-parser
yargs 4.0.0-alpha1 - 12.0.5 || 14.1.0 || 15.0.0 - 15.2.0
Depends on vulnerable versions of yargs-parser
node_modules/@ensdomains/ens/node_modules/yargs
solc 0.3.6 - 0.5.10
Depends on vulnerable versions of yargs
node_modules/@ensdomains/ens/node_modules/solc
@ensdomains/ens *
Depends on vulnerable versions of solc
node_modules/@ensdomains/ens
@ethereum-waffle/ens *
Depends on vulnerable versions of @ensdomains/ens
node_modules/@ethereum-waffle/ens
@ethereum-waffle/provider *
Depends on vulnerable versions of @ethereum-waffle/ens
Depends on vulnerable versions of ganache-core
node_modules/@ethereum-waffle/provider
@ethereum-waffle/chai >=2.5.0
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/@ethereum-waffle/chai
ethereum-waffle >=2.3.0-istanbul.0
Depends on vulnerable versions of @ethereum-waffle/chai
Depends on vulnerable versions of @ethereum-waffle/provider
node_modules/ethereum-waffle
@nomiclabs/hardhat-waffle *
Depends on vulnerable versions of ethereum-waffle
node_modules/@nomiclabs/hardhat-waffle

44 vulnerabilities (11 low, 4 moderate, 29 high)

To address issues that do not require attention, run:
npm audit fix

Collapse
 
lukeb profile image
lukeb

Awesome tutorial! I've noticed when you create a market item with createMarketItem() on the create-item page, the item.owner and item.seller values are not the same. Is this on purpose or should these values be the same? If they are the same, the item would show up on the my-assets page. Is the creator of the item not initially the owner?

Collapse
 
hoangsonsky profile image
hoangsonsky

Thanks. I try to deploy to the ropsten network but I have a mistake.
It is Error: call revert exception (method="fetchMarketItems()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)
How can I fix it?

Collapse
 
theindianappguy profile image
Sanskar Tiwari • Edited

i am facing the same if you have solution please share solution

Collapse
 
barryhewitt profile image
Baz-Cloud

Hi, i hope you're well

Firstly thank you for putting this together it's really amazing!

I've spent a few days going through it slowly and using your code examples above to avoid any syntax errors and i'm nearly at the end but am getting the following error and wondered if you could help?

error - ./pages/create-item.js:14:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

14 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
chaun profile image
Chaun

You need to add NFT -> /NFTMarket.sol/NFTMarket.json'

Collapse
 
chaun profile image
Chaun

You need to add NFT -> /NFTMarket.sol/NFTMarket.json'

Collapse
 
zhaluza profile image
Zac Haluza

I'm getting the following error when I enter pragma solidity ^0.8.3 at the top of my smart contracts:

Source file requires different compiler version (current compiler is 0.7.3+commit.9bfce1f6.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
Enter fullscreen mode Exit fullscreen mode

Even after reinstalling my dependencies, my yarn.lock file still lists solc "0.7.3" as a dependency of hardhat@^2.5.0. Right now I'm using 0.7.3 as the Solidity version of my smart contracts - doubt it'll cause any issues for a smaller project like this, but I'm curious about how to get around it, or if that's even necessary.

Looking forward to finishing this project! Wrapping my head about how to build apps in the Web 3.0 paradigm has been both challenging and exciting, and I appreciate you putting such a huge effort into creating this type of much-needed content.

Collapse
 
emmanuelmartinez profile image
Emaxnuel

Hello everyone :)

I have this error in my-assets.js:

Unhandled Runtime Error

Error: call revert exception (method="fetchMyNFTs()", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.0-beta.156)

I copied and pasted the code from Github, I already looked everywhere on the Web but I can't figure it out because I don't fully understand what it is

I feel so desperate and frustrated, so useless :(

Collapse
 
sumeetchawla profile image
Sumeet Chawla • Edited

You are calling the JsonRpcProvider but initialising it with a public rpc url while running a local node. Remove that and it should work fine. 👍🏼

const provider = new ethers.providers.JsonRpcProvider() in index page

Collapse
 
btandayamo profile image
Bertil Tandayamo
Collapse
 
dmk profile image
dmk • Edited

Has anyone received this error while buying NFT from Home page?
Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

I did some little digging and found that the error is coming out of function buyNft() in index.js. The error arises when I createMarketSale(). See code snippet below.

const price = ethers.utils.parseUnits(nft.price.toString(), 'ether')
const transaction = await contract.createMarketSale(nftaddress, nft.itemId, {value: price})

Full code: github.com/dabit3/polygon-ethereum...

The same function works perfectly fine when used in tests. Appreciate any help.

Collapse
 
le4kno3 profile image
Takshil Patil

Hi dmk,

I solved the problem. My bug was I was giving the wrong contract address to contract.createMarketSale()

Earlier, I was my code looked like,

const price = ethers.utils.parseEther(nft.price.toString());
createMarketSale(nftMarketplaceAddress, nft.tokenId, { value: price });

The correct code should be,

const price = ethers.utils.parseEther(nft.price.toString());
createMarketSale(nftTokenAddress, nft.tokenId, { value: price });

Collapse
 
picozzimichele profile image
Michele Picozzi

bump for this, anyone has a solution?

Collapse
 
jorgehenriquezd profile image
jorgehenriquezd

I got the same error, did you solved?

Collapse
 
oxamyy profile image
0xamyy • Edited

Hi I am following this article and sadly my test does not run successfully right now, does anyone know what this error is?
when i run npx hardhat test in the terminal , it fails at the function :
0 passing (717ms)
1 failing

1) NFTMarket
should create and describe and execute market sales:
Error: missing argument: in Contract constructor (count=0, expectedCount=1, code=MISSING_ARGUMENT, version=contracts/5.4.1)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
at Logger.checkArgumentCount (node_modules/@ethersproject/logger/src.ts/index.ts:296:18)
at ContractFactory. (node_modules/@ethersproject/contracts/src.ts/index.ts:1201:16)
at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
at /home/nft-marketplace/node_modules/@ethersproject/contracts/lib/index.js:23:71
at new Promise ()
at __awaiter (node_modules/@ethersproject/contracts/lib/index.js:19:12)
at ContractFactory.deploy (node_modules/@ethersproject/contracts/lib/index.js:1111:16)

thanks!

Collapse
 
spaceh3ad profile image
spaceh3ad

Got same error while testing contracts. This error happens as i try to call function that takes bool as parameter.

Collapse
 
rizkywellyanto profile image
Rizky Wellyanto

I'm getting the same error. Anyone knows how to solve this?

Collapse
 
harshvardhansingh458 profile image
harshvardha

I'm getting the same error. Can anyone help?

Collapse
 
solaxds profile image
solaxds

I'm getting the following error:

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.5.2)

Has anybody received the same error? And if so, how did you resolve it?

Collapse
 
mateusasferreira profile image
Mateus Ferreira • Edited

Hey guys, I posted an article on how to list the item in the marketplace again after the user first bought it, as this was an issue for me and for others here:
dev.to/mateusasferreira/how-to-cre...
Hope it helps :)

Collapse
 
chaun profile image
Chaun

Has anyone managed to solve this?

63 | let tx = await transaction.wait()
64 | let event = tx.events[0]

65 | let value = event.args[2]
| ^
66 | let tokenId = value.toNumber()
67 |
68 | const price = ethers.utils.parseUnits(formInput.price, 'ether')

????

Collapse
 
amo profile image
amo

Hi, I had the same error it was because I wasn't connected to the correct account in Metamask.

Make sure your metamask local network is on the same port provided when you run "npx hardhat node" probably "127.0.0.1:8545/" and then import the an account to metamask using any of the private keys given and test it again

Collapse
 
insivika profile image
Philipp A.

This fixed it for me, thanks!

Collapse
 
brnandhu001 profile image
Nandhabalan R

Hi, I had the same error ...pls help me to solve that

Collapse
 
6hanel profile image
Lynn • Edited

hey there, I'm currently working on this project and I'm receiving such errors... Can someone please advice me on what to do next? Thank you in advance :)

Unhandled Runtime Error
Error: network does not support ENS (operation="ENS", network="unknown", code=UNSUPPORTED_OPERATION, version=providers/5.5.2)

Call Stack
Logger.makeError
node_modules/@ethersproject/logger/lib.esm/index.js (185:0)
Logger.throwError
node_modules/@ethersproject/logger/lib.esm/index.js (194:0)
JsonRpcProvider.eval
node_modules/@ethersproject/providers/lib.esm/base-provider.js (1522:0)
Generator.next

fulfilled
node_modules/@ethersproject/providers/lib.esm/base-provider.js (5:42)

Collapse
 
priyexh profile image
Priyesh Gohil

did you fix it? as im also facing same error and i couldnt find a solution

Collapse
 
thanhtheman profile image
thanh quach

Thanks Nader for a wonderful tutorial, I just wonders how we have listing fee of 0.025 ETH, but once we changed to MATIC network, we don't have any ETH in our account, how can we pay this fee? We pay it with MATIC (converted to ETH)?

Collapse
 
arealclimber profile image
Lumii

I think it's denominated in MATIC here actually.

Collapse
 
3y3net profile image
3y3net

Hello,
thanks a lot for this super-interesting article. I have a question:
How do you disconnect the wallet?
I've connect the wallet for the first hardhat account but I don't know how to disconnect metamask to log with another account.
Thanks

Collapse
 
codermarty profile image
Martin M Fernandes

Hi,

Everytime I try to deploy to the mumbai testnet using the command
npx hardhat run scripts/deploy.js --network mumbai

I run into this error.
ProviderError: transaction underpriced

Could someone please help.

Thank you

Collapse
 
damiena24 profile image
DamienA24

Hello,

In sample-test.js, when we create two nft with:

await nft.createToken("https://www.mytokenlocation.com");
await nft.createToken("https://www.mytokenlocation2.com");
Enter fullscreen mode Exit fullscreen mode

Why the newItemId return by createToken function is always 0 ? and don't 1 and 2 ?

Thank you

Collapse
 
hellosongi profile image
HelloSongi

HOW DO I FIX THIS PLEASE?

./pages/index.js:12:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
10 |
11 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

12 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
13 |
14 | export default function Home() {
15 | const [nfts, setNfts] = useState([])

Import trace for requested module:

nextjs.org/docs/messages/module-no...

Collapse
 
chaun profile image
Chaun

You need to add NFT -> /NFTMarket.sol/NFTMarket.json'

Collapse
 
elixir7 profile image
Elixir

Help! Has anyone run into this issue and could please point me in the right direction (at the 1:39 mark in the video, totally stuck!)?

Unhandled Runtime Error
Error: resolver or addr is not configured for ENS name (argument="name", value="", code=INVALID_ARGUMENT, version=contracts/5.5.0)

Collapse
 
elixir7 profile image
Elixir

If any other developers run into issues and are unable to find or troubleshoot the answer to your questions, I recommend checking out Buildspace where you can be supported in discord to complete dapps. I really wanted to finish this lesson but unfortunately could not find the answer to above so am moving on. If anyone knows of good web 3 developer forums where you can get questions answered I would be most grateful to know.

Collapse
 
ikhana profile image
Inaam Ullah

This is one of the best glance for full stack developement
Would like to extend to include dutch and english auction !
Can you guide, I had discussion on this with Mr. Nobody and he suggested Wovyern protocol. Is it good idea to create those manually or do it protocol mentioned ?

Collapse
 
saurabh20026 profile image
Saurabh20026

PLEASE HELP!!!!!
After running the script "npx hardhat test" for testing the contract, I am getting this error
NFTMarket
Should create and execute market sales:
HardhatError: HH700: Artifact for contract "NFTMarket" not found.
at Artifacts._getArtifactPathFromFiles (node_modules\hardhat\src\internal\artifacts.ts:391:13)
at Artifacts._getArtifactPath (node_modules\hardhat\src\internal\artifacts.ts:316:17)
at Artifacts.readArtifact (node_modules\hardhat\src\internal\artifacts.ts:49:26)
at getContractFactory (node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:91:22)
at Context. (test\sample-test.js:7:20)

I have tried to delete the artifacts and cache files and again running the script, changing the versions of hardhat but no use..really stuck on this for days.

PLEASE HELP
Thanks

Collapse
 
the4duvar profile image
Rojhat Birel

hello i am having the same problem. did you solve the problem?

Collapse
 
saurabh20026 profile image
Saurabh20026

First delete the artifact folder, after that in the "test" file try replacing NFTMarket with NFTMarketplace and then rerun the hardhat script.
The following procedure worked for me

Thread Thread
 
vulong1706 profile image
vulong1706

hi, I have some problems with this prj, can I contact you for your help?

Collapse
 
andreasgrowen profile image
andreasgrowen

I had a problem with reading the .env file from in the hardhat.config.js file seemed like this was not explained in the tutorial. I fixed it by doing this :

const dotenv = require("dotenv");
dotenv.config();

accounts: [${process.env.privateKey}]

Is this the right way to do it ?

Collapse
 
n3rdh4ck3r profile image
Elvis Mørales Fdz • Edited

Hey Nader, by the end of this post you mention about publishing a tutorial about showing how to use Polygon with The Graph, however I can't find it under your profile here.

Were you able to put this together or is somewhere else? A link to it would be very appreciated.

Thank you!

Collapse
 
amarnathrao profile image
Amar • Edited

Can anyone help me fast, im getting this error

Image description
Image description

Collapse
 
lpatipat profile image
lpatipat

Getting a json rpc error on the creator-dashboard after deploying to mumbai. Worked perfectly in localhost though. Do I need to change the arguments to web3modal there too?

It looks like this

inpage.js:1 MetaMask - RPC Error: Internal JSON-RPC error.
{code: -32603, message: "Internal JSON-RPC error.", data: {…}}
code: -32603
data: {code: 3, data: "0x08c379a00000000000000000000000000000000000000000…4656e7420746f6b656e000000000000000000000000000000", message: "execution reverted: ERC721URIStorage: URI query for nonexistent token"}
message: "Internal JSON-RPC error."

Collapse
 
chaun profile image
Chaun

Any solutions for this error?

Unhandled Runtime Error
TypeError: Cannot read property '2' of undefined

Source
.next\static\chunks\pages\create-item.js (65:27) @ _callee3$

63 | let tx = await transaction.wait()
64 | let event = tx.events[0]

65 | let value = event.args[2]
| ^
66 | let tokenId = value.toNumber()
67 |
68 | const price = ethers.utils.parseUnits(formInput.price, 'ether')
Call Stack
Generator.invoke [as _invoke]
.next\static\chunks\main.js (293:0)
asyncGeneratorStep

Collapse
 
99bits profile image
99bits

Hi Chaun, Did you find an answer to this problem

Collapse
 
marcamil30 profile image
MarcAmil30

Thank you for the article. It was really helpful. I am in the section of running the program in the local network and I got it to work up to the gas fee in metamask. However looking at the video another metamask tab appears to put the item in sale but this does not appear in mine.

This is probably why the transaction does not occur even after pressing "Create Digital Asset."

Do you know how to fix this issue? Thanks

Collapse
 
ravencode profile image
Bharat Kharbanda

Please help I'm stuck at this.

error - ./pages/index.js:11:0
Module not found: Can't resolve '../artifacts/contracts/Market.sol/NFTMarket.json'
9 |
10 | import NFT from '../artifacts/contracts/NFT.sol/NFT.json'

11 | import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'
12 |
13 | export default function Home() {
14 | const [nfts, setNfts] = useState([])

Collapse
 
chaun profile image
Chaun

You need to add NFT -> /NFTMarket.sol/NFTMarket.json'

Collapse
 
coderbang1 profile image
coderbang1

i can create items , but when i try to sell nothing happens.

i got this errors on console:
MetaMask - RPC Error: Internal JSON-RPC error.
Object { code: -32603, message: "Internal JSON-RPC error.
data: Object { code: 3, message: "execution reverted: Please submit the asking price in order to complete the purchase.
and: uncaught in promise

P:S: its not on matic, i have deploy it to bsc testnet.

Collapse
 
latonet profile image
latonet

can create NFT but can't Buy from marketplace, nothing happens
Hi, I can create NFTs, they show in dashboard for the metamask account and marketplace but cannot buy, nothing happens with Buy button.

This is the code for the Buy button in the NFT box in the home page. There's nothing there to make it execute something to Buy the NFT?

button class="w-full bg-pink-500 text-white font-bold py-2 px-12 rounded">Buy</button

Collapse
 
brnandhu001 profile image
Nandhabalan R

MetaMask - RPC Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"code":-32000,"message":"transaction underpriced"}}}'
Object
code: -32603
message: "[ethjs-query] while formatting outputs from RPC '{\"value\":{\"code\":-32603,\"data\":{\"code\":-32000,\"message\":\"transaction underpriced\"}}}'"
[[Prototype]]: Object

Collapse
 
shivamdeshmukh21 profile image
ShivamDeshmukh21

Hey, after creating the asset when i switch over to index or creator-dashboard I'm met with this error:
Unhandled Runtime Error
Error: Network Error

Source
.next\static\chunks\pages\creator-dashboard.js (16:0) @ createError

14 | */
15 | module.exports = function createError(message, config, code, request, response) {

16 | var error = new Error(message);
17 | return enhanceError(error, config, code, request, response);
18 | };

Collapse
 
biggestorca profile image
Artem

Hi 👋
Thanks for the lesson 🙏
It's really helpfully 😌
One moment: when testing - 'auctionPrice' in sample-test.js must be same as 'listingPrice' in contract. Otherwise test will fail with message: 'Error: VM Exception while processing transaction: reverted with reason string 'Please submit the asking price in order to the complete purchase''.
So set 'auctionPrice' value in test same as 'listingPrice' in contract to pass the test)

Collapse
 
emma78185676 profile image
Emma

Please help me, how can i get single NFT. Which function should i call to get all the details of a "single NFT". Details includes seller, owner, price, name, description, image etc.. This is for a view NFT page.

Collapse
 
nildhwaj profile image
Nildhwaj

Hello World

I am facing some npm dependency issues. Has anyone else encountered the following errors? If so, could you please tell me how to resolve them?
ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-photo-gallery@8.0.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! react@"^17.0.2" from the root project
npm ERR! peer react@">=16.8.0" from @emotion/react@11.10.5
npm ERR! node_modules/@emotion/react
npm ERR! @emotion/react@"^11.4.0" from react-awesome-reveal@3.8.1
npm ERR! node_modules/react-awesome-reveal
npm ERR! react-awesome-reveal@"^3.8.1" from the root project
npm ERR! @emotion/react@"^11.1.1" from react-select@4.3.1
npm ERR! node_modules/react-select
npm ERR! react-select@"^4.3.1" from the root project
npm ERR! 31 more (@emotion/use-insertion-effect-with-fallbacks, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from react-photo-gallery@8.0.0
npm ERR! node_modules/react-photo-gallery
npm ERR! react-photo-gallery@"^8.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@16.14.0
npm ERR! node_modules/react
npm ERR! peer react@"^16.8.0" from react-photo-gallery@8.0.0
npm ERR! node_modules/react-photo-gallery
npm ERR! react-photo-gallery@"^8.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Collapse
 
frankismartinez profile image
frank martinez

Superb walkthrough Nader, gracias!

Had to change import web3 from 'web3' to import web3 from 'web3-utils' in create-item.js

Otherwise very easy to get it up/running.

Collapse
 
dabit3 profile image
Nader Dabit Edge and Node

Hey, thanks, I actually meant to remove web completely and just use ethers, just updated to do so!

Collapse
 
frankismartinez profile image
frank martinez

Superb walkthrough Nader, gracias!

Had to change import web3 from 'web3' to import web3 from 'web3-utils' in create-item.js

Otherwise very easy to get it up/running.

Collapse
 
xcanchal profile image
Xavier Canchal

Sharing in case anyone encounters with the same issue:

In order to configure the Mumbai testnet in Metamask, I had to use the following RPC URL https://rpc-mumbai.maticvigil.com/ (as stated in the docs docs.polygon.technology/docs/devel...) instead of the one in the article, which showed a wrong Chain ID error.

Collapse
 
jusharra profile image
Jusharra

Hi All, I'm running the command npx hardhat test
However, I keep getting the following error
HardhatError: HH404: File @openzeppelin/contracts/security/ReentrancyGuard.sol, imported from contracts/Market.sol, not found.

I've installed openzepplin, removed. and re-added the import but still getting the same error. Any suggestions?

Collapse
 
mateusasferreira profile image
Mateus Ferreira • Edited

Hey Nader, thanks for the tutorial! Could somebody help me out? I'm trying to create some custom methods for the MarketPlace contract. In one, I give the buyer the option to resell the purchased item. But I am getting a "execution reverted: ERC721: transfer caller is not owner nor approved"

function putItemToResell(address nftContract, uint256 itemId, uint256 newPrice){
        (...)
        uint256 tokenId = idToMarketItem[itemId].tokenId;

        //getting the error here
        IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);       
    }
Enter fullscreen mode Exit fullscreen mode

The strange thing is that if I console log (IERC721(nftContract).ownerOf(tokenId) == msg.sender I get "true"

Collapse
 
drew1128 profile image
Drew Morrison

Hey Friends,

I keep getting this error when I load the application.

Uncaught (in promise) Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT,

any ideas? Thanks!

Collapse
 
priyexh profile image
Priyesh Gohil • Edited

Im getting this error after deploying to local node
Pls help asap!

Unhandled Runtime Error
Error: network does not support ENS (operation="ENS", network="unknown", code=UNSUPPORTED_OPERATION, version=providers/5.5.3)

Call Stack
Logger.makeError
node_modules\@ethersproject\logger\lib.esm\index.js (185:0)
Logger.throwError
node_modules\@ethersproject\logger\lib.esm\index.js (194:0)
JsonRpcProvider.eval
node_modules\@ethersproject\providers\lib.esm\base-provider.js (1536:0)
Generator.next

fulfilled
node_modules\@ethersproject\providers\lib.esm\base-provider.js (5:42)

Collapse
 
olasubomio profile image
olasubomi-o

Thank you Nader for the amazing tutorial. More blessings.

Hey everyone, I am currently facing this runtime issue anytime i click on the create digital assets.

I have checked my codebase and everything is identical to Nader's not sure what's wrong. Did some googling and didn't find any tangible solution

Uncaught (in promise) Error: invalid address or ENS name (argument="name", value=1.1845894229454212e+48, code=INVALID_ARGUMENT, version=contracts/5.5.0)
at Logger.makeError (index.js?dd68:185)
at Logger.throwError (index.js?dd68:194)
at Logger.throwArgumentError (index.js?dd68:197)
at eval (index.js?b70c:35)
at Generator.next ()
at fulfilled (index.js?b70c:5)

Collapse
 
will_urban profile image
Willian Urban

Hey, can you please check your hardhat version, the following fixed a similar issue for me:

dev.to/will_urban/comment/1l26g

Collapse
 
m0nkey_d_luf7y profile image
MUGIWARA

"Error: network does not support ENS (operation="getResolver", network="maticmum", code=UNSUPPORTED_OPERATION, version=providers/5.6.1)"

This is the one of two error i'm getting. i'm unable to fix it !! HELP.

Collapse
 
kvarela profile image
Karim Varela

Hi Mugiwara, did you ever fix this? I'm getting the same.

Collapse
 
awaismaqsood profile image
Awais Maqsood

hello files are not uploaded on IPFS can anyone check with code it needs following can anyone check ?
--id string your Infura ProjectID
--pin whether or not to pin the data (default true)
--secret string your Infura ProjectSecret
--url string the API URL (default "ipfs.infura.io:5001")

Collapse
 
zonezter_bas profile image
Bas

I have it all deployed on mumbai testnet and it seems like it is working. But when I try to create an NFT, it doesn't seem to work. It goes all the way to the transaction being successful in the wallet (transaction complete in metamask). But nothing happens to the "sell digital assets page" its just still. Then when I look at the "Home" there is no items in the marketplace being displayed.

Can anybody please help? Maybe this has something to do with Infura wanting to have a separate project for IPFS now. But I don´t understand where I´m supposed to put the IPFS projectid and secretid in the code? :(

Collapse
 
andysharez profile image
AndySharez • Edited

What up guys.

So, I forked the github repository,
and tried to deploy it within vercel.com

I got a lot of error alerts then...
watch screenshot
dev-to-uploads.s3.amazonaws.com/up...

So - has that anything to do with the code?

Or in other words: Should I start trying this scrpit out?

Don't want to underrate this work or talk trash here;

just saw some other guys having some problems in deploying it.

Thanks

Collapse
 
nezzrx profile image
Nezzar Kefif

Amazing ! Juste went though it today. Now if we were to use Polygon, the contracts would need to handle both tokens right ? Because having the prices in ETH on Polygon would not work right ? Or I guess the entire market place would need to be on Polygon. Either way amazing work !

PS: I had some trouble with the JsonRpcProvider function which would still return localhost. Make sure you update .secret BEFORE deploying the Smart Contracts to the Mumbai testnet. (Already stated in the article, but I tend to read diagonally... )

Collapse
 
latonet profile image
latonet

Hi

I've finally been able to get this working online at vercel like in localhost

But nothing seems to work. Styling isn't working, no messages for marketplace and can't create an NFT, no form popup.

Thanks

Collapse
 
thapelo505 profile image
thapelo505

could someone please help me im stuck:

C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace>npx hardhat test
node:internal/modules/cjs/loader:357
throw err;
^

Error: Cannot find module 'C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace\node_modules\color-convert\node_modules\color-name\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:349:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:562:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:27)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object. (C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace\node_modules\color-convert\conversions.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32) {
code: 'MODULE_NOT_FOUND',
path: 'C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace\node_modules\color-convert\node_modules\color-name\package.json',
requestPath: 'color-name'
}

Collapse
 
amo profile image
amo

install all the packages related to hardhat again.
do them one by one just to make sure they're installed correctly. this worked for me

Collapse
 
jamesonhill profile image
Jameson Hill

This is awesome, thanks @dabit3 ! Question. In the deploy script, what's the difference between deploying the NFTMarket contract and NFT contract? The former calls deploy() with no args, whereas the later calls deploy(NFTMarket.address).

Collapse
 
sumeetchawla profile image
Sumeet Chawla

If you look at the constructor for NFT smart contract, it requires the NFTMarket address.

Collapse
 
echtcipher profile image
Ashish Singh • Edited

I'm getting this error in "create-item.js", it would be appreciable if someone could give some leads regarding this ASAP.

index.js:318 Uncaught TypeError: debug_default.default is not a function
at Object../node_modules/ipfs-http-client/cjs/src/lib/core.js (core.js:22)
at Object.options.factory (react refresh:8)
at __webpack_require
_ (bootstrap:25)
at fn (hot module replacement:61)
at Object../node_modules/ipfs-http-client/cjs/src/lib/configure.js (configure.js:5)
at Object.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at Object../node_modules/ipfs-http-client/cjs/src/bitswap/wantlist.js (wantlist.js:6)
at Object.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at Object../node_modules/ipfs-http-client/cjs/src/bitswap/index.js (index.js:5)
at Object.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at Object../node_modules/ipfs-http-client/cjs/src/index.js (index.js:12)
at Object.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at Module../node_modules/ipfs-http-client/esm/src/index.js (id.js:23)
at Module.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at Module../pages/create-item.js (utils.js:122)
at Module.options.factory (react refresh:8)
at webpack_require (bootstrap:25)
at fn (hot module replacement:61)
at ?bbf9:5
at route-loader.js:207

Collapse
 
mnitchov profile image
mnitchov

Were you able to resolve this? I'm having the same issue @dabit3

Collapse
 
jujumimi19 profile image
Frangipad

I would like to code something similar for supply chain track application with nft token, somebody said that it is cheaper with tezos, i am a newbie and iwould like to know the best way to follow, any suggest?

Collapse
 
zonezter_bas profile image
Bas

Hi! I am trying to deploy to mumbai test net. But I get the following error:

ProviderError: transaction type not supported

Can somebody please help? I am using infura.io. I had to sign up for the polygon PoS addon to get access. But now I get this error instead.

Collapse
 
sargtier1 profile image
Salvatore Argentieri

Has anyone else experienced an issue when uploading assets? It seems that as I'm logging into meta mask, the rest of the transaction continues. I'm not prompted to approve the transaction and therefor the form just resets.

Any direction would be great.

Collapse
 
gayatribit profile image
Gayatri Barhate

I got this error :
Error HH8: There's one or more errors in your config file:

  • Invalid account: #0 for network: mumbai - Expected string, received undefined This is hardhat.config.js file `/* hardhat.config.js */ require("@nomiclabs/hardhat-waffle")

module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337
},
// unused configuration commented out for now
mumbai: {
url: "rpc-mumbai.matic.today",
accounts: [process.env.privateKey]
}
},
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
}`