Bitcoin

script – Is it possible to include arbitrary data using OP_DROP?

OP_RETURN is limited to only 80 bytes according to Bitcoin Core’s default standard rules. Some people increase this limit using: -datacarriersize option. Others are running Peter Todd’s “Libre Relay” patch, which removes this and other standard restrictions and automatically connects to other nodes running the patch. As a result, many transactions exceeding this limit have been mined recently, so there may actually be no need to devise a way to circumvent it.

Moreover, OP_RETURN is one of the few standard output script templates. putting <data> OP_DROP Adding it to the output script makes it non-standard according to Bitcoin Core (and most other implementations) rules. What you really need is to put this in a script that is exposed to input, say a P2WSH watch script or a P2TR leaf script. Doing it this way also means that the data leverages discounts on witness data.

but, <data> OP_DROP It’s still a bit suboptimal if you’re trying to push for something big. The maximum push size allowed by the consensus rule is 520 bytes, so you need to split the data into 520-byte chunks as follows: <data> OP_DROP <data> OP_DROP ..., which requires multiple delete opcodes. A more efficient way is OP_FALSE OP_IF <data> <data> ... OP_ENDIF, popularized by ordinal inscriptions, so they are also called “inscription envelopes”. (There is currently a movement to make this particular pattern essentially non-standard. I’ll leave it as an exercise for the reader to see how likely this will be successful.)

Related Articles

Back to top button