ethereumipfsjs-ipfs

How can I update data on IPFS


I am storing user information on IPFS in JSON object format and then storing that file hash on blockchain. I want to update that JSON object array every time I add a new user object. How can I achieve this?

I'm using Etherium Blockchain and ReactJS


Solution

  • IPFS hashes are based on the content so the IPFS hash will change when the JSON data changes in this case. This means the content hash on-chain will have to be updated.

    1. Read current JSON data from IPFS
    2. Update JSON data with new entry
    3. Add new JSON data to IPFS
    4. Update content hash on smart contract