I'm pretty new to the BC and specifically Ethereum world and I'm just starting to scratch the surface of the potential applications of this powerful technology.

As I'm approaching to build my first project ever I'd like to create a simple dApp to validate data on the db of a web platform. Basically this dApp would have two functions:

  • The first posts the SHA-256 hash of a data on the BC;
  • The second retrieves a specific hash stored on the BC and validates it against the one stored in the db to check if it has been altered or not.

Obviously the amount of hashes would start from one and scale continuously over time as new data are entered on the db. What would be the best way to achieve my goals? Would a Distributed Hash Table be the right fit? And lastly what would be the transaction costs of this solution?

Thanks in advance for helping me. Looking forward to your advice.

2 Answers 2


You can create a smart contract on the blockchain that will be used to keep track of the hashes. Storing the hash is cheap as compared to storing data on ethereum.

Transaction costs can be calculated using:

Cost = Gas Cost * Estimated Gas Required

You can use web3j functions to calculate the gas cost and estimated gas required to carry out the transaction. The following functions could be useful:

web3.eth.estimateGas(callObject [, callback])

Storing 32 bytes hash takes around 25000 gas which is around $0.1545,

Regarding DHT vs Blockchain, It would depend on how you plan to design your system as DHT is good for lookup and provides you the key, value mapping whereas blockchain provides you tamper-proof data. DHT is decentralized but not every node will keep the data unlike in blockchain.

  • Hi Arpit thank you so much for the advice. I think that BC would then be the best and more secure solution to store the hashes. So by putting the hashes on the BC how should it be done? More specific: each hash will be standing alone on the BC or there's a way to "collect" those? And if those stand alone how could be retrieved? With a function having the hash as parameter? Jun 26, 2020 at 15:45

If you decide to use an Ethereum smart contract you would create something that roughly looks like this:

mapping (uint => string) hashes;

function storeHash(ID, hash) onlyOwner {
  hashes[ID] = hash;

function retreiveHash(ID){
  return hashes[ID];

Here is a good beginners tutorial similar to your use-case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.