here is the context, I would like to be able to burn n ERC721 token based on the "dna" and the attributes "type" in the metadata (see below):
{
"dna": "602472F",
"name": "Test #1",
"description": "My Collectibles",
"image": "ipfs://QmasMm8v9WkU11BtnWsybDW6/1.png",
"edition": 1,
"attributes": [
{
"trait": "type",
"value": "Fire"
},
{
"trait_type": "Eyes",
"value": "Black"
}
]
}
All my .png and .json files are hosted in IPFS and I know how to retrieve them with tokenURI. Here is my code:
string public uri;
string public uriSuffix = ".json";
function _baseURI() internal view virtual override returns (string memory) {
return uri;
}
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory){
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : "";
}
The code above works well. I can get the uri of the token I want (only if it exists). Now, If I want msg.sender to burn n token with those specific attributes:
{
"trait": "type",
"value": "Fire"
}
How can I do that?