Metadata isn't showing up for my ERC-721, yet await contract.tokenURI(<id>)
returns correctly formatted JSON.
Token Contract:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract FollowNFT is ERC721URIStorage, Ownable {
uint public id = 1;
constructor() ERC721("SocialLinks NFT","SOCIAL") {}
function follow (address _address, string calldata metadata) public onlyOwner {
_mint(_address, id);
_setTokenURI(id, metadata);
id++;
}
function changeMetadata (
uint nft_id,
string calldata new_metadata
) public onlyOwner {
_setTokenURI(
nft_id,
new_metadata
);
}
}
Metadata arg:
let metadata = {
"description": "Tester",
"image": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Head_skull_anterior_view.jpg",
"name": "Ryan",
}
metadata = JSON.stringify(metadata)
Result of await NFTConract.tokenURI('2')
:
{"description":"Tester","image":"https://upload.wikimedia.org/wikipedia/commons/3/3a/Head_skull_anterior_view.jpg","name":"Ryan"}
And here it is on OpenSea