Closed skyrover7 closed 1 month ago
yea so i didn't need to script.encode, just directly put the script in the txn and it worked!
Yeah the transaction encoder should also handle encoding any scripts that you have in the transaction, so you don't have to encode them separately.
for sure, which is super helpful, i just assumed it needed to be explicitly encoded because that is the flow for ordinals where the script is built and encoded with the Tap class
yea so i didn't need to script.encode, just directly put the script in the txn and it worked!
would be great if you could paste the full code snippet, so others who stumble upon this, like me, can use
I haven't done any runes stuff yet, but if you want to add an OP_RETURN output to your transaction, it should look something like this:
const vout = [{
value : 0,
scriptPubKey : [ 'OP_RETURN', 'hex_data_goes_here' ]
}],
FYI the runes protocol stuffs data in the OP_RETURN output, but that data references other outputs in the transaction by their index, so you have to make sure that your outputs are ordered properly. OP_RETURN outputs typically are the last output in the tx.
Let me know if you have any further questions about it.
Thanks I did figure it out, but it took some trial and error. That snippet will help anyone searching the repo for OP_RETURN. Works great, thanks for the library!
@cmdruid was trying to implement the runes specification on my existing codebase used for inscriptions.
I feel like this should be a straightforward task but for whatever reason once my txn is broadcast the block explorers show UNKNOWN rather than the OP_RETURN. runes protocol aside, i should be able to use an OP_RETURN with any data following it, right?
Here is some sample code
i then add
runestone
as the scriptpubkey of a 0 value txn output. the txn signs and broadcasts no problem.here are some examples on testnet that shown UNKNOWN
It should look something like the OP_RETURN here.
any thoughts appreciated!