scriptPubKey
The locking mechanism placed on an output.
A scriptPubKey (more easily thought of as a “locking script”) is a Script that you put on an output to prevent others from spending it.
Standard Scripts
There are a few set patterns of locking scripts that are commonly used in bitcoin:
1. Pay To Pubkey
4104a9d6840fdd1497b3067b8066db783acf90bf42071a38fe2cf6d2d8a04835d0b5c45716d8d6012ab5d56c7824c39718f7bc7486d389cd0047f53785f9a63c0c9dac |
04a9d6840fdd1497b3067b8066db783acf90bf42071a38fe2cf6d2d8a04835d0b5c45716d8d6012ab5d56c7824c39718f7bc7486d389cd0047f53785f9a63c0c9d OP_CHECKSIG
|
hex | opcodes |
Tip: In the raw hex data of the script above, the public key is preceded by a byte to indicate the size of the upcoming public key. For example, 0x41
means “push the next 65 bytes of script on to the stack”.
Opcodes between 0x01
and 0x4e
are used to indicate the upcoming number of bytes of data to push on to the stack.
2. Pay To Pubkey Hash
76a914fde0a08625e327ba400644ad62d5c571d2eec3de88ac |
OP_DUP OP_HASH160 fde0a08625e327ba400644ad62d5c571d2eec3de OP_EQUALVERIFY OP_CHECKSIG
|
hex | opcodes |
Details
This is the most common locking script. You can only unlock this if you have the private key
that corresponds to the public key
placed in to the script.
This is the default locking script used when you make a standard bitcoin transaction. In fact, this locking script is used so often you might think that various “locking scripts” weren’t a thing.
3. Pay To Multisig
51210378ee11c3fb97054877a809ce083db292b16d971bcdc6aa4c8f92087133729d8b211283b5fbf5cc62d4399dfa1025c3e306295264494722c5085ceadadf1291f6812521a31752c9f17c628edc4c69c4c0846f8d814b21e046eabe06f9968a037ce0741c7453ae |
OP_1 0378ee11c3fb97054877a809ce083db292b16d971bcdc6aa4c8f92087133729d8b 1283b5fbf5cc62d4399dfa1025c3e306295264494722c5085ceadadf1291f68125 a31752c9f17c628edc4c69c4c0846f8d814b21e046eabe06f9968a037ce0741c74 OP_3 OP_CHECKMULTISIG
|
hex | opcodes |
4. Pay To Script Hash
a91410b0ed2d1698ff0f0ea151cf41988d05b728746a87 |
OP_HASH160 10b0ed2d1698ff0f0ea151cf41988d05b728746a OP_EQUAL
|
hex | opcodes |
5. NULL DATA
6a0b68656c6c6f20776f726c64 |
OP_RETURN 68656c6c6f20776f726c64
|
hex | opcodes |