Bitcoin

taproot – What is the difference between P2PKH and tapscript using opcodes from a developer perspective?

I’ll use ordinal numbers as an example because they explain my question most effectively. What I understand is that you create an ordinal by writing an opcode in the transaction, just like you would in a non-tabroot transaction. If you have performed a typical P2PKH transaction

"scriptPubKey": "OP_DUP OP_HASH160 HASH_OF_PUBKEY_IN_HEX OP_EQUALVERIFY OP_CHECKSIG"

I use it as a locking script, but if you want to do ordinal numbers, you can just write a locking script.

"scriptPubKey": "OP_DUP OP_HASH160 HASH_OF_PUBKEY_IN_HEX OP_EQUALVERIFY OP_CHECKSIG OP_FALSE OP_IF OP_PUSH "ord" OP_PUSH 1 OP_PUSH "text/plain;charset=utf-8" OP_PUSH 0 OP_PUSH "Hello, world!" OP_ENDIF"

This seems to mean that ordinal numbers can be performed on Bitcoin transactions that are not taproot addresses. So I was able to create an ordinal number with the P2PKH address.

So what does tapscript actually do that P2PKH doesn’t?

Related Articles

Back to top button