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...
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?

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
 
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
 
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
 
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

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
 
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
 
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
 
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
 
blackbeltdegen profile image
blackbeltDegen

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

Collapse
 
si3mshady profile image
Elliott Arnold

yes!1

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
 
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

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
 
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
 
technophile04 profile image
Shiv Bhonde

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

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
 
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
 
samreenkazi profile image
Samreen Kazi

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

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
 
arealclimber profile image
Lumii • Edited

Thank you @arielbk! Really helpful!

I'll supplement some details.

First, put the infura personal project id and project secret to .env and make sure to add .env to .gitignore:

INFURA_IPFS_PROJECT_ID="....."
INFURA_IPFS_PROJECT_SECRET=".....
Enter fullscreen mode Exit fullscreen mode

Second, set env in next.config.js:

const nextConfig = {
    reactStrictMode: true,
    env: {
        INFURA_IPFS_PROJECT_ID: process.env.INFURA_IPFS_PROJECT_ID,
        INFURA_IPFS_PROJECT_SECRET: process.env.INFURA_IPFS_PROJECT_SECRET,
    },
}

module.exports = nextConfig
Enter fullscreen mode Exit fullscreen mode

Third, change the code in create-item.js

The import and const:

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

const projectId = process.env.INFURA_IPFS_PROJECT_ID
const projectSecret = process.env.INFURA_IPFS_PROJECT_SECRET
const projectIdAndSecret = `${projectId}:${projectSecret}`
const auth = `Basic ${Buffer.from(projectIdAndSecret).toString('base64')}`

const client = create({
    host: 'ipfs.infura.io',
    port: 5001,
    protocol: 'https',
    headers: {
        authorization: auth,
    },
})
Enter fullscreen mode Exit fullscreen mode

And in the function CreateItem():

    async function onChange(e) {

        const file = e.target.files[0]
        try {
            const added = await client.add(file, {
                progress: (prog) => console.log(`received: ${prog}`),
            })

            const url = `https://ipfs.infura.io/ipfs/${added.path}`

            client.pin.add(added.path).then((res) => {
                console.log(res)
                setFileUrl(url)
            })
        } catch (error) {
            console.log('Error uploading file: ', error)
        }
    }

    async function createItem() {
        const { name, description, price } = formInput
        if (!name || !description || !price || !fileUrl) return
        /* first, upload to IPFS */
        const data = JSON.stringify({
            name,
            description,
            image: fileUrl,
        })

        try {
            const added = await client.add(data)

            const url = `https://ipfs.infura.io/ipfs/${added.path}`
            // after file is uploaded to IPFS, pass the URL to save it on Polygon
            createSale(url)
        } catch (error) {
            console.log('Error uploading file: ', error)
        }
    }

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
kingjulien profile image
Abusomwan Santos

Hey, I tried everything here but I get message: "Request failed with status code 400"

Thread Thread
 
joninsley profile image
J.Ins

Do the suggestion above with the Auth header and also...

In your Infura IPFS Project, enable the dedicated gateway then replace:

const url = https://ipfs.infura.io/ipfs/${added.path}

const url = https://DEDICATED_GATEWAY_URL/ipfs/${added.path}

This requires a credit card on file on Infura.

Thread Thread
 
akumthek profile image
akumthek

Does this solution take care of creating an IPFS project (giving credit card info) ??? i dont see how.

Thread Thread
 
joninsley profile image
J.Ins

Yes because it allows you to use the dedicated gateway which gives you a URL like - nftmarketplace.infura-ipfs.io. Otherwise the old way in the tutorial no longer works on Infura.

Thread Thread
 
hmtri1011 profile image
Tri Hoang

Hi @arealclimber and @joninsley appreciated, able to run the flow, but may I know what is the differences between client.add and client.pin.add.

Thanks so much!

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.

Thread Thread
 
ssf profile image
Sione

Thanks that solution works but I agree with the implications it may bring if any. Thank you though! Ill update you if I find another stable solution.

Thread Thread
 
mateusasferreira profile image
Mateus Ferreira

my pleasure! Keep me posted about the solutions you may find.

Thread Thread
 
javilonte profile image
Javilonte

Hi, thank you for posting this, i would like to use your function on my code but it says "onlyItemOwner(itemId)" never used, am i missing something? thanks again!

Thread Thread
 
mateusasferreira profile image
Mateus Ferreira

Hey there! its a modifier that you're missing. I added this to my contract so I can use it in functions to ensure only the item's owner can execute it:


    modifier onlyItemOwner(uint256 id) {
        require(
            idToMarketItem[id].owner == msg.sender,
            "Only product owner can do this operation"
        );
        _;
    }

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
javilonte profile image
Javilonte

thanksss

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

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

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
 
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' ''

Thread Thread
 
mendsalbert profile image
Mends Albert

After a couple of hours of digging I finally found the solution to this problem

  1. The 'artefacts' directory is included in the .gitignore file which makes the whole folder invisible during build
  2. open the gitignore file and exclude the artefacts directory
  3. Now run 'npm run build' and everything all the error will be gone
Collapse
 
btandayamo profile image
Bertil Tandayamo

Please elaborate

Collapse
 
vitustockholm profile image
Vitus

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

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

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
 
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
 
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
 
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
 
baart1989 profile image
baart1989 • Edited

I had similar in my case it was that i had to re-run deploy.js command.

Collapse
 
cryptobeginner profile image
CryptoBeginner

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

Collapse
 
chaun profile image
Chaun

Hi also have the same issue, any solutions?

Collapse
 
insivika profile image
Philipp A.

Did you find a soludtion for this?

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
 
blackbeltdegen profile image
blackbeltDegen

i did not :( did you?

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
 
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
 
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
 
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...

Thread Thread
 
latonet profile image
latonet

where is console.log? (to "instead of console.log address .....") (jan 10 post)

Thread Thread
 
latonet profile image
latonet

where is console.log file to get market.deployTransaction.hash and nft.deployTransaction.hash?

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
 
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
 
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
 
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
 
rizkywellyanto profile image
Rizky Wellyanto

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

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
 
harshvardhansingh458 profile image
harshvardha

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

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
amarnathrao profile image
Amar • Edited

Can anyone help me fast, im getting this error

Image description
Image description

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
}
}
}
}`

Collapse
 
arcticmatt profile image
Matt Lim

Not sure why address(0) is used instead of address(this) to represent that the market owns the NFT? address(this) is passed to transferFrom, so I think they should be consistent.

Collapse
 
silviarainicorn profile image
Silvia Barros

I agree with this! Have you tried it?

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
 
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
 
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
 
gayatribit profile image
Gayatri Barhate

When i deploy to matic using
npx hardhat run scripts/deploy.js --network mumbai
I get this :
HardhatError: HH110: Invalid JSON-RPC response received:

405 Not Allowed

405 Not Allowed



nginx


at parseJsonResponse (C:\nft-marketplace\node_modules\hardhat\src\internal\util\jsonrpc.ts:47:11)
at HttpProvider._fetchJsonRpcResponse (C:\nft-marketplace\node_modules\hardhat\src\internal\core\providers\http.ts:206:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at HttpProvider.request (C:\nft-marketplace\node_modules\hardhat\src\internal\core\providers\http.ts:84:29)
at EthersProviderWrapper.send (C:\nft-marketplace\node_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20)
at getSigners (C:\nft-marketplace\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:45:20)
at getContractFactoryByAbiAndBytecode (C:\nft-marketplace\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:288:21)
at main (C:\nft-marketplace\scripts\deploy.js:5:26)

My hardhat.config.js file :
`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
}
}
}
}`

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
mansijoshi17 profile image
Mansi Joshi

Hello! I have followed the tutorial till the last. But I am facing issue in getting list of item which user just buy. I am able to successfully buy items but I am not getting those item in my items by calling fetchMyNFTs function.

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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

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

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
 
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
 
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
 
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
 
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
 
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
 
thejuju profile image
Julien Gabriel

This is crazy. Wonderful post @dabit3 !

Collapse
 
maximtil profile image
MaximTil

Has anyone received the following error? Ran into it while trying out the UI locally after running the deploy script for the first time
Image description

Collapse
 
mokuaomae254 profile image
robert mokua omae obare

hello guys i was trying to deploy this NFTMarketplace.sol contract to sepolia test network but got this error ready - started server on 0.0.0.0:3000, url: localhost:3000
info - Loaded env from C:\Users\MOKUA\Downloads\my project\polygon-ethereum-nextjs-marketplace.env
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:6:0
Module not found: Can't resolve '../config'
4 | import Web3Modal from 'web3modal'
5 |

6 | import {
7 | //nftmarketaddress
8 | marketplaceAddress
9 | } from '../config'

Import trace for requested module:

nextjs.org/docs/messages/module-no...
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./pages/index.js:6:0
Module not found: Can't resolve '../config'
4 | import Web3Modal from 'web3modal'
5 |

6 | import {
7 | //nftmarketaddress
8 | marketplaceAddress
9 | } from '../config'

Import trace for requested module:

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

Collapse
 
piotrsadolewski profile image
PiotrSadolewski

Hi,
I can't solve that problem. TypeError: Cannot read properties of undefined (reading 'length'). Do you have any ideas, previus solution don't work.

Collapse
 
arealclimber profile image
Lumii

I guess you have typos. Could you post the code?

Collapse
 
piotrsadolewski profile image
PiotrSadolewski

The same result is when im doing it with cloned git from that blog, and it was working 4 months ago i didn't change anythink

Collapse
 
muneer_hashmat profile image
Muneer Hashmat🍁

hello bro. I'm facing the same problem. Did you find any solution?

Collapse
 
vulong1706 profile image
vulong1706

did you fix this erro? can you help me :((( I am facing with this problem

Collapse
 
deborahquarksalchemist profile image
Deborah Sanchez

Image description

Any ideas why this is happening? I am trying to create the nft, but seems like all the pages throw a 404 (home, create, etc)

Collapse
 
hoangson98 profile image
HoangSon98

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

How to fix error above? Thanks a lot

Collapse
 
yash271 profile image
Yash271

Hey Guys,
I have been getting this issue after running my localhost once i've deployed the nft to mumbai

Error: missing revert data in call exception; Transaction reverted without a reason string See: links.ethers.org/v5-errors-CALL_EXCEPTION

Any possible solutions for this?

Collapse
 
r0ushann profile image
ROUSHAN KUMAR • Edited

Image description

Unhandled Runtime Error
AxiosError: Network Error

Call Stack
XMLHttpRequest.handleError
node_modules/axios/lib/adapters/xhr.js (154:0)

Collapse
 
vishal590 profile image
vishal


Unhandled Runtime Error
Error: Invariant: attempted to hard navigate to the same URL /create-nft.js http://localhost:3000/create-nft.js

getting this error

Collapse
 
saurabh20026 profile image
Saurabh20026

After running the following script: "npx hardhat run scripts/deploy.js --network localhost" , I am getting the following error.
Error HH8: There's one or more errors in your config file:

  • Invalid account: #0 for network: mumbai - private key too long, expected 32 bytes
  • Invalid account: #0 for network: mainnet - private key too long, expected 32 bytes

I am running the script from the correct directory and the private key is also same from my metamask account
I really dont know what's happening, been over this for couple days.
Any help is appreciated

Collapse
 
fabolandry profile image
Fritz FABO

Hello, Tried to push on vercel.

I have this error : Module not found: Can't resolve '../artifacts/contracts/NFTMarketplace.sol/NFTMarketplace.json' in '/vercel/path0/pages'

Any chance on how to resolve it ? I know that usually the .json represent the abi. Where is the abi of this project ?

Collapse
 
merajbugti profile image
Dr. Meraj ahmed

Hello Everyone, I am getting this error can anyone help me please.

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

Collapse
 
merajbugti profile image
Dr. Meraj ahmed

I am stuck at this point , I have looked in all comments for solution but coudn't find it.

Collapse
 
merajbugti profile image
Dr. Meraj ahmed

Hello Everyone, I am getting this error?

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

  • have tried to look around the comments for answers with no success so far, little help will be really appreciated. regards
Collapse
 
deposetaprodctrl profile image
deposetaprod-ctrl

thank you very much for your content but I don't understand why my page is not showing on my browser everything works except that. nothing is displayed. No error is announced but on my browser for the create-item tab, I just see the header and that's it.

Collapse
 
foxyflow profile image
LukaFox • Edited

Metamask connection works and confirmed on Etherscan However: Pic doesn't reappear as an NFT on any of my pages. Anyone ran into this and remember how they fixed the issue?

pages\creator-dashboard.js (31:14) @ _callee$

29 | const data = await marketContract.fetchItemsCreated()
30 |

31 | const soldItems = items.filter(i => i.sold)
| ^
32 | setSold(soldItems)
33 | setNfts(items)
34 | setLoadingState('loaded')

And this error could be related:
Unhandled Runtime Error

Error: processing response error (body={"jsonrpc":"2.0","id":44,"error":{"code":3,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000032","message":"execution reverted"}}, error={"code":3,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000032"}, requestBody="{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x6c6d68d48fe64c064985901058e828035901d153\",\"data\":\"0x0f08efe0\"},\"latest\"],\"id\":44,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="polygon-mumbai.infura.io/v3/7356d5...", code=SERVER_ERROR, version=web/5.0.0-beta.142)

Collapse
 
panselino profile image
Panselino • Edited

Hi, thank you for the information. I'm trying to build up NFT market place by your tutorial. The first step is "npx create-next-app nft-marketplace" right? I entered it, it seems not right. In my folder only node_modules, package-lock.json, packge.json, yarn.lock are shown. It is wrong, isn't it? I reinstalled but there is no "next.config.js, pages, public, styles." I delete the all folder and reinstall but still there is an error.

error next@12.1.2: The engine "node" is incompatible with this module. Expected version ">=12.22.0". Got "12.19.1"
error Found incompatible module.

Collapse
 
guillaumeds profile image
Guillaume-ds

Hi, thanks for this amazing tutorial.

Does anyone knows how the marketplace contract can be updated in prod? If I change this contract I will need to redeploy it, does that mean that every nft published on the marketplace will be lost (because of a change in the market address)?

Thanks !

Collapse
 
alwaystanaya20 profile image
Vaibhavi Thakare • Edited

C:\nft-marketplace>npx hardhat run scripts/deploy.js --network mumbai
Error HH8: There's one or more errors in your config file:

* Invalid account: #0 for network: mumbai - Expected string, received undefined

During deploying it on Polygon network!
URGENT HELP!!

Collapse
 
jcoegom profile image
Jose CM

I wonder.. If you are implement a NFT marketplace like this, In a future version you could want to create users management...etc.
The question is, What data will you store in blockchain and what data should you store in a centralized database of the application? What should be the criteria?

I asked this question in a lot of places but nodoby answer to me a really realiable answer.

Collapse
 
techfixl profile image
Fixl Solutions

I am using this project and having an issue that when anyone purchases the NFT no amount is transferred to seller's wallet when console log the details it shows 0x000000000000000.. as seller's address.

Collapse
 
techfixl profile image
Fixl Solutions

Hey ,
I am using this project and found that no amount is deducted and and send to the seller wallets after the transaction is done.
NFT is transferring but amount is not.
Kindly help in this issue.

I didn't change anything just copy paste the same project.

Collapse
 
afrazahmmad profile image
afraz-ahmad

Hi,
I have watched and followed your youtube video and successfully created NFT Marketplace.
Thanks a lot for this.

I have a question that, I want features to list, categorise, search, filter NFTs.

So how I can save those details and where to save them ?
Should I save nft details on other database like Mysql to perform those queries ?

Or there is any preferred way to do this ?

Thanks a lot.

Collapse
 
brnandhu001 profile image
Nandhabalan R • Edited

mint and sale function working fine after that move marketplace page but items not listed pls help me how to fix the error....

GET bafybeih7dpst275p3h2vrl3opg4y2lajf... net::ERR_NAME_NOT_RESOLVED

Collapse
 
hotarumoon profile image
Ege • Edited

Hi, I've tried to add a method to create a resell of an NFT bought from the market.
But I am having 'ERC721: transfer caller is not owner nor approved' error. Is anyone having a similar issue? Thanks

    function createSecondarySaleForMarketItem(
          address nftContract,
          uint256 tokenId,
          uint256 price
    ) public payable nonReentrant {
    uint256 totalItemCount = _itemIds.current();
    require(price > 0, "Price must be at least 1 wei");
    require(
        msg.value == listingPrice,
        "Price must be equal to listing price"
    );

    //Find the item in the map first
    MarketItem memory item;
    uint256 itemId;
    for (uint256 i = 0; i < totalItemCount; i++) {
        if (idToMarketItem[i + 1].tokenId == tokenId) {
            item = idToMarketItem[i + 1];
            itemId = i + 1;
        }
    }

    //Update its attributes in the map
    idToMarketItem[itemId].price = price;
    idToMarketItem[itemId].seller = payable(msg.sender);
    idToMarketItem[itemId].owner = payable(address(0));
    idToMarketItem[itemId].sold = false;
    _itemsSold.decrement();

    //Transfer token from its owner to the contract
    IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
speldenaar profile image
speldenaar

npm run dev and opening localhost:3000 I receive this message

wait - compiling /_error (client and server)...
error - ./pages/index.js:4:0
Module not found: Can't resolve 'web3modal'
2 | import { useEffect, useState } from 'react'
3 | import axios from 'axios'

4 | import Web3Modal from "web3modal"
5 |
6 | import {
7 | nftaddress, nftmarketaddress

Collapse
 
dremind5000 profile image
DreMind5000

Hi everyone, After following this NFT course I’m stuck on the fact that there is no official way to allow reselling for users who have previously bought a NFT. I understand how to download the NFT to Metamask, but how can the user import the NFT on the “Mint Token” page with their NFT address?? Please help!!

Collapse
 
sottomarino profile image
simone ambrosi

I tried to deploy on github repository with vercel.com but I have 2 mistakes in the construction. Thank you in advance if anyone can give me a boost in rightdirection
1
Failed to compile.
./pages/create-item.js
Error: Parsing error: /vercel/path0/pages/create-item.js: Unexpected token, expected ","

2
error Command failed with exit code 1.
info Visit yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

Collapse
 
thapelo505 profile image
thapelo505

I'm trying to build a marketplace like opensea, does anyone know how I could alter the code to be able to facilitate categorizing the nft by type using the graph, and is ipfs able to render a 3d object directly into an html canvas?

Collapse
 
ssf profile image
Sione

Did you find a solution?

Collapse
 
ssf profile image
Sione

Hi!

Im getting 'ERC721: transfer caller is not owner nor approved' error after the second purchase of an item in the createMarketSale function in Market contract. Ive logged to see the owner of the token and it does show the right address so I dont know why it is showing this since the Market address has been approved in createToken function in NFT contract. Anyone else reproduce this? thanks for the help

Collapse
 
dannyiscra profile image
DannyIscra

Having this issue when I am on my Create NFT page. Once I click Create NFT, this message pops up

Error: invalid decimal value (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.6.2)

Any Solutions in the code.

All of my code is exactly up to date w the new version.

Collapse
 
vulong1706 profile image
vulong1706

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

Collapse
 
seemcat profile image
Maricris Bonzo • Edited

Ran into Could not fetch chain ID. Is your RPC URL correct? when trying to add the Mumbai TestNet network. So I decided to use the main Matic / Polygon network instead and it worked!

Collapse
 
thapelo505 profile image
thapelo505

please help

C:\Users\Monnosi\Music\typebeats\projects\digital-marketplace>npx hardhat node
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
 
rich1n profile image
Richard Rodrigues

Hey @dabit3 nice article but the NFT.sol is a JavaScript code (the same as pages/index.js)

Collapse
 
rich1n profile image
Richard Rodrigues

here's the code for NFT.sol

Collapse
 
dabit3 profile image
Nader Dabit

Hey, do you mind double checking that, it looks fine to me. I have noticed that Dev.to sometimes renders gist incorrectly, so wondering if you ran into that bug.

Thread Thread
 
dabit3 profile image
Nader Dabit

Just confirmed the bug: loom.com/share/c8d473bef6224087ac8...

Try refreshing the page. Reporting this now.

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

Collapse
 
ssf profile image
Sione

can you run through how to deploy the app and setting up environements for dev and production/staging etc please.

Collapse
 
prateekgeek profile image
prateekgeek

Unhandled Runtime Error
Error: No router instance found.
You should only use "next/router" on the client side of your app.

Any suggestions?

Collapse
 
sevantasci profile image
sevantasci

Hi , What happens if i store NFT's name and description in: MarketItem struct(Smart Contract), not in IPFS.Is it possible to do that and what are the negative sides?

Collapse
 
caruso33 profile image
Caruso

Is there any graph tutorial regarding the NFT marketplace out yet?

Collapse
 
illusioncode4 profile image
illusionCode4

please,i need help :Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')

Collapse
 
muneer_hashmat profile image
Muneer Hashmat🍁

hello bro. I'm facing the same problem. Did you find any solution?

Collapse
 
mosesibe profile image
moze

Thank you for this

Collapse
 
ponyjackal profile image
ponyjackal

This is nice

Recently I post a blog for be + sc validation based on EIP712

dev.to/ponyjackal/signature-verifi...

Collapse
 
capiflvcko profile image
capiflvcko

Was anybody able to successfully deploy to the mainnet?

Collapse
 
skhedaskar profile image
Shubham Khedaskar

guys how do i slove this error.
i have done everything right but when i click on sell...this pop-up im not able to understand what is happening please help me out

Collapse
 
adrian1980 profile image
NFT-project-test • Edited

Everything works fine in development..

But when i do npm run build && npm run export, and try and run the app with http-server, then i can't see NFT listed for sale.

Collapse
 
vulong1706 profile image
vulong1706

Image description
I have this problem with _app.js :((( can u guys help me

Collapse
 
arealclimber profile image
Lumii

Remove the in

Collapse
 
mochaoverchai profile image
Sakar

In your _app.js, replace 'Link' with 'Link legacyBehavior' in the function MyApp.

Collapse
 
farhadi profile image
Farhad Rahmani

when i want to create item that is not publishing in app because the etherium price is showing 0, how to fix this?

Collapse
 
srtkp2009 profile image
sarthak pujari

Invalid JSON-RPC response received: invalid project id

this is the error i get when i run
npx hardhat run scripts/deploy.js --network mumbai

Collapse
 
srtkp2009 profile image
sarthak pujari

i have checked the project id as well it is correct

Collapse
 
farhadi profile image
Farhad Rahmani

Thank you dear Sir but can i make it this in React JS?

Collapse
 
csellis profile image
Chris Ellis

It looks like Infura requires an account for the IPFS now

Collapse
 
lot8 profile image
lot8

Hi,
Thank u for the nice Project! Everything works fine, but pages/my-assets.... syntax error: unexpected token (1:0) Any ideas?

Collapse
 
lot8 profile image
lot8

Fixed it : / pages/my-assets.js */ to / pages/my-assets.js */ :)

Collapse
 
nan141979 profile image
Skrillx

How can I program to pay with some other erc 20 token besides eth?

Collapse
 
nan141979 profile image
Skrillx • Edited

Hey I'm trying to deploy to ropsten's network and I get this error:
dev-to-uploads.s3.amazonaws.com/up...

where am I going wrong?

Collapse
 
leewynne profile image
Lee Wynne

This is bloody incredible, fancy a cross post on an NFT based Forem?

MetaPunk

Collapse
 
johnfrades profile image
John Frades • Edited

The v2 update cannot upload picture

Collapse
 
lgs profile image
Luca G. Soave • Edited

Super !!!

For the future, why not SvelteKit instead of Next.js ?

Collapse
 
dabit3 profile image
Nader Dabit

No huge reason really other than that I am already really experienced with Next.js. Will try using SvelteKit next time :)

Collapse
 
vorcigernix profile image
Adam Sobotka

Nice article, thanks. I am getting
reason: 'could not detect network',
code: 'NETWORK_ERROR',
event: 'noNetwork',
when I try to deploy to mumbai. Any idea what could be wrong?

Collapse
 
vorcigernix profile image
Adam Sobotka • Edited

Also getting a weird metamask RPC errors, like
message: "NetworkError when attempting to fetch resource." or similar with empty message. I found some related reports, could be caused by some metamask/firefox combination. Weird is that it works fine on localhost. Could be some Matic issue? Also tried to switch to infura RPC, didn't help. Any idea what can I try?

Collapse
 
johnrigler profile image
John Rigler

I had to change to this network: matic-mumbai.chainstacklabs.com

Collapse
 
latonet profile image
latonet

Anyone know how I can:

  1. make the images in marketplace all the same size, as at the moment it shows images in full size.
  2. make each image (or NFT) link to a details page.

Thanks

Collapse
 
tawseef profile image
tawseef nabi

thanks @dabit3 awesome tutorial

Collapse
 
meekaphro profile image
Quentin

learned so much, thanks for this

Collapse
 
chelseaschnider profile image
Chelsea Schnider

Hi! I have this error when clicking create nft button

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'length')

Any help would be awesome

Collapse
 
muneer_hashmat profile image
Muneer Hashmat🍁

hello bro. I'm facing the same problem. Did you find any solution?

Collapse
 
bhakti087 profile image
Bhakti Ghude

create digital asset btn is not working

Collapse
 
v41bh4v profile image
Vaibhav Tiwari

Hi folks,
HardhatError: HH700: Artifact for contract "NFT" not found.
while running : npx hardhat test

Collapse
 
duytoannn profile image
Duy Toan • Edited

Image description

Has anyone when sell nft received the following error?


Enter fullscreen mode Exit fullscreen mode
Collapse
 
ramsir011 profile image
ramsir011

I am facing this problem. Anyone know the solution?
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.5.1)

Collapse
 
colinr98 profile image
Colin Rogers

Running into the same issue.
So far this is working:

npm install pm2 -g

source (random article I found): githubmate.com/repo/ericet/claysta...

Collapse
 
latonet profile image
latonet

Got this error now in create-item.js .....

ReferenceError: createItem is not defined

button onClick={createItem} className="font-bold mt-4 bg-green-500 text-white rounded p-4 shadow-lg"

Collapse
 
mcmaurok profile image
mcmaurok

How would like to display the 'description' and 'name' data after creating an NFT and display it under 'Creator dashboard' and 'My assets'

Collapse
 
rakveli profile image
rakveli

Hello thanks for this,

please i am having issues uploading to my server, couldnt not run npm install successfully on cpanel nodejs app set up

Collapse
 
rakveli profile image
rakveli • Edited

Hello thanks for this,

please i am having issues uploading to my server, couldnt not run npm install successfully on cpanel nodejs app set up

Collapse
 
turbowarsftw profile image
👑 Dheeraj

Ran into an error on sample test
HardhatError: HH700: Artifact for contract "NFTMarket" not found.

Collapse
 
v41bh4v profile image
Vaibhav Tiwari

Hi , What is the solution? Ran into same problem

Collapse
 
the4duvar profile image
Rojhat Birel

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

Collapse
 
mfaiqkhan3 profile image
Faiq Khan

what's the difference in V2 and V1(youtube video)?

Collapse
 
mfaiqkhan3 profile image
Faiq Khan

Hi, What's the difference between V1(Youtube) and V2(2022) ??

Collapse
 
igorroman777 profile image
Igor Roman

Hey,
the following method is clear to me:
const data = await contract.fetchMarketItems();

But how do I find only one item for Id, e.g.:
const data = await contract.fetchMarketItem(identId);

Collapse
 
frejandreassen profile image
Frej Andreassen

Thank you for a great tutorial!

Collapse
 
bellomi profile image
Lívia Bellomi

Is it possible to create all this in a Mobile environment instead of web?

Collapse
 
liniukesi profile image
Kevin

nice, works fine on my computer, thansk very much

Collapse
 
codewitheric profile image
Izuchukwu Onukwube • Edited

Hi everyone... i'm getting this error when i try to load the "create-item" page, would appreciate any help from anyone
Server Error
TypeError: Agent is not a constructor

Collapse
 
m0nkey_d_luf7y profile image
MUGIWARA

here is the other error i'm getting
dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
mhaa72 profile image
Mhaa72

404 This page could not be found.
when clicking on SellNFT button I am receiving the above error. Please let me know if anyone has idea why I'm getting this error!!

Collapse
 
lowk profile image
LowK

Thanks for your tutorial. it help me understand web3. But I just suggest a problem. Please split each feature and analyze it, don't paste all codes to page. Because I don't know what is flow?

Collapse
 
mokuaomae254 profile image
robert mokua omae obare

hello guys have been stuck for days trying to fix this
Image description

Collapse
 
dvlazarev451 profile image
dvlazarev451

Sorry if it might seem to be a stupid question, but I'm quite new to codig, so... If there is a possibility to upload audio and video files?

Collapse
 
vvronskyfx profile image
Vladlen Vronsky

This is dope! Can we use the same fronend to build on Solana?

Collapse
 
cryptodammiee profile image
dammiee.eth

I m still facing issue with IPSF QmQHYxQppDaaDGjVJ8tfi5XQJvWKRg6f1MXYyvnsP7uS4U:1 GET ipfs.infura.io/ipfs/api/v0/QmQHYxQ... 400 (Bad Request)

Collapse
 
mochaoverchai profile image
Sakar

Me too!
Hey @dabit3 can you please guide us?

Collapse
 
kingjulien profile image
Abusomwan Santos

hey every one I'm having this error, when I try to create nft
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'length')

Collapse
 
inwbas12345 profile image
inwbas12345

I'm not sure where I went wrong.
Image description

Collapse
 
mochaoverchai profile image
Sakar

Update your create-nft.js file as mentioned below -

/* pages/create-nft.js */
import { useState } from 'react'
import { ethers } from 'ethers'
import { create as ipfsHttpClient } from 'ipfs-http-client'
import { useRouter } from 'next/router'
import Web3Modal from 'web3modal'

const projectId = process.env.INFURA_IPFS_PROJECT_ID;
const projectSecret = process.env.INFURA_IPFS_PROJECT_SECRET;
const projectIdAndSecret = ${projectId}:${projectSecret}

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

const authorization = "Basics" + btoa(projectId + ":" + projectSecret);

import {
marketplaceAddress
} from '../config'

import NFTMarketplace from '../artifacts/contracts/NFTMarketplace.sol/NFTMarketplace.json'
import { Bytecode } from 'hardhat/internal/hardhat-network/stack-traces/model'
import { notEqual } from 'assert'

export default function CreateItem() {
const [fileUrl, setFileUrl] = useState([null])
const [formInput, updateFormInput] = useState({ price: '', name: '', description: '' })
const router = useRouter()

async function onChange(e) {
/* upload image to IPFS */
const file = e.target.files[0]
try {
const added = await client.add(
file,
{
progress: (prog) => console.log(received: ${prog}),
}
)
const url = https://ipfs.infura.io/ipfs/${added.path}

  client.pin.add(added.path).then((res) => {
    console.log(res)
    setFileUrl(url)
})
} catch (error) {
  console.log('Error uploading file: ', error)
}  
Enter fullscreen mode Exit fullscreen mode

}
async function uploadToIPFS() {
const { name, description, price } = formInput
if (!name || !description || !price || !fileUrl) return
/* first, upload metadata to IPFS /
const data = JSON.stringify({
name, description, image: fileUrl
})
try {
const added = await client.add(data)
const url = https://ipfs.infura.io/ipfs/${added.path}
/
after metadata is uploaded to IPFS, return the URL to use it in the transaction */
return url
} catch (error) {
console.log('Error uploading file: ', error)
}

}

async function listNFTForSale() {
const url = await uploadToIPFS()
const web3Modal = new Web3Modal()
const connection = await web3Modal.connect()
const provider = new ethers.providers.Web3Provider(connection)
const signer = provider.getSigner()

/* create the NFT */
const price = ethers.utils.parseUnits(formInput.price, 'ether')
let contract = new ethers.Contract(marketplaceAddress, NFTMarketplace.abi, signer)
let listingPrice = await contract.getListingPrice()
listingPrice = listingPrice.toString()
let transaction = await contract.createToken(url, price, { value: listingPrice })
await transaction.wait()

router.push('/')
Enter fullscreen mode Exit fullscreen mode

}

return (




      placeholder="Asset Name"<br>
      className="mt-8 border rounded p-4"<br>
      onChange={e =&gt; updateFormInput({ ...formInput, name: e.target.value })}<br>
    /&gt;<br>

      placeholder="Asset Description"<br>
      className="mt-2 border rounded p-4"<br>
      onChange={e =&gt; updateFormInput({ ...formInput, description: e.target.value })}<br>
    /&gt;<br>

      placeholder="Asset Price in Eth"<br>
      className="mt-2 border rounded p-4"<br>
      onChange={e =&gt; updateFormInput({ ...formInput, price: e.target.value })}<br>
    /&gt;<br>

      type="file"<br>
      name="Asset"<br>
      className="my-4"<br>
      onChange={onChange}<br>
    /&gt;<br>
    {<br>
      fileUrl &amp;&amp; (<br>
        <img src="%7BfileUrl%7D"><br>
      )<br>
    }<br>
    <br>
      Create NFT<br>
    <br>
  <br>
<br>
Enter fullscreen mode Exit fullscreen mode

)

}

Collapse
 
matt_mccoy_b4e88f9c7a0587 profile image
Matt McCoy

Is this marketplace something like developed digital twin of a real one?

Collapse
 
sottomarino profile image
simone ambrosi

Hello everyone.

I tried deploy on repositories github with vercel.com but I get erroere in building.
Thank you in advance if anyone can give me a boost in rightdirection.

Collapse
 
sottomarino profile image
simone ambrosi

Failed to compile.
Error: Parsing error: /vercel/path0/pages/create-item.js: Unexpected token, expected ","


error Command failed with exit code 1.
info Visit yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1

Collapse
 
mmukulkumar profile image
mmukulkumar • Edited

how to proceed through this errors

Collapse
 
mansoob profile image
Sayyid Mansoob Hasan

I am having Unhandled Runtime Error while creating NFT
TypeError: str is undefined

Please guide.

Collapse
 
huudyy profile image
PabloHoudini

Hi, I was wondering if deploying to Solana would be just changing the url in hardhat.config? @dabit3 : any idea if solana mainnet open for developers?

Collapse
 
priyexh profile image
Priyesh Gohil

After deploying node, Im getting this error

Collapse
 
toussaint7 profile image
TOUSSAINT7 • Edited

GREETINGS, I HAVE A PROBLEM HERE MY STYLING SEEMS NOT TO BE WORKING ANYBODY HELP

Collapse
 
toussaint7 profile image
TOUSSAINT7

PLEASE HELP MY STYLING IS NOT WORKING ⚒

Collapse
 
gayatribit profile image
Gayatri Barhate • Edited

I got an unhandled Runtime Error
Error : User Rejected
Can anyone tell me what to do ?
Image description

Collapse
 
mochaoverchai profile image
Sakar

Connect your Metamask to your localhost. If you haven't signed in to your Metamask account, this error shows up.

Collapse
 
cyberstorm2007 profile image
cyberstorm2007

Looks good!

Collapse
 
marc_nahas profile image
Marc Nahas

Hi Nader,
This content is amazing but I keep having the following error and I don't get how to fix it.
Thank you forward for your help :)
Have a good day !

Collapse
 
m0nkey_d_luf7y profile image
MUGIWARA

im getting this error !! help !!

Collapse
 
deborahquarksalchemist profile image
Deborah Sanchez • Edited

Hi there! When using the input to upload the image I keep getting this from the server: basic auth failure: invalid project id or project secret

any ideas?

Collapse
 
anushkasankhe profile image
Anushka Sankhe

Hey I am having trouble with the config.js file
The export command seems to be part of the es6 module and node.js is referencing commonjs module. Please let me know how to solve this.

Collapse
 
anushkasankhe profile image
Anushka Sankhe • Edited

Hey I am having trouble with the config.js file
The export command seems to be part of the es6 module and node.js is referencing commonjs module. Please let me know how to solve this.

Collapse
 
shivamdeshmukh21 profile image
ShivamDeshmukh21 • Edited

Hey community, I'm new to front end development so if any of you could share your github repo for this project with a good looking UI, it would mean a lot! Please I need this for college😬