Cloning OpenSea NFT Boilerplate Questions

I see from demo site ( https://ethereum-boilerplate.github.io/ethereum-boilerplate ) and I want to using it in my project, hope someone can talk about it.

I think I will be go to another post for this lmao, thanks anyway

@IAmJaysWay hey there
i am currently following along with the tutorial but have run into an error


Could anyone who sees this tell me what have i done wrong here ?
Thanks in advance

part 2 of the doubt (this is where i have pasted the cryptopunks addr from etherscan)

How could I go about receiving NFTs on the Mumbai test net?

I tried Copying some of the NFT collections to the ropsten network but it doesnt any of the NFTs . Could someone help me out here ?

did u get ur doubt solved ? im facing the same issue…
i was wondering if u could help me

I created an account just to thank you for this - you absolute legend.

1 Like

Hey I appreciate it, that made my day haha

1 Like

I have seen the complete tutorial of nft marketplace and I want to make it now. but the source code of the smart contract showing in the video is not given in the description. can anyone give me the source code of the smart contract?

Here you go;

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol";

contract marketPlaceBoilerPlate is ReentrancyGuard {
    using Counters for Counters.Counter;
    Counters.Counter private _itemIds;
    Counters.Counter private _itemsSold;
    
     address public owner;
     
     constructor() {
         owner = msg.sender;
     }
     
     struct MarketItem {
         uint itemId;
         address nftContract;
         uint256 tokenId;
         address payable seller;
         address payable owner;
         uint256 price;
         bool sold;
     }
     
     mapping(uint256 => MarketItem) private idToMarketItem;
     
     event MarketItemCreated (
        uint indexed itemId,
        address indexed nftContract,
        uint256 indexed tokenId,
        address seller,
        address owner,
        uint256 price,
        bool sold
     );
     
     event MarketItemSold (
         uint indexed itemId,
         address owner
         );
     
    
    
    function createMarketItem(
        address nftContract,
        uint256 tokenId,
        uint256 price
        ) public payable nonReentrant {
            require(price > 0, "Price must be greater than 0");
            
            _itemIds.increment();
            uint256 itemId = _itemIds.current();
  
            idToMarketItem[itemId] =  MarketItem(
                itemId,
                nftContract,
                tokenId,
                payable(msg.sender),
                payable(address(0)),
                price,
                false
            );
            
            IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);
                
            emit MarketItemCreated(
                itemId,
                nftContract,
                tokenId,
                msg.sender,
                address(0),
                price,
                false
            );
        }
        
    function createMarketSale(
        address nftContract,
        uint256 itemId
        ) public payable nonReentrant {
            uint price = idToMarketItem[itemId].price;
            uint tokenId = idToMarketItem[itemId].tokenId;
            bool sold = idToMarketItem[itemId].sold;
            require(msg.value == price, "Please submit the asking price in order to complete the purchase");
            require(sold != true, "This Sale has alredy finnished");
            emit MarketItemSold(
                itemId,
                msg.sender
                );

            idToMarketItem[itemId].seller.transfer(msg.value);
            IERC721(nftContract).transferFrom(address(this), msg.sender, tokenId);
            idToMarketItem[itemId].owner = payable(msg.sender);
            _itemsSold.increment();
            idToMarketItem[itemId].sold = true;
        }
        
    function fetchMarketItems() public view returns (MarketItem[] memory) {
        uint itemCount = _itemIds.current();
        uint unsoldItemCount = _itemIds.current() - _itemsSold.current();
        uint currentIndex = 0;

        MarketItem[] memory items = new MarketItem[](unsoldItemCount);
        for (uint i = 0; i < itemCount; i++) {
            if (idToMarketItem[i + 1].owner == address(0)) {
                uint currentId = i + 1;
                MarketItem storage currentItem = idToMarketItem[currentId];
                items[currentIndex] = currentItem;
                currentIndex += 1;
            }
        }
        return items;
    }
      
}

Thanks bro
It will help me lot

when i run yarn start:

 
 :  Delete `␍`  prettier/prettier
  Line 68:35:  Delete `␍`  prettier/prettier
  Line 69:27:  Delete `␍`  prettier/prettier
  Line 70:35:  Delete `␍`  prettier/prettier
  Line 71:20:  Delete `␍`  prettier/prettier
  Line 72:51:  Delete `␍`  prettier/prettier
  Line 73:19:  Delete `␍`  prettier/prettier
  Line 74:8:   Delete `␍`  prettier/prettier
  Line 75:4:   Delete `␍`  prettier/prettier
  Line 76:1:   Delete `␍`  prettier/prettier
  Line 77:43:  Delete `␍`  prettier/prettier
  Line 78:3:   Delete `␍`  prettier/prettier
  Line 79:1:   Delete `␍`  prettier/prettier
  Line 80:27:  Delete `␍`  prettier/prettier

src\hooks\useVerifyMetadata.js
  Line 1:34:    Delete `␍`  prettier/prettier
  Line 2:37:    Delete `␍`  prettier/prettier
  Line 3:1:     Delete `␍`  prettier/prettier
  Line 4:4:     Delete `␍`  prettier/prettier
  Line 5:78:    Delete `␍`  prettier/prettier
  Line 6:119:   Delete `␍`  prettier/prettier
  Line 7:75:    Delete `␍`  prettier/prettier
  Line 8:4:     Delete `␍`  prettier/prettier
  Line 9:41:    Delete `␍`  prettier/prettier
  Line 10:37:   Delete `␍`  prettier/prettier
  Line 11:46:   Delete `␍`  prettier/prettier
  Line 12:1:    Delete `␍`  prettier/prettier
  Line 13:6:    Delete `␍`  prettier/prettier
  Line 14:46:   Delete `␍`  prettier/prettier
  Line 15:25:   Delete `␍`  prettier/prettier
  Line 16:18:   Delete `␍`  prettier/prettier
  Line 17:6:    Delete `␍`  prettier/prettier
  Line 18:33:   Delete `␍`  prettier/prettier
  Line 19:47:   Delete `␍`  prettier/prettier
  Line 20:34:   Delete `␍`  prettier/prettier
  Line 21:23:   Delete `␍`  prettier/prettier
  Line 22:22:   Delete `␍`  prettier/prettier
  Line 23:31:   Delete `␍`  prettier/prettier
  Line 24:70:   Delete `␍`  prettier/prettier
  Line 25:23:   Delete `␍`  prettier/prettier
  Line 26:1:    Delete `␍`  prettier/prettier
  Line 27:6:    Delete `␍`  prettier/prettier
  Line 28:32:   Delete `␍`  prettier/prettier
  Line 29:31:   Delete `␍`  prettier/prettier
  Line 30:25:   Delete `␍`  prettier/prettier
  Line 31:19:   Delete `␍`  prettier/prettier
  Line 32:6:    Delete `␍`  prettier/prettier
  Line 33:36:   Delete `␍`  prettier/prettier
  Line 34:19:   Delete `␍`  prettier/prettier
  Line 35:60:   Delete `␍`  prettier/prettier
  Line 36:77:   Delete `␍`  prettier/prettier
  Line 37:14:   Delete `␍`  prettier/prettier
  Line 38:6:    Delete `␍`  prettier/prettier
  Line 39:19:   Delete `␍`  prettier/prettier
  Line 40:25:   Delete `␍`  prettier/prettier
  Line 41:33:   Delete `␍`  prettier/prettier
  Line 42:28:   Delete `␍`  prettier/prettier
  Line 43:25:   Delete `␍`  prettier/prettier
  Line 44:16:   Delete `␍`  prettier/prettier
  Line 45:25:   Delete `␍`  prettier/prettier
  Line 46:73:   Delete `␍`  prettier/prettier
  Line 47:41:   Delete `␍`  prettier/prettier
  Line 48:13:   Delete `␍`  prettier/prettier
  Line 49:10:   Delete `␍`  prettier/prettier
  Line 50:26:   Delete `␍`  prettier/prettier
  Line 51:18:   Delete `␍`  prettier/prettier
  Line 52:30:   Delete `␍`  prettier/prettier
  Line 53:60:   Delete `␍`  prettier/prettier
  Line 54:12:   Delete `␍`  prettier/prettier
  Line 55:16:   Delete `␍`  prettier/prettier
  Line 56:24:   Delete `␍`  prettier/prettier
  Line 57:64:   Delete `␍`  prettier/prettier
  Line 58:30:   Delete `␍`  prettier/prettier
  Line 59:36:   Delete `␍`  prettier/prettier
  Line 60:35:   Delete `␍`  prettier/prettier
  Line 61:13:   Delete `␍`  prettier/prettier
  Line 62:38:   Delete `␍`  prettier/prettier
  Line 63:35:   Delete `␍`  prettier/prettier
  Line 64:30:   Delete `␍`  prettier/prettier
  Line 65:20:   Delete `␍`  prettier/prettier
  Line 66:96:   Delete `␍`  prettier/prettier
  Line 67:15:   Delete `␍`  prettier/prettier
  Line 68:22:   Delete `␍`  prettier/prettier
  Line 69:16:   Delete `␍`  prettier/prettier
  Line 70:38:   Delete `␍`  prettier/prettier
  Line 71:16:   Delete `␍`  prettier/prettier
  Line 72:23:   Delete `␍`  prettier/prettier
  Line 73:73:   Delete `␍`  prettier/prettier
  Line 74:26:   Delete `␍`  prettier/prettier
  Line 75:13:   Delete `␍`  prettier/prettier
  Line 76:25:   Delete `␍`  prettier/prettier
  Line 77:9:    Delete `␍`  prettier/prettier
  Line 78:24:   Delete `␍`  prettier/prettier
  Line 79:73:   Delete `␍`  prettier/prettier
  Line 80:15:   Delete `␍`  prettier/prettier
  Line 81:15:   Delete `␍`  prettier/prettier
  Line 82:30:   Delete `␍`  prettier/prettier
  Line 83:12:   Delete `␍`  prettier/prettier
  Line 84:10:   Delete `␍`  prettier/prettier
  Line 85:20:   Delete `␍`  prettier/prettier
  Line 86:1:    Delete `␍`  prettier/prettier
  Line 87:6:    Delete `␍`  prettier/prettier
  Line 88:23:   Delete `␍`  prettier/prettier
  Line 89:25:   Delete `␍`  prettier/prettier
  Line 90:30:   Delete `␍`  prettier/prettier
  Line 91:6:    Delete `␍`  prettier/prettier
  Line 92:40:   Delete `␍`  prettier/prettier
  Line 93:19:   Delete `␍`  prettier/prettier
  Line 94:29:   Delete `␍`  prettier/prettier
  Line 95:16:   Delete `␍`  prettier/prettier
  Line 96:66:   Delete `␍`  prettier/prettier
  Line 97:19:   Delete `␍`  prettier/prettier
  Line 98:45:   Delete `␍`  prettier/prettier
  Line 99:56:   Delete `␍`  prettier/prettier
  Line 100:20:  Delete `␍`  prettier/prettier
  Line 101:1:   Delete `␍`  prettier/prettier
  Line 102:29:  Delete `␍`  prettier/prettier
  Line 103:25:  Delete `␍`  prettier/prettier

src\index.js
  Line 1:43:   Delete `␍`  prettier/prettier
  Line 2:34:   Delete `␍`  prettier/prettier
  Line 3:25:   Delete `␍`  prettier/prettier
  Line 4:49:   Delete `␍`  prettier/prettier
  Line 5:22:   Delete `␍`  prettier/prettier
  Line 6:74:   Delete `␍`  prettier/prettier
  Line 7:48:   Delete `␍`  prettier/prettier
  Line 8:1:    Delete `␍`  prettier/prettier
  Line 9:57:   Delete `␍`  prettier/prettier
  Line 10:1:   Delete `␍`  prettier/prettier
  Line 11:61:  Delete `␍`  prettier/prettier
  Line 12:61:  Delete `␍`  prettier/prettier
  Line 13:1:   Delete `␍`  prettier/prettier
  Line 14:28:  Delete `␍`  prettier/prettier
  Line 15:60:  Delete `␍`  prettier/prettier
  Line 16:13:  Delete `␍`  prettier/prettier
  Line 17:30:  Delete `␍`  prettier/prettier
  Line 18:21:  Delete `␍`  prettier/prettier
  Line 19:88:  Delete `␍`  prettier/prettier
  Line 20:7:   Delete `␍`  prettier/prettier
  Line 21:20:  Delete `␍`  prettier/prettier
  Line 22:13:  Delete `␍`  prettier/prettier
  Line 23:62:  Delete `␍`  prettier/prettier
  Line 24:29:  Delete `␍`  prettier/prettier
  Line 25:25:  Delete `␍`  prettier/prettier
  Line 26:7:   Delete `␍`  prettier/prettier
  Line 27:9:   Delete `␍`  prettier/prettier
  Line 28:13:  Delete `␍`  prettier/prettier
  Line 29:66:  Delete `␍`  prettier/prettier
  Line 30:23:  Delete `␍`  prettier/prettier
  Line 31:13:  Delete `␍`  prettier/prettier
  Line 32:7:   Delete `␍`  prettier/prettier
  Line 33:4:   Delete `␍`  prettier/prettier
  Line 34:3:   Delete `␍`  prettier/prettier
  Line 35:1:   Delete `␍`  prettier/prettier
  Line 36:17:  Delete `␍`  prettier/prettier
  Line 37:15:  Delete `␍`  prettier/prettier
  Line 38:20:  Delete `␍`  prettier/prettier
  Line 39:17:  Delete `␍`  prettier/prettier
  Line 40:35:  Delete `␍`  prettier/prettier
  Line 41:3:   Delete `␍`  prettier/prettier
  Line 42:1:   Delete `␍`  prettier/prettier
  Line 43:72:  Delete `␍`  prettier/prettier
  Line 44:73:  Delete `␍`  prettier/prettier
  Line 45:58:  Delete `␍`  prettier/prettier
  Line 46:38:  Delete `␍`  prettier/prettier

src\serviceWorkerRegistration.js
  Line 1:60:    Delete `␍`  prettier/prettier
  Line 2:40:    Delete `␍`  prettier/prettier
  Line 3:1:     Delete `␍`  prettier/prettier
  Line 4:79:    Delete `␍`  prettier/prettier
  Line 5:79:    Delete `␍`  prettier/prettier
  Line 6:80:    Delete `␍`  prettier/prettier
  Line 7:76:    Delete `␍`  prettier/prettier
  Line 8:44:    Delete `␍`  prettier/prettier
  Line 9:1:     Delete `␍`  prettier/prettier
  Line 10:77:   Delete `␍`  prettier/prettier
  Line 11:37:   Delete `␍`  prettier/prettier
  Line 12:1:    Delete `␍`  prettier/prettier
  Line 13:29:   Delete `␍`  prettier/prettier
  Line 14:46:   Delete `␍`  prettier/prettier
  Line 15:44:   Delete `␍`  prettier/prettier
  Line 16:44:   Delete `␍`  prettier/prettier
  Line 17:54:   Delete `␍`  prettier/prettier
  Line 18:36:   Delete `␍`  prettier/prettier
  Line 19:64:   Delete `␍`  prettier/prettier
  Line 20:7:    Delete `␍`  prettier/prettier
  Line 21:3:    Delete `␍`  prettier/prettier
  Line 22:1:    Delete `␍`  prettier/prettier
  Line 23:35:   Delete `␍`  prettier/prettier
  Line 24:79:   Delete `␍`  prettier/prettier
  Line 25:73:   Delete `␍`  prettier/prettier
  Line 26:77:   Delete `␍`  prettier/prettier
  Line 27:55:   Delete `␍`  prettier/prettier
  Line 28:78:   Delete `␍`  prettier/prettier
  Line 29:80:   Delete `␍`  prettier/prettier
  Line 30:84:   Delete `␍`  prettier/prettier
  Line 31:14:   Delete `␍`  prettier/prettier
  Line 32:6:    Delete `␍`  prettier/prettier
  Line 33:1:    Delete `␍`  prettier/prettier
  Line 34:44:   Delete `␍`  prettier/prettier
  Line 35:67:   Delete `␍`  prettier/prettier
  Line 36:1:    Delete `␍`  prettier/prettier
  Line 37:25:   Delete `␍`  prettier/prettier
  Line 38:94:   Delete `␍`  prettier/prettier
  Line 39:48:   Delete `␍`  prettier/prettier
  Line 40:1:    Delete `␍`  prettier/prettier
  Line 41:80:   Delete `␍`  prettier/prettier
  Line 42:45:   Delete `␍`  prettier/prettier
  Line 43:51:   Delete `␍`  prettier/prettier
  Line 44:23:   Delete `␍`  prettier/prettier
  Line 45:71:   Delete `␍`  prettier/prettier
  Line 46:67:   Delete `␍`  prettier/prettier
  Line 47:13:   Delete `␍`  prettier/prettier
  Line 48:12:   Delete `␍`  prettier/prettier
  Line 49:15:   Delete `␍`  prettier/prettier
  Line 50:58:   Delete `␍`  prettier/prettier
  Line 51:40:   Delete `␍`  prettier/prettier
  Line 52:8:    Delete `␍`  prettier/prettier
  Line 53:8:    Delete `␍`  prettier/prettier
  Line 54:4:    Delete `␍`  prettier/prettier
  Line 55:2:    Delete `␍`  prettier/prettier
  Line 56:1:    Delete `␍`  prettier/prettier
  Line 57:42:   Delete `␍`  prettier/prettier
  Line 58:26:   Delete `␍`  prettier/prettier
  Line 59:21:   Delete `␍`  prettier/prettier
  Line 60:30:   Delete `␍`  prettier/prettier
  Line 61:43:   Delete `␍`  prettier/prettier
  Line 62:58:   Delete `␍`  prettier/prettier
  Line 63:40:   Delete `␍`  prettier/prettier
  Line 64:18:   Delete `␍`  prettier/prettier
  Line 65:10:   Delete `␍`  prettier/prettier
  Line 66:49:   Delete `␍`  prettier/prettier
  Line 67:56:   Delete `␍`  prettier/prettier
  Line 68:54:   Delete `␍`  prettier/prettier
  Line 69:80:   Delete `␍`  prettier/prettier
  Line 70:76:   Delete `␍`  prettier/prettier
  Line 71:59:   Delete `␍`  prettier/prettier
  Line 72:27:   Delete `␍`  prettier/prettier
  Line 73:72:   Delete `␍`  prettier/prettier
  Line 74:78:   Delete `␍`  prettier/prettier
  Line 75:17:   Delete `␍`  prettier/prettier
  Line 76:1:    Delete `␍`  prettier/prettier
  Line 77:34:   Delete `␍`  prettier/prettier
  Line 78:47:   Delete `␍`  prettier/prettier
  Line 79:47:   Delete `␍`  prettier/prettier
  Line 80:16:   Delete `␍`  prettier/prettier
  Line 81:21:   Delete `␍`  prettier/prettier
  Line 82:63:   Delete `␍`  prettier/prettier
  Line 83:52:   Delete `␍`  prettier/prettier
  Line 84:63:   Delete `␍`  prettier/prettier
  Line 85:65:   Delete `␍`  prettier/prettier
  Line 86:1:    Delete `␍`  prettier/prettier
  Line 87:34:   Delete `␍`  prettier/prettier
  Line 88:48:   Delete `␍`  prettier/prettier
  Line 89:48:   Delete `␍`  prettier/prettier
  Line 90:16:   Delete `␍`  prettier/prettier
  Line 91:14:   Delete `␍`  prettier/prettier
  Line 92:12:   Delete `␍`  prettier/prettier
  Line 93:11:   Delete `␍`  prettier/prettier
  Line 94:9:    Delete `␍`  prettier/prettier
  Line 95:7:    Delete `␍`  prettier/prettier
  Line 96:24:   Delete `␍`  prettier/prettier
  Line 97:73:   Delete `␍`  prettier/prettier
  Line 98:8:    Delete `␍`  prettier/prettier
  Line 99:2:    Delete `␍`  prettier/prettier
  Line 100:1:   Delete `␍`  prettier/prettier
  Line 101:50:  Delete `␍`  prettier/prettier
  Line 102:76:  Delete `␍`  prettier/prettier
  Line 103:17:  Delete `␍`  prettier/prettier
  Line 104:45:  Delete `␍`  prettier/prettier
  Line 105:5:   Delete `␍`  prettier/prettier
  Line 106:26:  Delete `␍`  prettier/prettier
  Line 107:81:  Delete `␍`  prettier/prettier
  Line 108:64:  Delete `␍`  prettier/prettier
  Line 109:11:  Delete `␍`  prettier/prettier
  Line 110:35:  Delete `␍`  prettier/prettier
  Line 111:74:  Delete `␍`  prettier/prettier
  Line 112:10:  Delete `␍`  prettier/prettier
  Line 113:79:  Delete `␍`  prettier/prettier
  Line 114:63:  Delete `␍`  prettier/prettier
  Line 115:49:  Delete `␍`  prettier/prettier
  Line 116:38:  Delete `␍`  prettier/prettier
  Line 117:14:  Delete `␍`  prettier/prettier
  Line 118:12:  Delete `␍`  prettier/prettier
  Line 119:15:  Delete `␍`  prettier/prettier
  Line 120:52:  Delete `␍`  prettier/prettier
  Line 121:40:  Delete `␍`  prettier/prettier
  Line 122:8:   Delete `␍`  prettier/prettier
  Line 123:7:   Delete `␍`  prettier/prettier
  Line 124:19:  Delete `␍`  prettier/prettier
  Line 125:19:  Delete `␍`  prettier/prettier
  Line 126:73:  Delete `␍`  prettier/prettier
  Line 127:9:   Delete `␍`  prettier/prettier
  Line 128:8:   Delete `␍`  prettier/prettier
  Line 129:2:   Delete `␍`  prettier/prettier
  Line 130:1:   Delete `␍`  prettier/prettier
  Line 131:31:  Delete `␍`  prettier/prettier
  Line 132:38:  Delete `␍`  prettier/prettier
  Line 133:34:  Delete `␍`  prettier/prettier
  Line 134:32:  Delete `␍`  prettier/prettier
  Line 135:35:  Delete `␍`  prettier/prettier
  Line 136:9:   Delete `␍`  prettier/prettier
  Line 137:26:  Delete `␍`  prettier/prettier
  Line 138:38:  Delete `␍`  prettier/prettier
  Line 139:10:  Delete `␍`  prettier/prettier
  Line 140:4:   Delete `␍`  prettier/prettier
  Line 141:2:   Delete `␍`  prettier/prettier

Search for the keywords to learn more about each error.

webpack 5.69.0 compiled with 1 error in 28364 ms

what do you mean renamin images 1 to n ?

When cronos chain will come in moralis?

Hello, Where is the contract used in remix found?

Hi @Smart19,

I have it here: src\contracts\marketplaceBoilerplate.sol
Or if you do not have this file, this is my current version…

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

//import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol";
//import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
//import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol";

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3458c1e8541ce0a0cd935828c9db8f9cbca988a0/contracts/utils/Counters.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3458c1e8541ce0a0cd935828c9db8f9cbca988a0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3458c1e8541ce0a0cd935828c9db8f9cbca988a0/contracts/security/ReentrancyGuard.sol";

contract marketPlaceBoilerPlate is ReentrancyGuard {
    using Counters for Counters.Counter;
    Counters.Counter private _itemIds;
    Counters.Counter private _itemsSold;
    
     address public owner;
     
     constructor() {
         owner = msg.sender;
     }
     
     struct MarketItem {
         uint itemId;
         address nftContract;
         uint256 tokenId;
         address payable seller;
         address payable owner;
         uint256 price;
         bool sold;
     }
     
     mapping(uint256 => MarketItem) private idToMarketItem;
     
     event MarketItemCreated (
        uint indexed itemId,
        address indexed nftContract,
        uint256 indexed tokenId,
        address seller,
        address owner,
        uint256 price,
        bool sold
     );
     
     event MarketItemSold (
         uint indexed itemId,
         address owner
         );
     
    
    
    function createMarketItem(
        address nftContract,
        uint256 tokenId,
        uint256 price
        ) public payable nonReentrant {
            require(price > 0, "Price must be greater than 0");
            
            _itemIds.increment();
            uint256 itemId = _itemIds.current();
  
            idToMarketItem[itemId] =  MarketItem(
                itemId,
                nftContract,
                tokenId,
                payable(msg.sender),
                payable(address(0)),
                price,
                false
            );
            
            IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);
                
            emit MarketItemCreated(
                itemId,
                nftContract,
                tokenId,
                msg.sender,
                address(0),
                price,
                false
            );
        }
        
    function createMarketSale(
        address nftContract,
        uint256 itemId
        ) public payable nonReentrant {
            uint price = idToMarketItem[itemId].price;
            uint tokenId = idToMarketItem[itemId].tokenId;
            bool sold = idToMarketItem[itemId].sold;
            require(msg.value == price, "Please submit the asking price in order to complete the purchase");
            require(sold != true, "This Sale has alredy finnished");
            emit MarketItemSold(
                itemId,
                msg.sender
            );

            //idToMarketItem[itemId].seller.transfer(msg.value);
            // 24mar22 added ownerfee to send 1% of price to owner
            uint ownerFee = price.div(100);
            idToMarketItem[itemId].seller.transfer(msg.value - ownerFee);
            idToMarketItem[itemId].owner.transfer(ownerFee);

            IERC721(nftContract).transferFrom(address(this), msg.sender, tokenId);
            idToMarketItem[itemId].owner = payable(msg.sender);
            _itemsSold.increment();
            idToMarketItem[itemId].sold = true;
        }
        
    function fetchMarketItems() public view returns (MarketItem[] memory) {
        uint itemCount = _itemIds.current();
        uint unsoldItemCount = _itemIds.current() - _itemsSold.current();
        uint currentIndex = 0;

        MarketItem[] memory items = new MarketItem[](unsoldItemCount);
        for (uint i = 0; i < itemCount; i++) {
            if (idToMarketItem[i + 1].owner == address(0)) {
                uint currentId = i + 1;
                MarketItem storage currentItem = idToMarketItem[currentId];
                items[currentIndex] = currentItem;
                currentIndex += 1;
            }
        }
        return items;
    }
      
}

/// Thanks for inspiration: https://github.com/dabit3/polygon-ethereum-nextjs-marketplace/

How can this be done automatically I.e. writing a function that fetch the required data from the database and get it return accordingly without having to go through the manual method. If you have a solution to this kindly share
Thanks

someone please help me.
I’m having trouble with the BUY function, and I’ve been working on it for 2 days but it doesn’t work, and I even tried to start over from scratch.

you have to approve first before registering nft to the market