I have a hash value and I need to store it in the blockchain as part of a transaction. and I need to look for that transaction with that hash later in time.

So creating a contract and storing it in its array/mapping. is this the only solution in Ethereum?


If you want an easy way to fetch that hash later on, you can:

  • use the contract store: array or mapping
  • or use the contract logging system with an event. event LogMyHash(bytes32 indexed theHash);. indexed will ensure you can query by the hash, like a mapping would do.

On the other hand if you did not care about retrieval, but all you wanted to do was quickly add your hash to a dummy transaction, you can send one to your other address and do eth.sendTransaction({ from: you, to: otherYou, data: theHash }). Since there is no code at your other address, data will not trigger anything. But the hash is there for anyone who knows where to look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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