0

I am ultimately trying to display the nft that is being minted. I can record the transaction properly but now I am just trying to display the tokenURI. This is my smart contract.

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

    Counters.Counter private _tokenIdCounter;
    uint256 public mintRate= 1.00 ether;

    constructor() ERC721("EzAsPyNews", "EAPN") {}

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

    function safeMint(address to) public payable returns(uint256){
        require(msg.value >= mintRate, "Please make sure you are entering atleast one ether.");
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        return tokenId;
        
  ''  }



This is my streamlit application to mint the nfts, where i also want to display the NFT. So right after you mint an nft you can see the actual uri or image of the nft that you just minted.

st.title("Register for a Certificate of membership token")
accounts = w3.eth.accounts
address = st.selectbox("Select account for membership", options=accounts)



if st.button("Purchase a Certificate of Membership Token"):
    tx_hash = contract.functions.safeMint(address).transact({
        "from": address,
        "gas": 1000000,
        "value": 1000000000000000000, #Web3.fromWei(1000000000000000000, "ether")
    
    })
    st.write(tx_hash)
    receipt = w3.eth.waitForTransactionReceipt(tx_hash)
    st.write("Transaction receipt mined:")
    st.write(dict(receipt))

    tokenId = contract.functions.totalSupply()
    st.write(tokenId)

    tokenURI = contract.functions.tokenURI(tokenId)
    st.write(tokenURI)

I tried to use this

    tokenId = contract.functions.totalSupply()
    st.write(tokenId)

    tokenURI = contract.functions.tokenURI(tokenId)
    st.write(tokenURI)

but was met with this error enter image description here

I tried adding .call() to the end of the two functions but I would still get an error.

TylerH
  • 20,799
  • 66
  • 75
  • 101

0 Answers0