How We Added Support for Giant OP_RETURN Data in Money Button

We are happy to announce that as of today, Money Button supports giant OP_RETURN data sizes of up to 100 KB, making it possible to store files such as images, audio, video, documents, and any other type of data in a single transaction on the Bitcoin SV (BSV) blockchain. Money Button provides this service completely for free, and the only fees paid are to miners, which at present market prices are only about 7 US cents per 100 KB.

The easiest way to add OP_RETURN data in a Money Button is with the opReturn parameter:

  opReturn="[data of any length up to about 99900 bytes]"

For more fine-tuned control, you can insert an OP_RETURN script manually into the list of outputs. See our documentation for more information.

Earlier this week, Steve Shadders figured out how to increase the OP_RETURN data size with no changes to the Bitcoin SV node software. You can read his account of how he figured out how to do this in his article. Thanks to Shadders, miners have started accepting OP_RETURN data up to 100 KB in size, an approximately 450-fold increase over the previous limit of 220 bytes.

We already support OP_RETURN data on Money Button and we wanted to add support for larger sizes. The first step was to add the -datacarriersize=100000 argument to our Bicoin SV nodes and then confirm that broadcasting large data sizes was valid and mined. That was easy.

The second step was to fix bsv, our open-source javascript library for Bitcoin SV, to regard large data sizes as valid and to improve tooling to make it easier to produce large data outputs. That was also easy.

The next step was a bit harder. Because Money Button is an iframe, we pass parameters into Money Button via the URL. This turns out to be a problem for large OP_RETURNs because URLs usually cannot be larger than about 4 KB, meaning the maximum size was about 1/25th of the new maximum OP_RETURN data size.

The solution was to add a new API method to load Money Button via the HTML postMessage API instead of the URL. The postMessage API does not have limits like a URL and can be used to send large amounts of data.

The new postMessage API solves several problems. Not only does it allow us to pass large amounts of OP_RETURN data, but it also allows to pass in a large list of outputs. Previously, Money Button supported only about 80 outputs due to the URL limit. Now we support the full limit of 300 outputs.

Furthermore, the postMessage API does not require refreshing the button when arguments are changed. This means the arguments into a Money Button can now be changed instantly without impacting the user experience. This makes new applications possible that require dynamically changing the arguments in a Money Button.

The new large OP_RETURN data sizes on Bitcoin SV are the start of a new era of leveraging Bitcoin as a data carrier. Long-term, miners will be funded entirely by tiny transaction fees on huge volumes of transactions. Thanks to this improvement, it is now possible to build many of the types of applications that will fund miners in the future.

One thought on “How We Added Support for Giant OP_RETURN Data in Money Button

Leave a Reply