BITCOIN MAINNETLive explorer status
PROGRAMMABLE LOCKS

Bitcoin Script

The small language that decides who can spend each output, from P2PKH to Taproot.

Bitcoin Script

Every Bitcoin output is locked by a tiny program written in Script. Learn how locking and unlocking scripts work together and why Script is limited.

INTERMEDIATE2 min read

The stack

Bitcoin Script runs on a stack: items go on top and operations take them off. Watch a simple script execute step by step with an animated diagram.

INTERMEDIATE2 min read

Script opcodes

Opcodes are Bitcoin Script's instructions: duplicate, hash, compare, check signatures and times. A clear reference to the opcodes you will see most.

ADVANCED2 min read

Pay to public key (P2PK)

The earliest Bitcoin outputs locked coins directly to a public key. Learn how P2PK works, where to find it, and why it was replaced by P2PKH.

ADVANCED2 min read

Pay to public key hash (P2PKH)

P2PKH locks bitcoin to the hash of a public key; to spend, you reveal the key and a signature. Step through the script with an animated diagram.

INTERMEDIATE2 min read

Pay to script hash (P2SH)

P2SH locks bitcoin to the hash of a script that is revealed only when spending, giving complex conditions a short address. Learn how it works.

INTERMEDIATE2 min read

Multisig

Multisig requires several keys to sign, such as 2 of 3, removing single points of failure for theft and loss. Learn how to set it up safely.

INTERMEDIATE2 min read

Timelocks: CLTV and CSV

Timelocks stop bitcoin being spent until a set time. CLTV uses an absolute block or date; CSV counts from when the coins were received. See examples.

ADVANCED2 min read

Segregated Witness (SegWit)

SegWit (2017) moved signatures into a separate witness section, fixing malleability, discounting signature data and making Lightning practical.

INTERMEDIATE2 min read

Taproot

Taproot (2021) lets complex Bitcoin spending conditions look like ordinary payments, using Schnorr signatures and hidden script branches. Learn how.

INTERMEDIATE2 min read

Witness data

The witness is the part of a SegWit transaction holding signatures and unlocking data. It sits outside the txid and is discounted. Learn how it works.

ADVANCED2 min read

OP_RETURN data outputs

An OP_RETURN output carries data and can never be spent, so it never bloats the UTXO set. Learn how it works, what it is used for and its limits.

INTERMEDIATE2 min read

← All Bitcoin topics