Jeff Flowers & Yvonne Tang / 11 June 2015 / Bitcoin/Blockchain / 18223

Example 2. Pay-to-Public-Key-Hash (P2PKH) + OP_RETURN

In this example, we transferred the complete value from one UTXO (Unspent Transaction Output) into another Bitcoin Testnet address, with an additional OP_RETURN output (2 outputs total). Note: No miner’s fees for this example for simplicity.

Transaction ID (TXID): 


From (Payer):

  • Address: mokJKW1AjFTHHjA78kXhoxFDc6nkTAVYvb
  • Total Value: 200,000 Satoshi’s
  • Index (or Output No.): 1
  • Pub Key: 027137d153419cbfe555b69a17c862978afa56cc2562568cfbae842c47636991a4
  • Priv Key (WIF): cU7mhkBwtRdsDydM1keG98DuQdN2g6PVuwHUh5E26fZNz4t8Rbvh

To (Payee):


  • Data (ASCII): How is everyone!
  • Data (HEX): 48 6f 77 20 69 73 20 65 76 65 72 79 6f 6e 65 21

Raw Hex Transaction Script

The first part of the transaction script is very similar to the simpler example in Deconstructing Bitcoin Transaction Part 1. For this example, we will start the deconstruction after the disabled sequence number "ffffffff" in grey, since this part will include the OP_RETURN script which was not covered in Part 1.

Hover over each section of the script to see what they are.

01000000017df4eee40fef1cf0ac17bb9e723489a078511d8b402b1063d00a5f42dd5fa97b010000006a4730440220779202bedffce6d14c1d3918215b46de57aa3efb873455b0697ab9002a6226d3022039d684012fa8c92d8fe100cb23ec7c07a0129a58b55e82e507c78484b1ef378f0121027137d153419cbfe555b69a17c862978afa56cc2562568cfbae842c47636991a4ffffffffSequence number, disabled for this transaction. However if non-zero locktime is used, then at least one input must have a seq number below 0xffffffff 02Number of outputs followed in HEX (2 outputs, in this case, one is the OP_RETURN) 400d030000000000Value to be transferred in Satoshi for the 1st output (in this case, 200000 Satoshi), in Little-Endian. 19Size (in bytes) of the Locking Script (in this case, P2PKH) which follows. This is also in HEX. 76OP_DUP (duplicate), part of the scriptPubKey/Locking Script. a9OP_HASH160, part of the scriptPubKey/Locking Script. 14PUSHDATA 14 - Size (in Bytes) to push to stack, part of the scriptPubKey/Locking Script. This is also in HEX. e20cf24f62878ad5da120bd1efe6bcd6b1e13ea3Hash of the Destination Public Key 88OP_EQUALVERIFY, part of the scriptPubKey/Locking Script. acOP_CHECKSIG, part of the scriptPubKey/Locking Script. 0000000000000000Value to be transferred in Satoshi for the 2nd output (in this case 0 because this is the OP_RETURN part) 12Size of the script that follows (in HEX). In this case, 12 in HEX = 18 bytes in decimal. 6aOP_RETURN - immediately marks transaction as invalid/provably unspendable. 10PUSHDATA 10 - size of data to push to the stack. In this case, 10 in HEX = 16 bytes in decimal. This is the size of the OP_RETURN data in our example. 486f772069732065766572796f6e6521The OP_RETURN data in HEX. In this case, this is "How is everyone!" in HEX. Use a HEX to ASCII decoder to do this conversion. 00000000nLockTime, can be either UNIX time or Block Height depending on usage. Before this time, the transaction cannot be accepted into a block. In this example, nLockTime is 0, meaning that there is no nLockTime specified and thus the transaction is executed immediately.

Great Tools At Helping to Understand Transactions:

Add comment

Security code

Talk to Us!

Get a quote, give us suggestions, or send us a hello :)


San Mateo, California

PGP: 20AE A7E7 6CA8 F81B 4FB1 C942 BA34 7830 1DEB 320E