I have a Nodejs application in which users fill up multiple forms and that data is saved to the centralized DB i.e MongoDB. Admin can review the user data and can push the user data to Blockchain to maintain the integrity of data so that any third party can view the data in future and verify its integrity.
Now, as data is large it can't be stored directly to the blockchain. So, I am converting the data first to pdf and then creating the hash of pdf using Keccack 256 algorithm and storing the hash to the contract. And in return, I get a transaction Id which I can later use for retrieving the data from the blockchain.
Please suggest If I am on right track or there is a better approach for this.
Note:- If a user updates his application, Admin will again push the user data to the blockchain.
This is the contract code I am using:
pragma solidity ^0.4.17;
contract AddUserApplication {
string public userdata;
function addUserData(string data) public {
userdata = data;
}
}
// Code for retreiving the data from Block:
const viewTransaction = async () => {
let viewData = await web3.eth.getTransaction('0xd819b09a906232a37b6ad102a7616eed6af9d968718b23878e023ccf7f967f8');
console.log('viewdata: ',viewData.input);
const decodedData = abiDecoder.decodeMethod(viewData.input);
console.log('decodedData',decodedData);
}