the NFTOwners table automatically sets the tokenURI class column to (token_uri) but my NFT contract uses (TokenURI), is there a way to change it from token_uri ,to tokenURI and have the database recognize it. I created a new column named tokenURI but it doesnât register the token uri
okay please send an example, thanks
beforeconsume
trigger*
Moralis.Cloud.beforeConsume('NFTOwners', async (event) => {
event.tokenURI = event.token_uri;
delete event.token_uri;
return event;
});
unfortunately this doesnât work. I donât know if this matters but iâm using chainlink VRF to generate the nftâs and My code doesnât set tokenURI when the NFT is minted, i do that manually after a few nfts have been minted.
Canât you start from beginning by modifying the smart contract to add token_uri?
Unfortunately iâm using openzeppelin erc721 contract and the set token uri function is defined as
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), âERC721Metadata: URI set of nonexistent tokenâ);
_tokenURIs[tokenId] = _tokenURI;
}
an example of ERC721 token:
https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code
an example of NFT for that ERC721 smart contract: https://opensea.io/assets/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/9136
it looks like there is no token_uri in that smart contract code
but somehow when running:
options_2 = { address: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D", token_id: "9136", chain: "eth" };
tokenIdMetadata_2 = await Moralis.Web3API.token.getTokenIdMetadata(options_2)
=>
it will display token_uri
:
{token_address: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d", token_id: "9136", contract_type: "ERC721", token_uri: "https://ipfs.moralis.io:2053/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/9136", metadata: null, âŚ}
amount: "1"
contract_type: "ERC721"
metadata: null
name: "BoredApeYachtClub"
symbol: "BAYC"
synced_at: null
token_address: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
token_id: "9136"
token_uri: "https://ipfs.moralis.io:2053/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/9136"
I think for my version of solidity and openzeppelin contract the tokenURI is specified as tokeURI not token_uri so trying to rewrite the function throws an error. Most recent NFT contracts are using the tokenURI statement
Iâm not sure what is going on, token_uri could also be something computed and added by Moralis when it processes the NFTs. In the example above it looks like the contract didnât have token_uri but at the end there is an IPFS link on Moralis IPFS for an NFT that probably was not created with Moralis.