Opcodes · splice · enabled

OP_CAT (0x7e)

Concatenates the top two items. Disabled in Bitcoin since 2010 and re-enabled on BCH in May 2018. Covenants use it to build output scripts on the stack.

Verified
Stack in → out
a b → a‖b
Cost
Base instruction cost 100 plus result length. The result may be up to 10,000 bytes since 2025 (was 520).
Bitcoin status
Proposed for Bitcoin (BTC)Disabled in BTC since 2010. BIP-347 proposes re-adding it in Tapscript via OP_SUCCESS126 (same byte, 0x7e); not activated.

Example

<0x76a914> <pkh> OP_CAT <0x88ac> OP_CAT OP_0 OP_OUTPUTBYTECODE OP_EQUAL
Step Stack after (top on the right) What happens
<0x76a914> 76a914 P2PKH prefix: OP_DUP OP_HASH160, push 20 bytes.
<pkh> 76a914 pkh A 20-byte public key hash, from the contract or the spender.
OP_CAT 76a914‖pkh
<0x88ac> 76a914‖pkh 88ac P2PKH suffix: OP_EQUALVERIFY OP_CHECKSIG.
OP_CAT 76a914‖pkh‖88ac A complete 25-byte P2PKH locking script.
OP_0 76a914‖pkh‖88ac 0
OP_OUTPUTBYTECODE 76a914‖pkh‖88ac out0 The locking script of output 0.
OP_EQUAL 1 True only if output 0 pays that address. This is a covenant.

Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.

Where OP_CAT is used

Sources

  1. BCHN upgrade specs: Restore disabled script opcodes, May 2018
  2. Libauth BCH_2023_05 opcodes (bch-2023-opcodes.ts)
  3. BIP-347: OP_CAT in Tapscript