I'm a total newbie to blockchain and just started with it a week ago. I have already deployed a private Ethereum blockchain and want to use it to ensure document integrity which means that I'll be storing MD5 checksums on the blockchain to check at a later point in time.

Now I understand that a blockchain is not for storing data and one should use OP_RETURN to store such information if desired. This brings me to my question i.e. How do I create such a transaction and add the document's hash to it in OP_RETURN using:

  1. A web3.eth object
  2. Nethereum

Any and all help will be appreciated.

  • I'm voting to close this question as off-topic because You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page. And Reddit might be a good place for chatty questions. – niksmac Mar 2 '17 at 14:37
  • @niksmac Since when has a questioning starting with "How do I..." being called a chatty question? I'd appreciate if you could actually point me to a resource where the statement for creating such a transaction is mentioned. – Syed Mar 2 '17 at 14:45
  • This is more of an architecture design oriented question, just like how to use promises in javascript. Nice edit there ethereum.stackexchange.com/posts/12672/revisions – niksmac Mar 2 '17 at 14:49
  • 1
    Welcome to the community! ethereum.stackexchange.com/questions/1547/… may help and please also check ethereum.stackexchange.com/help – eth Mar 2 '17 at 15:14
  • 1

In ethereum there is no script opcodes so there is no op_return (like in Bitcoin). However you could store data in a similar way by using :

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(1‌​00,'finney'),data:web3.toHex('My Message')})
| improve this answer | |
  • thanks, this was helpful. I've been able to add the data this way and will now give Mikko's approach a try. Is it safe to say that the best way to do this would be using Mikko's Smart contract approach below? – Syed Mar 6 '17 at 9:33
  • it is not about safety but about how do you intend to desing your app if you want to use a smart contract so use it otherwise just send transactions containing your hash. you have the choice – Badr Bellaj Mar 6 '17 at 12:54

Smart contracts can store any data, including document hashes

contract MyHashRegistry {

    mapping (uint => uint) hashes:

    function storeHash(uint documentId, uint hash) {
        hashes[documentId] = hash;

It seems that you do not have yet relevant experience in Ethereum to build your own things, so jumping into conclusion instead of understanding all the steps in between is an issue here. I suggest taking a learning path. You need to

  • Learn Solidity programming language

  • Create a smart contract

  • Learn how to interact with smarts contracts from your computer (web3.js, web3.py)

| improve this answer | |
  • 1
    thanks, I've been able to add the transaction with the way Badr prescribed above but I believe Smart contracts would be the proper way to do it. Will follow the learning path you suggested. – Syed Mar 6 '17 at 9:36

Thought it might be helpful to add the code here for posting the transaction using Nethereum:

var txCount = await web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(senderAddress);
var encoded = web3.OfflineTransactionSigning.SignTransaction(myPrivateKey, receiverAddress, 
                amount: 0, 
                nonce: txCount.Value, 
                gasPrice: 1,
                gasLimit: 100000,
                data: myHexData);

txId = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync(encoded);
| improve this answer | |

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