← Back to Glossary

ScriptPubKey

ScriptPubKey (Script Public Key) is the locking script attached to a Bitcoin transaction output. It defines the conditions that must be satisfied before the output can be spent in a future transaction. Every UTXO on the Bitcoin network is protected by a ScriptPubKey that specifies the rules for unlocking and transferring ownership.

ScriptPubKey Explained in Simple Terms

Whenever Bitcoin is sent to someone, the network doesn't simply record an owner. Instead, it creates a transaction output and attaches a set of spending rules to it.

These rules are stored inside the ScriptPubKey.

You can think of ScriptPubKey as a digital lock placed on a piece of Bitcoin. The lock specifies what proof must be provided before the funds can be spent.

In most cases, the rule is simple:

"Provide a valid digital signature from the private key associated with this address."

Until those conditions are met:

  • the Bitcoin remains locked

  • the output remains a UTXO

  • ownership cannot be transferred

This mechanism is one of the foundations of Bitcoin's security model.

How ScriptPubKey Works

Every Bitcoin transaction output contains a ScriptPubKey.

The process works as follows:

  1. Transaction Created Bitcoin is sent to a recipient.

  2. Output Generated The transaction creates a new output.

  3. Locking Script Attached A ScriptPubKey is added to the output.

  4. UTXO Created The output becomes an unspent transaction output.

  5. Future Spending Attempted The spender provides unlocking data through ScriptSig or Witness data.

  6. Scripts Executed Bitcoin nodes evaluate whether the unlocking conditions are satisfied.

The relationship can be summarized as:

If validation succeeds, the output can be spent.

Example of ScriptPubKey in Practice

Imagine Alice sends Bitcoin to Bob.

The transaction creates an output containing:

  • a Bitcoin amount

  • a ScriptPubKey

The locking script specifies that future spending requires:

  • the correct public key

  • a valid digital signature

Months later, when Bob wants to spend the Bitcoin, his wallet provides the required cryptographic proof.

Bitcoin nodes verify that the proof satisfies the ScriptPubKey. If it does, the output can be spent and new outputs are created.

Why ScriptPubKey Matters

ScriptPubKey is one of the key mechanisms that allows Bitcoin to function without centralized control.

It enables the network to:

  • define ownership rules

  • verify spending rights

  • secure UTXOs

  • prevent unauthorized transfers

  • support programmable transaction conditions

Without ScriptPubKey, Bitcoin would have no reliable way to determine who is allowed to spend a transaction output.

ScriptPubKey vs ScriptSig

ScriptPubKey

Located in:

  • transaction outputs

Purpose:

  • lock Bitcoin

  • define spending requirements

Created when:

  • a transaction output is generated

ScriptSig

Located in:

  • transaction inputs

Purpose:

  • provide unlocking data

  • satisfy ScriptPubKey conditions

Created when:

  • an output is spent

In simple terms:

  • ScriptPubKey creates the lock

  • ScriptSig provides the key

Both must work together for a transaction to be valid.

Common ScriptPubKey Types

Bitcoin supports several common locking script formats.

Pay-to-Public-Key-Hash (P2PKH)

The traditional Bitcoin address format.

Requires:

  • public key

  • valid signature

Pay-to-Script-Hash (P2SH)

Locks funds to a script rather than directly to a public key hash.

Commonly used for:

  • multi-signature wallets

  • advanced spending conditions

Pay-to-Witness-Public-Key-Hash (P2WPKH)

SegWit version of standard address locking.

Benefits include:

  • lower transaction fees

  • improved efficiency

Pay-to-Taproot (P2TR)

Modern Taproot-based outputs.

Provides:

  • better privacy

  • more efficient scripting

  • support for Schnorr signatures

ScriptPubKey and Bitcoin Script

ScriptPubKey is written using Bitcoin Script, a stack-based scripting language built into the Bitcoin protocol.

Bitcoin Script is intentionally limited.

It supports:

  • signature verification

  • conditional logic

  • time-based restrictions

  • multi-signature requirements

However, it is not a fully programmable smart contract language like those found on some other blockchains.

This limited design helps improve security and predictability.

ScriptPubKey and UTXOs

Every UTXO on the Bitcoin network contains a ScriptPubKey.

When a node validates a transaction, it checks:

  • whether the UTXO exists

  • whether the output remains unspent

  • whether the provided unlocking data satisfies the ScriptPubKey

Only then can ownership be transferred to a new output.

This process is repeated for every Bitcoin transaction ever confirmed.

ScriptPubKey and SegWit

Before SegWit, unlocking data was stored entirely in ScriptSig.

After SegWit:

  • signature data moved to the Witness structure

  • ScriptPubKey remained responsible for defining spending conditions

As a result, ScriptPubKey continues to play a central role in transaction validation regardless of address type.

Related Bitcoin Terms

  • ScriptSig

  • Bitcoin Script

  • UTXO (Unspent Transaction Output)

  • Transaction Output

  • SegWit

  • Taproot

Frequently Asked Questions

Still have questions about ScriptPubKey?

Have traffic?

Earn with the best product in cloud mining

Become a partner
15%

First purchase

On every new user’s first purchase. No limit on the purchase amount.

5%

Repeat purchases

Earn for life from every repeat purchase. When the user buys again, you earn again.