NFT's wont list on marketplace or add into the database

This is not a contract address
https://rinkeby.etherscan.io/address/0xb94bb1b53ab68465cEB10b89E3B67Eae2Db003BA

When i tried it gave me an error saying MetaMask - RPC Error: TxGasUtil - Trying to call a function on a non-contract address

This is how i am calling.

await marketplaceContract.methods.addItemToMarket(1, "0x99495223da7dFE1A14d5224Bc90bad4a01F0e58A", 1).send({ from: "AddYourWalletAddressHere" }, function (err, res) {
  if (err) {
    console.log("An error occurred", err)
    return
  }
  console.log("Result: ", res)
})
1 Like

I think you might of put the token contract address when calling instead of my marketplace contract.
My marketplace contract is 0xb94bb1b53ab68465cEB10b89E3B67Eae2Db003BA. Does this change the outcome when you call it?

oh wait, i think i checked on rinkeby chain

This function has OnlyItemOwner and HasTransferApproval modifiers. Do you meet these conditions? The error could be from these modifiers

Yes I do meet these conditions.
I have corrected the addItemsToMarket function to addItemToMarket.

I tested again by deploying a new NFT contract and marketplace contract. The error is only happening from these modifiers.

modifier OnlyItemOwner(address tokenAddress, uint256 tokenId){
        IERC721 tokenContract = IERC721(tokenAddress);
        require(tokenContract.ownerOf(tokenId) == msg.sender);
        _;
    }
     modifier HasTransferApproval(address tokenAddress, uint256 tokenId) {
        IERC721 tokenContract = IERC721(tokenAddress);
        require(tokenContract.getApproved(tokenId) == address(this));
        _;
    }

Verify again if the modifier conditions are met.
getApproved(tokenId) should be equal to the marketplace contract and ownerOf(tokenId) should be equal to the wallet from which you are calling the function.

Ok Thank you
ill check them now

Hi John
I’ve checked if the conditions are met with those 2 modifiers and they have been but I still continue to get the EVM error. Is there anything else that stuck out to you?
Cheers

Could it be what is calling the modifiers?

Hey John
I’ve fixed the EVM issue now and can add items to the marketplace with no errors.
My next issue is the ItemsForSale wont populate in the database.
I’m thinking this is a Cloud function issue?
Cheeers

Hi
I have fixed the issue with ItemsForSale in the database.
Cheers