Home

P2SH

P2SH, or Pay to Script Hash, is a type of Bitcoin transaction output that defers the details of the spending conditions to a separate script stored off the blockchain. It was introduced as part of a Bitcoin Improvement Proposal (BIP16) in 2012 to simplify and reduce the size of complex spending rules, such as multisignature requirements. In a P2SH output, the scriptPubKey contains a hash of a redeem script: OP_HASH160 <20-byte script hash> OP_EQUAL. The corresponding address is the Base58Check encoding of that script hash, and on mainnet these P2SH addresses typically begin with the digit 3.

When funds locked with a P2SH output are spent, the spending transaction must include, in its unlocking

Common use cases include multisignature wallets (such as 2-of-3 or 3-of-5 schemes), time-locked or condition-based spending,

script
(scriptSig),
the
redeem
script
itself
and
the
data
needed
to
satisfy
it
(for
example,
the
required
signatures).
The
network
first
hashes
the
provided
redeem
script
and
compares
it
to
the
hash
in
the
scriptPubKey.
If
they
match
and
the
redeem
script
evaluates
to
true
with
the
supplied
data,
the
spend
is
valid.
This
mechanism
moves
the
complexity
of
the
conditions
off-chain,
while
keeping
the
on-chain
output
compact
and
private
until
redemption.
and
other
complex
scripts.
The
main
benefits
are
reduced
on-chain
data
for
complex
setups
and
greater
flexibility
for
wallet
developers.
A
related
consideration
is
that
the
redeem
script
becomes
visible
when
spent,
so
P2SH
does
not
provide
perpetual
privacy
of
the
underlying
conditions.
P2SH
can
also
wrap
SegWit
scripts
(P2SH-P2WSH
or
P2SH-P2WPKH)
for
compatibility
with
newer
technologies.