bitcoin-nfts / ordinals

A place to track ideas, implementations, and more related to the Bitcoin NFTs working group.
1 stars 0 forks source link

Using OP_DROP to identify data to pass to Stacks #4

Open whoabuddy opened 1 year ago

whoabuddy commented 1 year ago

The idea here is similar to the generic data import proposal from Jude/Pavi, where a specially crafted OP_RETURN would result in miner's putting data into a clarity smart contract. (GitHub issue)

Miners would be the only ones who can write to it, and it would be available to Stacks contracts similar to how the boot contracts are now. The design would be simple: a preamble to identify the tx and a blob of data.

This sounds very similar to how Ordinal Theory defines their Bitcoin scripts with OP_PUSH, e.g.

OP_FALSE
OP_IF
  OP_PUSH "ord"
  OP_1
  OP_PUSH "application/json"
  OP_0
  OP_PUSH ...data...
OP_ENDIF

Instead of using OP_RETURN, Hank recommended OP_DROP in the Stacks forum and a few conversations, which allows the data to be appended to a valid transaction.

One example was including a SIP-018 signed message, which the user could implicitly sign by sending dust to it.

# metadata:
${sip18MessageHash} OP_DROP
# allow sending the bitcoin back:
${temporarySenderPubKey} OP_CHECKSIGVERIFY

Another example from the Magic protocol:

OP_PUSHBYTES_4 ${swapperId}
OP_DROP
OP_IF
  OP_SHA256 OP_PUSHBYTES_32 ${hash}
  OP_EQUALVERIFY
  OP_PUSHBYTES_33 ${supplierPublicKey}
OP_ELSE
  OP_PUSHBYTES_2 f401
  OP_CSV
  OP_DROP
  OP_PUSHBYTES_33 ${swapperPublicKey}
OP_ENDIF
OP_CHECKSIG

What if we used an approach that combined the use of OP_DROP for our purposes and the standard inscription script?

This could be done manually at first and interpreted by a client, and if fed directly into a Clarity contract by miners, would create a valid index on both networks where data would be accessible directly to Clarity contracts without having to query Bitcoin transactions or state.