Storing Data Hash on Flow

Hi Flowmates,
I need to develop an application that gets a simple block of data as input, hash it and store the hash on flow.
I would be grateful if someone helps me know how I should proceed with the above-mentioned project :slight_smile:

You could just hash it off-chain and store the hash as a String wherever you want to store it. :slight_smile: Does that answer your question?

thanks, @flowjosh for your answer.
Since Hashing data and storing it on-chain is one of the trivial usages of blockchain, I thought there might be a walking-through document for it. I mean the javascript to call Flow APIs along with Cadence codes to store on the chain. Is there a sample javascript code for calling Flow API to store a string on it?

Yes, please check out the javascript SDK docs for more info about how to build an integration like this: https://docs.onflow.org/flow-js-sdk/

There is a quick start app tutorial there with examples for building a basic Flow App

2 Likes

@Nariman

1 Like

What if we want to verify some hash params in cadence? How to implement it?

1 Like

Hi @Caos ,
Would you please explain more? what do you mean by verifying hash params?

If we use Mapping to store some domains, first of all we need the readable domains name, second we need use hash to make the domains name unique in the storing mapping

So we need to calculate the hash off-chain and verify it on-chain, make sure the domain name corresponding to the hash

1 Like

Thanks @Caos , What do you mean by readable domains?

For example ,I want register a domain named ‘caos’, and contract store the domains infomation in the mapping, store {String: DomainStruct} is good ,but if I want to support more char such as emoji ,the {String: Domain} is not good enough.

Just like ENS have done ,they use sha1 hash fun to calc the domain name and use the hash as a unique key in their mapping.

When user register a new domain name in cadence ,the contract need to verify or calc the name hash and find the record in the mapping .