Bitcoin Script Opcodes — Common Opcodes & P2PKH Pattern
Bitcoin locks outputs with a small stack-based scripting language. This reference lists the common opcodes and walks through the standard Pay-to-Public-Key-Hash script.
Common opcodes
OP_DUP — duplicates the top stack item. OP_HASH160 — hashes the top item with SHA-256 then RIPEMD-160. OP_EQUALVERIFY — checks the top two items are equal and fails the script if not. OP_CHECKSIG — verifies a signature against a public key and pushes true or false. OP_CHECKMULTISIG — verifies M-of-N signatures for multisig. OP_RETURN — marks an output as provably unspendable, used to embed data.
The standard P2PKH script
The classic Pay-to-Public-Key-Hash locking script is: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG. The spender provides a signature and public key; the script duplicates and hashes the public key, checks it matches the committed hash, then verifies the signature. This is what a 1-prefixed legacy address ultimately locks to.
OP_RETURN and data outputs
OP_RETURN creates an output that can never be spent, letting a small amount of arbitrary data be committed to the chain. Because such outputs are unspendable, they are pruned from the UTXO set. They are commonly used for timestamping or protocol metadata rather than value transfer.
Preguntas frecuentes
What does the standard P2PKH script do?
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG duplicates and hashes the spender's public key, verifies it matches the address's committed hash, and then checks the signature — proving the spender controls the key for that address.
Can OP_RETURN outputs be spent?
No. OP_RETURN marks an output as provably unspendable, so it can hold arbitrary data without bloating the spendable UTXO set. It is used for embedding metadata, not for transferring value.
Herramientas relacionadas
Recarga, obtén tu clave y publica.
Autoservicio. Paga en cripto o con tarjeta. Medido por créditos: las primitivas pesadas cuestan más, las simples son baratas.
Obtener clave API