Fetch data from IPFS URI
In smart contracts, some methods return a URI pointing to IPFS.
To fetch data from this URI we need first to register an oracle:
Then, we need to extract the CID from the IPFS URI. The URI root is what comes before the CID. For example,
https://ipfs.io/ipfs/
Finally, we can prompt the data returned from IPFS:
We call the tokenURI method from the smart contract.
We extract the CID from the URI.
We use the get_http() predicate on the ipfs oracle. The output can be a big object, but we extract only what we need to display. For example, the name, description and image.
The complete dApp treated in this example can be found here - RINKEBY
Last updated