0

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?

Remzzer
  • 25
  • 2
  • For any interaction with the world outside the blockchain you need an oracle to perform the query and send the result to your contract. See this https://ethereum.stackexchange.com/questions/85178/what-is-a-blockchain-oracle. – Ismael Jan 27 '22 at 01:58
  • Maybe I am wrong but as my metadatas hosted by IPFS, I am not stepping outside the blockchain right? Maybe the easiest way to retrieve all metadatas from a token once minted is to get all infos the way Opensea does? Thanks – Remzzer Jan 27 '22 at 09:43
  • IPFS is a protocol that is independent of any blockchain, if you want to access it you'll need an oracle. OpenSea is the same, its api lives outside the blockchain so to access it you'll need an oracle. For example Chainlink and Provable are well known oracles you could use. – Ismael Jan 27 '22 at 13:00
  • Alright ! Thanks a lot for your clarifications @Ismael ! – Remzzer Jan 27 '22 at 17:12

0 Answers0