0

I have issue i succesfully minted and send nft but when I checking this nft on etherscan i see nft transaction but don't see img same on metamask i don't see any kind of nft or any nft photos

Attachments:

enter image description here

enter image description here enter image description here

Code 1

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

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract REALESTATE is ERC721, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("RealEsate", "RE") {}

    function _baseURI() internal pure override returns (string memory) {
        return
            "https://gateway.pinata.cloud/ipfs/QmToLt8pdvBAMvX3iTvcig6Tw4Sh3sP5uGdK19o7asV74B";
    }

    function safeMint(address to) public onlyOwner {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        tokenId = 0;
    }
}

code 2

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "./nftestate.sol";

contract BidContract is REALESTATE {
    struct Bid {
        address bidder;
        uint amount;
    }
    address public ownerr;
    uint public highestBid;
    address public highestBidder;
    event newbid(uint256 indexed highestBid, address indexed highestBidder);

    mapping(address => Bid) public bids;

    constructor() {
        ownerr = msg.sender;
    }

    function hisghestbidcheck() public view returns (uint256) {
        return highestBid;
    }

    function bid() public payable {
        require(msg.value > highestBid, "Bid too low");

        if (highestBidder != address(0)) {
            payable(highestBidder).transfer(highestBid);
        }

        highestBid = msg.value;
        highestBidder = msg.sender;
        bids[msg.sender] = Bid(msg.sender, msg.value);
        emit newbid(highestBid, highestBidder);
    }

    function endAuction() public {
        require(msg.sender == ownerr, "Only owner can end auction");
        require(highestBidder != address(0), "No bids received");

        payable(ownerr).transfer(highestBid);
        highestBid = 0;
        safeMint(highestBidder);
        highestBidder = address(0);
    }
}

2 Answers 2

0

On mainnet Etherscan, NFT images take some time to be indexed, with different indexing priorities such as if your token is updated or not.

Testnets explorers such as Sepolia or Goerli unfortunately do not have support for NFT images.

1

There is something you need to understand when working with ERC721 contracts. There are 2 types of NFTs you generate through this standard:

  1. Multiple NFTs: Something similar to Bored Apes. In this case, the baseURI() function contains the link to the metadata of all the images. Notice that it contains the metadata of the image, and not the image itself.

BaseURI of Bored Apes: ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq

  1. Single NFT: Only 1 NFT is minted through the NFT contract. Since it doesn't necessarily need uri to a folder, you can directly point to the metadata file. Therefore, you don't need to use baseUri in this case. You can explicitly set the tokenURI of the NFT.

Now talking about your contract, you are directly inputting the link to your image in your baseURi, which is wrong. baseURI needs a link to the metadata file, not the image itself. Second, since you are minting just 1 NFT, you don't need baseURI necessarily.

Metadata format:

 {
  "image": "ipfs://QmPbxeGcXhYQQNgsC6a36dDyYUcHgMLnGKnF8pVFmGsvqi",
  "attributes": [
    {
      "trait_type": "Mouth",
      "value": "Grin"
    },
    {
      "trait_type": "Clothes",
      "value": "Vietnam Jacket"
    },
    {
      "trait_type": "Background",
      "value": "Orange"
    },
    {
      "trait_type": "Eyes",
      "value": "Blue Beams"
    },
    {
      "trait_type": "Fur",
      "value": "Robot"
    }
  ]
}

Possible Modification:

function safeMint(address to, string memory _tokenURI) public onlyOwner {
        _tokenIdCounter.increment();            
        uint256 tokenId = _tokenIdCounter.current();
        
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, _tokenURI)
        tokenId = 0;
    }

See ERC721UriStorage.sol. It will help you.

7
  • i modified code but photo is still blank i think on testnets all nft photos are blank Commented May 4, 2023 at 13:17
  • Share your code and transaction Commented May 4, 2023 at 18:12
  • code: constructor() ERC721("RealEsate", "RE") {} uint256 tokenId = 0; mapping(uint256 => string) private _tokenURIs; function _setTokenURI( uint256 tokenId, string memory _tokenURI ) internal virtual { require( _exists(tokenId), "ERC721URIStorage: URI set of nonexistent token" ); _tokenURIs[tokenId] = _tokenURI; } function safeMint(address to, string memory _tokenURI) public onlyOwner { _safeMint(to, tokenId); _setTokenURI(tokenId, _tokenURI); } Commented May 4, 2023 at 20:44
  • and tx hash on Sepolia Testnet:0x0fca79af799260b10f4478a67c4dd301487b96abdf3d911d387458983187c2ae Commented May 4, 2023 at 20:46
  • You can dm me directly on dc:Xardesso#9566 Commented May 4, 2023 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.