5

I know Ethereum is more advanced, and allows for more interesting things than associating data to a transaction. But let's say I have a legacy system that uses Bitcoin's OP_RETURN. What options do I have to move from the Bitcoin blockchain, to the Ethereum blockchain?

To put it another way, I need to add data, and then be able to look up that data by some unique id. (like Bitcoin's tx id). Also I need to be able to verify who placed the data. Can I just associate data to a tx? Or should I build a contract with a key-value field for the data, and add some way to verify authorship?

1

1 Answer 1

4

In most of the cases I can think of, what can be achieved with OP_RETURN should be achieved with contracts.

For example what Open Assets does can be done via a contract - either a giant contract with all assets or a simple contract managing each separate asset. For the second option see "token contracts" (read more here and here)

If you really need or insist to copy how OP_RETURN works, that is possible also. Each transaction has (among other fields):

  • recipient
  • value
  • data / bytecode

This data contains the contract bytecode when creating a new contract, otherwise contains the message to be passed when executing a contract.

There is nothing stopping you using the data field when making a transaction between external accounts (i.e. addresses which are not contracts). You'll need to pay appropriate gas as the basic 21000 will not cover you.

Important: this only works between external accounts. For contracts, that field will be interpreted as a command and it is very likely to fail.

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.