I use pragma solidity ^0.8.0; and contract MyERC721 is Ownable, ERC721URIStorage I want to set the tokenUri from my mint function argument like this: function mintToken(address recipient, string memory tokenURI) external onlyOwner { uint256 newItemId = _tokenIds.current(); _safeMint(recipient, _tokenIds.current()); _setTokenURI(newItemId, tokenURI); _tokenIds.increment(); } On https://rinkeby.etherscan.io/address/0x89…80b#writeContract I trigger mintToken with an transfer address and the ipfs::Listen
I use pragma solidity ^0.8.0;
and contract MyERC721 is Ownable, ERC721URIStorage
I want to set the tokenUri from my mint function argument like this:
function mintToken(address recipient, string memory tokenURI) external onlyOwner { uint256 newItemId = _tokenIds.current(); _safeMint(recipient, _tokenIds.current()); _setTokenURI(newItemId, tokenURI); _tokenIds.increment(); }
On https://rinkeby.etherscan.io/address/0x89…80b#writeContract I trigger mintToken with an transfer address and the ipfs url "ipfs://bafk…eu"
On OpenSea the preview image is broken and the token id is not linked with the tokenUrl
But when I set the tokenUri inside of the mint function like this
function mintToken(address recipient) external onlyOwner { uint256 newItemId = _tokenIds.current(); _safeMint(recipient, _tokenIds.current()); _setTokenURI(newItemId, "ipfs://bafk...eu"); _tokenIds.increment(); }
Suddenly everything is fine. OpenSea displays the preview image and links the token id with the tokenUri
Whats the difference between the two ways and why is way 1 not working?
Also when I call tokenURI on https://rinkeby.etherscan.io/address/0x89…80b#readContract for both contracts, both minted tokens return the same url "ipfs://bafk…eu". That’s strange.