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

enter image description here

Code 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);
    }
}

Code 2


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 "bafybeia435jagllnx7hgzidfd4q7jztp2u2a7di2h5xl6an6gbk5x6phzi";
    }

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

1 Answer 1

0

From the information you've given it looks like you are missing two bits.

The first being in the _baseURI function you are returning a hardcoded IPFS address. This is missing the ipfs:// prefix to indicate that this is a ipfs address. It also will require a / at the end so the token ID suffix is not appending directly to the IPFS hash.

Secondly, metamask and other platforms use the tokenURI() function to retrieve the NFT metadata, the result will be <BASE_URI><TOKEN_ID> which in this case will be bafybeia435jagllnx7hgzidfd4q7jztp2u2a7di2h5xl6an6gbk5x6phzi0 the zero at the end is the token ID of that minted NFT. You can see the implementation here

Looking at the base IPFS URI, it points to an index which contains one file called photo-1600585154340-be6161a56a0c.jpg, you can see this here. I am assuming that this is the photo that you would want displayed.

For this to work you would need a file at that IPFS address called 0 which follows the ERC721 metadata standard for ERC-721 which has an image property which points to the image you want to display.

I would recommend to use pinata to handle the uploads to IPFS and metadata creation as this can get tricky :)

2
  • i make few changes but this still dont work first change New ipfs address now look like this function _baseURI() internal pure override returns (string memory) { return "https://gateway.pinata.cloud/ipfs/QmToLt8pdvBAMvX3iTvcig6Tw4Sh3sP5uGdK19o7asV74B"; } and in safeMint function i set tokenId = 0; and i started using piniata and changed photo name to 0 and still don't work May 3, 2023 at 16:02
  • Attachemts: imgur.com/a/JuqqvGP May 3, 2023 at 16:16

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.