Search code examples
storeblockchainethereum

Storing users data on ethereum blockchain


We are developing an application where we want to store the data of the user on the ethereum blockchain. My thought process is something like this

  • Have a contract that interfaces with the UI.
  • When the user enters info on the UI, it triggers the solidity smart contract
  • The smart contract will inturn trigger an event through oraclejs that will store the data on a database

I want to know if there is a better way to do this.


Solution

  • As storing in Blockchain is costly operation you can store the data in oracle db and store the rowhash(I recommend sha256()) to the blockchain.

    mapping (uint=> byets32) dataHashById;
    

    Now whenever you fetch the data from db, you have to make hashing of that row and verify against the hash from blockchain. Thats it.