Fetch data from IPFS URI
Last updated
Last updated
In smart contracts, some methods return a URI pointing to IPFS.
To fetch data from this URI we need first to register an :
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 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 . 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 - RINKEBY