[SOLVED] Child unique key _ Ethereum NFT Boilerplate

Is anyone at Moralis able to have a look at the code and help solve this with me please or tell me exactly how to fix this? I’ve been doing alot of trial and error and need some more support.
Cheers

@johnversus Is this getting close to what you mean? I’ve done what I think you meant and im getting this in my console now.

NFTBalance

import React, { useState } from "react";

import { useMoralis } from "react-moralis";

import { Card, Image, Tooltip, Modal, Input, Alert, Spin, Button } from "antd";

import { useNFTBalance } from "hooks/useNFTBalance";

import { FileSearchOutlined, ShoppingCartOutlined } from "@ant-design/icons";

import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider";

import { getExplorer } from "helpers/networks";

import { useWeb3ExecuteFunction } from "react-moralis";

const { Meta } = Card;

const styles = {

  NFTs: {

    display: "flex",

    flexWrap: "wrap",

    WebkitBoxPack: "start",

    justifyContent: "flex-start",

    margin: "0 auto",

    maxWidth: "1000px",

    gap: "10px",

  },

};

function NFTBalance(index) {

  const { NFTBalance, fetchSuccess } = useNFTBalance();

  const { chainId, marketAddress, contractABI } = useMoralisDapp();

  const { Moralis } = useMoralis();

  const [visible, setVisibility] = useState(false);

  const [nftToSend, setNftToSend] = useState(null);

  const [price, setPrice] = useState(1);

  const [loading, setLoading] = useState(false);

  const contractProcessor = useWeb3ExecuteFunction();

  const contractABIJson = JSON.parse(contractABI);

  const listItemFunction = "createMarketItem";

  const ItemImage = Moralis.Object.extend("ItemImages");

  async function list(nft, listPrice) {

    setLoading(true);

    const p = listPrice * ("1e" + 18);

    const ops = {

      contractAddress: marketAddress,

      functionName: listItemFunction,

      abi: contractABIJson,

      params: {

        nftContract: nft.token_address,

        tokenId: nft.token_id,

        price: String(p),

      },

    };

    await contractProcessor.fetch({

      params: ops,

      onSuccess: () => {

        console.log("success");

        setLoading(false);

        setVisibility(false);

        addItemImage();

        succList();

      },

      onError: (error) => {

        setLoading(false);

        failList();

      },

    });

  }

  async function approveAll(nft) {

    setLoading(true);  

    console.log("nft: ", nft)

    const ops = {

      contractAddress: nft.token_address,

      functionName: "setApprovalForAll",

      abi: [{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"}],

      params: {

        operator: marketAddress,

        approved: true

      },

    };

    await contractProcessor.fetch({

      params: ops,

      onSuccess: () => {

        console.log("Approval Received");

        setLoading(false);

        setVisibility(false);

        succApprove();

      },

      onError: (error) => {

        setLoading(false);

        failApprove();

      },

    });

  }

  const handleSellClick = (nft) => {

    setNftToSend(nft);

    setVisibility(true);

  };

  function succList() {

    let secondsToGo = 5;

    const modal = Modal.success({

      title: "Success!",

      content: `Your NFT was listed on the marketplace`,

    });

    setTimeout(() => {

      modal.destroy();

    }, secondsToGo * 1000);

  }

  function succApprove() {

    let secondsToGo = 5;

    const modal = Modal.success({

      title: "Success!",

      content: `Approval is now set, you may list your NFT`,

    });

    setTimeout(() => {

      modal.destroy();

    }, secondsToGo * 1000);

  }

  function failList() {

    let secondsToGo = 5;

    const modal = Modal.error({

      title: "Error!",

      content: `There was a problem listing your NFT`,

    });

    setTimeout(() => {

      modal.destroy();

    }, secondsToGo * 1000);

  }

  function failApprove() {

    let secondsToGo = 5;

    const modal = Modal.error({

      title: "Error!",

      content: `There was a problem with setting approval`,

    });

    setTimeout(() => {

      modal.destroy();

    }, secondsToGo * 1000);

  }

  function addItemImage() {

    const itemImage = new ItemImage();

    itemImage.set("image", nftToSend.image);

    itemImage.set("nftContract", nftToSend.token_address);

    itemImage.set("tokenId", nftToSend.token_id);

    itemImage.set("name", nftToSend.name);

    itemImage.save();

  }

  return (

    <>

      <div style={styles.NFTs}>

        {contractABIJson.noContractDeployed && (

          <>

            <Alert

              message="No Smart Contract Details Provided. Please deploy smart contract and provide address + ABI in the MoralisDappProvider.js file"

              type="error"

            />

            <div style={{ marginBottom: "10px" }}></div>

          </>

        )}

        {!fetchSuccess && (

          <>

            <Alert

              message="Unable to fetch all NFT metadata... We are searching for a solution, please try again later!"

              type="warning"

            />

            <div style={{ marginBottom: "10px" }}></div>

          </>

        )}

        {NFTBalance &&

          NFTBalance.map((nft, index) => (

            <Card

              hoverable

              actions={[

                <Tooltip title="View On Blockexplorer">

                  <FileSearchOutlined

                    onClick={() =>

                      window.open(

                        `${getExplorer(chainId)}address/${nft.token_address}`,

                        "_blank"

                      )

                    }

                  />

                </Tooltip>,

                <Tooltip title="List NFT for sale">

                  <ShoppingCartOutlined onClick={() => handleSellClick(nft)} />

                </Tooltip>,

              ]}

              style={{ width: 240, border: "2px solid #e7eaf3" }}

              cover={

                <Image

                  preview={false}

                  src={nft?.image || "error"}

                  fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQB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EPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="

                  alt=""

                  style={{ height: "240px" }}

                />

              }

            >

              <NFTBalance key={index}></NFTBalance>

              <Meta title={nft.name} description={nft.contract_type} key={index} />

            </Card>

          ))}

      </div>

      <Modal

        title={`List ${nftToSend?.name} #${nftToSend?.token_id} For Sale`}

        visible={visible}

        onCancel={() => setVisibility(false)}

        onOk={() => list(nftToSend, price)}

        okText="List"

        footer={[

          <Button onClick={() => setVisibility(false)}>

            Cancel

          </Button>,

          <Button onClick={() => approveAll(nftToSend)} type="primary">

            Approve

          </Button>,

          <Button onClick={() => list(nftToSend, price)} type="primary">

            List

          </Button>

        ]}

      >

        <Spin spinning={loading}>

          <img

            src={`${nftToSend?.image}`}

            style={{

              width: "250px",

              margin: "auto",

              borderRadius: "10px",

              marginBottom: "15px",

            }}

          />

          <Input

            autoFocus

            placeholder="Listing Price in ETH"

            onChange={(e) => setPrice(e.target.value)}

          />

        </Spin>

      </Modal>

    </>

  );

}

export default NFTBalance;

App.jsx

import { useEffect, useState} from "react";

import { useMoralis } from "react-moralis";

import {

  BrowserRouter as Router,

  Switch,

  Route,

  NavLink,

  Redirect,

} from "react-router-dom";

import Account from "components/Account";

import Chains from "components/Chains";

import NFTBalance from "components/NFTBalance";

import NFTTokenIds from "components/NFTTokenIds";

import { Menu, Layout} from "antd";

import SearchCollections from "components/SearchCollections";

import "antd/dist/antd.css";

import NativeBalance from "components/NativeBalance";

import "./style.css";

import Text from "antd/lib/typography/Text";

import NFTMarketTransactions from "components/NFTMarketTransactions";

const { Header, Footer } = Layout;

const styles = {

  content: {

    display: "flex",

    justifyContent: "center",

    fontFamily: "Roboto, sans-serif",

    color: "#041836",

    marginTop: "130px",

    padding: "10px",

  },

  header: {

    position: "fixed",

    zIndex: 1,

    width: "100%",

    background: "#fff",

    display: "flex",

    justifyContent: "space-between",

    alignItems: "center",

    fontFamily: "Roboto, sans-serif",

    borderBottom: "2px solid rgba(0, 0, 0, 0.06)",

    padding: "0 10px",

    boxShadow: "0 1px 10px rgb(151 164 175 / 10%)",

  },

  headerRight: {

    display: "flex",

    gap: "20px",

    alignItems: "center",

    fontSize: "15px",

    fontWeight: "600",

  },

};

const App = ({ isServerInfo, index }) => {

  const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading } =

    useMoralis();

  const [inputValue, setInputValue] = useState("explore");

  useEffect(() => {

    if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading) enableWeb3();

    // eslint-disable-next-line react-hooks/exhaustive-deps

  }, [isAuthenticated, isWeb3Enabled]);

  return (

    <Layout style={{ height: "100vh", overflow: "auto" }}>

      <Router>

        <Header style={styles.header}>

          <Logo />

          <SearchCollections setInputValue={setInputValue}/>

          <Menu

            theme="light"

            mode="horizontal"

            style={{

              display: "flex",

              fontSize: "17px",

              fontWeight: "500",

              marginLeft: "50px",

              width: "100%",

            }}

            defaultSelectedKeys={["nftMarket"]}

          >

            <Menu.Item key="nftMarket" onClick={() => setInputValue("explore")} >

              <NavLink to="/NFTMarketPlace">🛒 Explore Market</NavLink>

            </Menu.Item>

            <Menu.Item key="nft">

              <NavLink to="/nftBalance">🖼 Your Collection</NavLink>

            </Menu.Item>

            <Menu.Item key="transactions">

              <NavLink to="/Transactions">📑 Your Transactions</NavLink>

            </Menu.Item>

          </Menu>

          <div style={styles.headerRight}>

            <Chains />

            <NativeBalance />

            <Account />

          </div>

        </Header>

        <div style={styles.content}>

          <Switch>

            <Route path="/nftBalance">

           <NFTBalance key={index}></NFTBalance>

            </Route>

            <Route path="/NFTMarketPlace">

              <NFTTokenIds inputValue={inputValue} setInputValue={setInputValue}/>

            </Route>

            <Route path="/Transactions">

              <NFTMarketTransactions />

            </Route>

          </Switch>

          <Redirect to="/NFTMarketPlace" />

        </div>

      </Router>

      <Footer style={{ textAlign: "center" }}>

        <Text style={{ display: "block" }}>

          ⭐️ Please star this{" "}

          <a

            href="https://github.com/ethereum-boilerplate/ethereum-boilerplate/"

            target="_blank"

            rel="noopener noreferrer"

          >

            boilerplate

          </a>

          , every star makes us very happy!

        </Text>

        <Text style={{ display: "block" }}>

          🙋 You have questions? Ask them on the {""}

          <a

            target="_blank"

            rel="noopener noreferrer"

            href="https://forum.moralis.io/t/ethereum-boilerplate-questions/3951/29"

          >

            Moralis forum

          </a>

        </Text>

        <Text style={{ display: "block" }}>

          📖 Read more about{" "}

          <a

            target="_blank"

            rel="noopener noreferrer"

            href="https://moralis.io?utm_source=boilerplatehosted&utm_medium=todo&utm_campaign=ethereum-boilerplat"

          >

            Moralis

          </a>

        </Text>

      </Footer>

    </Layout>

  );

};

export const Logo = () => (

  <div style={{ display: "flex" }}>

    <svg

      width="60"

      height="38"

      viewBox="0 0 50 38"

      fill="none"

      xmlns="http://www.w3.org/2000/svg"

    >

      <path

        d="M43.6871 32.3986C43.5973 32.4884 43.53 32.5782 43.4402 32.6905C43.53 32.6007 43.5973 32.5109 43.6871 32.3986Z"

        fill="black"

      />

      <path

        d="M49.7037 14.3715C49.5241 6.2447 42.7891 -0.17592 34.6624 0.00367768C31.0031 0.0934765 27.4784 1.53026 24.8294 4.06708C22.113 1.46291 18.4986 0.00367768 14.727 0.00367768C6.71246 0.00367768 0.202047 6.49164 0 14.5511V14.6633C0 20.8146 2.24497 26.2698 4.26545 30.0189C5.11853 31.5904 6.08387 33.117 7.13901 34.5762C7.5431 35.115 7.8574 35.564 8.10435 35.8559L8.39619 36.2151L8.48599 36.3273L8.50844 36.3498L8.53089 36.3722C10.2146 38.3253 13.1555 38.5498 15.1087 36.8886C15.1311 36.8661 15.1536 36.8437 15.176 36.8212C17.1291 35.0701 17.3312 32.0843 15.625 30.1087L15.6026 30.0638L15.423 29.8618C15.2658 29.6597 15.0189 29.3455 14.727 28.9414C13.9188 27.8189 13.178 26.6515 12.5269 25.4392C10.8881 22.4309 9.42888 18.6145 9.42888 14.7531C9.49623 11.8347 11.9432 9.52236 14.8617 9.58971C17.7128 9.65705 19.9802 11.9694 20.0251 14.8205C20.0476 15.5389 20.2272 16.2348 20.5415 16.8859C21.4844 19.3104 24.2232 20.5227 26.6478 19.5798C28.4438 18.8839 29.6336 17.1553 29.6561 15.2246V14.596C29.7683 11.6775 32.2153 9.38766 35.1562 9.47746C37.94 9.56726 40.1625 11.8122 40.2748 14.596C40.2523 17.6941 39.2645 20.7472 38.1421 23.1718C37.6931 24.1371 37.1992 25.08 36.6379 25.978C36.4359 26.3147 36.2787 26.5617 36.1665 26.6964C36.1216 26.7862 36.0767 26.8311 36.0542 26.8535L36.0318 26.876L35.9869 26.9433C37.6033 24.9004 40.5442 24.5412 42.5871 26.1576C44.4953 27.6617 44.9443 30.3781 43.6198 32.4211L43.6422 32.4435V32.3986L43.6647 32.3762L43.732 32.2864C43.7769 32.1966 43.8667 32.1068 43.9565 31.9721C44.1361 31.7027 44.3606 31.3435 44.6525 30.8945C45.3933 29.6822 46.0668 28.4026 46.673 27.1229C48.1097 24.0249 49.6812 19.5349 49.6812 14.5286L49.7037 14.3715Z"

        fill="#041836"

      />

      <path

        d="M39.7135 25.1249C37.1094 25.1025 34.9991 27.2127 34.9766 29.8169C34.9542 32.4211 37.0645 34.5313 39.6686 34.5538C41.1503 34.5538 42.5647 33.8578 43.4626 32.6905C43.53 32.6007 43.5973 32.4884 43.6871 32.3986C45.1015 30.221 44.4729 27.3025 42.2953 25.9107C41.532 25.3943 40.634 25.1249 39.7135 25.1249Z"

        fill="#B7E803"

      />

    </svg>

  </div>

);

export default App;

What is the error above this?

Hi @johnversus
this error your talking about has gone away and these are the 2 current errors I am having. I’ve redeployed my smart contract to the Mumbai chain and added the new market address into my code. I still get the same errors and glad mentioned it could be something throwing the error. I’m looking on different forums and google to see if i can find a solution.

Hey @johnversus
I was reading it could be something to do with my constructor. Do I need to add anymore to mine?

marketplace smart contract

// 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 for inspiration: https://github.com/dabit3/polygon-ethereum-nextjs-marketplace/

It cant be related to the contract code.

Can you share your project files thru github?

here is my repo for my code

1 Like

I was checking the NFTs on /nftBalance page and it does not seem to throw any error for me.

Can you share the steps to reproduce the error?

Hey @johnversus
I go to the Mumbai chain on my Dapp and I go to my collections. I have a polygon NFT that I try to approve and list. When i click on the NFT itself I get the error for the unique key and when I click on the approve button after I type 0.01 as a price I get the invalid address error. I also get the same errors when I add and use the Ropsten test net where I have NFT’s I can approve and list.

Everything else on the Dapp works great just the approve and list feature for my own collections. :slight_smile:

You are getting error during approval as you did not add the contract address MoralisDappProvider.js as string. Fixing it should solve the error at approval.

const [marketAddress, setMarketAddress] = useState( "0xd9145CCE52D386f254917e481eB44e9943F39138"); //Smart Contract Address Here

And the error related to unique key props is happening from Modal component for some reason. You can ignore it as it does not seem to be breaking anything in the app.

1 Like

You can fix the key props error by adding key values in side the footer props of Modal component.

footer={[
          <Button key={"CancelBtn"} onClick={() => setVisibility(false)}>
            Cancel
          </Button>,
          <Button
            key={"ApproveBtn"}
            onClick={() => approveAll(nftToSend)}
            type="primary"
          >
            Approve
          </Button>,
          <Button
            key={"ListBtn"}
            onClick={() => list(nftToSend, price)}
            type="primary"
          >
            List
          </Button>,
        ]}
3 Likes

@johnversus
Yes thank you bro. both of those errors are gone now and it works great.
I’m just trying to fix this new error i haven’t seen before with the listing of the nft.
Cheers
Screenshot FOR OPENSEA

Can you create a new post for this question.
The error is possibly due to the wrong contract address or you are executing the contract call on the wrong chain.