Opensea clone CreateMarketItem in database won't populate

Hey Guys
I’m doing the Opensea Marketplace clone and I’ve gotten the approve and list buttons working for Mumbai testnet. The only thing that doesn’t work is after i approve and list a NFT on Mumbai, the CreateMarketItem table in the Moralis database doesn’t populate with the market item that was created. I have the same problem with the transactions section of the Dapp. I don’t have any transaction history after I approve and list a NFT.
I have deleted the sync and watch contract events in my Moralis server and i re added it again. That hasn’t solved my problem. Has anyone come across this while cloning the marketplace?
Thanks in advance :slight_smile:
Link to my Github Repo

What is your Mumbai contract address? Check it on https://mumbai.polygonscan.com to make sure you have a market items event(s).

Hey @glad
Are these the events you are talking about? it says 12 days ago which surely wasn’t me.
Cheers

@johnversus Have you seen this with this Marketplace?

Hey guys
I’m still stuck trying to fix this opportunity and I’ve double checked my sync and watch contract events. Is there another reason why my CreateMarketItems class won’t populate in the Moralis database? I’m having trouble finding anyone that’s had the same issue.
Cheers

What is your marketplace contract address, the one that you’ve deployed? You need to check if you’re getting MarketItem events first when you list. When that happens and you’ve created a correct sync for that event + contract, your server will start to get the populated data.

1 Like

Hey @glad
0x2dC879Ce98Fc40830A2D4392e40088943D7a9179
This is my marketplace contract address. I now have 1 item in the CreateMarketItem class in my database but when I’m on my Dapp my polygon NFT in my collection won’t load. Is this because it is on the market? How do i see it because I don’t have anything in the transactions section of the Dapp.


@glad
I’m going to buy some more polygon NFTs to see if I can fix this opportunity.

That page will get any data from the class used for the event sync, it looks like you need to change the code in NFTMarketTransactions.jsx so the table name matches (you’re using CreateMarketItem but the default code is using MarketItems as the name).

@glad
Yes Thank you, I changed that and both the CreatemarketItems class and MarketItems class are populating. the transaction section of the Dapp now has transaction history aswell. :slight_smile:
I’m just trying to buy some more Polygon nfts to keep testing and make sure it everything works great.
I’m struggling with swapping my MATIC testnet tokens to Wrapped Matic testnet tokens. Is there a different way to doing it through Metamask because my wallet says swapping isn’t supported on Mumbai testnet?
Cheers

How are you doing this swap? Can you screenshot this MetaMask message?

Swapping can be done at the contract level e.g. on the wMATIC contract (deposit function).

Hi @glad
I was able to sort out the swapping by going to Uni swap.
I’m trying to sort out the issue with the NFT images not fetching correctly. I have this opportunity with a few of the collections on the Ethereum mainnet and also with the collections I’m adding to the Mumbai testnet. I get a net::ERR_CERT_AUTHORITY_INVALID error in the console.
Appreciate the help, means alot.
Cheers

Can you post one of those IPFS links here. You may need to use a different gateway e.g. https://gateway.moralisipfs.com/ipfs/cidhere.

@glad
I’m getting a 504 Gateway Time-out. I was trying to load the data by putting the tokenId and Tokenaddress into the search bar and searching. Am I missing something in the search bar?
Cheers


You can try a different gateway as I mentioned. ipfs.io is typically very slow because it is the most commonly used public gateway.

The second error means it can’t find your IPFS CID/hash at that path of 18.

What do you mean by search bar? You get the IPFS links directly from the NFT data.

Ok @glad
when I said search bar i meant am I missing anything where the URL goes sorry lol. My NFTs stopped listing all of a sudden. I get no error in the console but I get a failed transaction. I’ve got the market addresses all the same now so I’m not sure why it has stopped listing NFTs. Could it be my other market address i was using before that gave it a successful transaction? Can i deploy 2 contracts or should i add another sync and event contract with the old market address?

Not sure, you can check your transaction hashes for the contract address that it interacted with. Don’t use the old market address, just use your existing one. A sync for an event should be on the contract address you’re using now on the chain you’re working with.

Ok @glad
Ill get rid of the old market address.
Ill check my sync and event contracts.
Cheers

Hey @glad
When i created the sync and event contract with the new market address, I get invalid Abi. I’ve pasted the Abi i thought was correct for the sync and event contract. Can you please tell me what I have done wrong :slight_smile:
Thanks in advance.

Abi from syn and event contract

{
		"anonymous": false,
		"inputs": [
			{
				"indexed": true,
				"internalType": "uint256",
				"name": "itemId",
				"type": "uint256"
			},
			{
				"indexed": true,
				"internalType": "address",
				"name": "nftContract",
				"type": "address"
			},
			{
				"indexed": true,
				"internalType": "uint256",
				"name": "tokenId",
				"type": "uint256"
			},
			{
				"indexed": false,
				"internalType": "address",
				"name": "seller",
				"type": "address"
			},
			{
				"indexed": false,
				"internalType": "address",
				"name": "owner",
				"type": "address"
			},
			{
				"indexed": false,
				"internalType": "uint256",
				"name": "price",
				"type": "uint256"
			},
			{
				"indexed": false,
				"internalType": "bool",
				"name": "sold",
				"type": "bool"
			}
		],
		"name": "MarketItemCreated",
		"type": "event"
	},

Abi

[
	{
		"inputs": [
			{
				"internalType": "address",
				"name": "nftContract",
				"type": "address"
			},
			{
				"internalType": "uint256",
				"name": "tokenId",
				"type": "uint256"
			},
			{
				"internalType": "uint256",
				"name": "price",
				"type": "uint256"
			}
		],
		"name": "createMarketItem",
		"outputs": [],
		"stateMutability": "payable",
		"type": "function"
	},
	{
		"inputs": [
			{
				"internalType": "address",
				"name": "nftContract",
				"type": "address"
			},
			{
				"internalType": "uint256",
				"name": "itemId",
				"type": "uint256"
			}
		],
		"name": "createMarketSale",
		"outputs": [],
		"stateMutability": "payable",
		"type": "function"
	},
	{
		"inputs": [],
		"stateMutability": "nonpayable",
		"type": "constructor"
	},
	{
		"anonymous": false,
		"inputs": [
			{
				"indexed": true,
				"internalType": "uint256",
				"name": "itemId",
				"type": "uint256"
			},
			{
				"indexed": true,
				"internalType": "address",
				"name": "nftContract",
				"type": "address"
			},
			{
				"indexed": true,
				"internalType": "uint256",
				"name": "tokenId",
				"type": "uint256"
			},
			{
				"indexed": false,
				"internalType": "address",
				"name": "seller",
				"type": "address"
			},
			{
				"indexed": false,
				"internalType": "address",
				"name": "owner",
				"type": "address"
			},
			{
				"indexed": false,
				"internalType": "uint256",
				"name": "price",
				"type": "uint256"
			},
			{
				"indexed": false,
				"internalType": "bool",
				"name": "sold",
				"type": "bool"
			}
		],
		"name": "MarketItemCreated",
		"type": "event"
	},
	{
		"anonymous": false,
		"inputs": [
			{
				"indexed": true,
				"internalType": "uint256",
				"name": "itemId",
				"type": "uint256"
			},
			{
				"indexed": false,
				"internalType": "address",
				"name": "owner",
				"type": "address"
			}
		],
		"name": "MarketItemSold",
		"type": "event"
	},
	{
		"inputs": [],
		"name": "fetchMarketItems",
		"outputs": [
			{
				"components": [
					{
						"internalType": "uint256",
						"name": "itemId",
						"type": "uint256"
					},
					{
						"internalType": "address",
						"name": "nftContract",
						"type": "address"
					},
					{
						"internalType": "uint256",
						"name": "tokenId",
						"type": "uint256"
					},
					{
						"internalType": "address payable",
						"name": "seller",
						"type": "address"
					},
					{
						"internalType": "address payable",
						"name": "owner",
						"type": "address"
					},
					{
						"internalType": "uint256",
						"name": "price",
						"type": "uint256"
					},
					{
						"internalType": "bool",
						"name": "sold",
						"type": "bool"
					}
				],
				"internalType": "struct marketPlaceBoilerPlate.MarketItem[]",
				"name": "",
				"type": "tuple[]"
			}
		],
		"stateMutability": "view",
		"type": "function"
	},
	{
		"inputs": [],
		"name": "owner",
		"outputs": [
			{
				"internalType": "address",
				"name": "",
				"type": "address"
			}
		],
		"stateMutability": "view",
		"type": "function"
	}
]

I fixed the Abi lol :slight_smile: