P2PKH: BSV's Most Common Payment Script Template Explained
P2PKH (Pay to Public Key Hash) is the most basic payment script in Bitcoin/BSV. This article breaks down its core logic, workflow, relationship with addresses, unlocking conditions, and why BSV developers need to understand it.
Ethan Lin
technical_editor
In a Nutshell
P2PKH stands for "Pay to Public Key Hash." It is one of the most common payment script templates in Bitcoin/BSV.
The core logic is: an output locks funds to a public key hash, and to spend it, the spender must provide a matching public key and a valid digital signature.

What Problem Does P2PKH Solve?
Ordinary payments need to answer two questions:
- When receiving: How to specify who can spend the money in the future?
- When spending: How to prove you are the authorized person?
P2PKH's answer:
- When receiving, the locking script records the public key hash.
- When spending, the unlocking script provides the public key and signature.
- Nodes check if the public key hash matches and verify the signature.
This way, the receiver does not need to expose the full public key during receipt; only the address is required.
Breaking Down the Name
P2PKH can be broken down as:
- Pay To Public Key Hash
- Payment → To → Public Key Hash
Note: It is not a direct payment to a public key, but to the hash of a public key.
The typical flow is:
Private key → Public key → Public key hash → Address → P2PKH locking script
The address is what users see as a payment identifier, while the locking script is the real on-chain locking condition.
Intuition Behind the P2PKH Locking Script
The P2PKH locking script roughly expresses:
- Give me a public key.
- I check if the hash of this public key equals the locked hash.
- Give me a signature.
- I verify the signature using this public key.
- Only if all pass, allow spending.
This is the real logic behind ordinary address payments.
Intuition Behind the P2PKH Unlocking Script
When spending a P2PKH output, the input typically provides:
- Signature
- Public key
These two pieces of data are placed on the script execution stack and run together with the locking script. If the public key hash matches and the signature verifies, the script result is true.
Why Not Lock to the Public Key Directly?
Early Bitcoin also had Pay to Public Key (direct pay to public key). P2PKH chooses to lock to the public key hash for several benefits:
- Shorter addresses, more user-friendly.
- Does not expose the full public key during receipt, improving privacy.
- The public key is only revealed when spending.
- Addresses can include a checksum, reducing the risk of manual input errors.
For beginners, remember: An address usually represents a public key hash, not the public key encoded directly.
P2PKH and UTXO
An unspent P2PKH output is a UTXO. It means:
There is value here. Whoever can provide the corresponding public key and signature in the future can spend it.
When a wallet spends it, it creates an input and provides the signature and public key. The old UTXO is consumed, and new outputs are created.
Why Understanding P2PKH Matters for BSV Development
Even if you primarily use SDKs and wallet interfaces, understanding P2PKH is valuable because it ties together several core concepts:
- Private key
- Public key
- Address
- Public key hash
- Locking script
- Unlocking script
- Signature verification
- UTXO spending
Once you understand P2PKH, learning about OP_RETURN, multisig, custom scripts, and token state outputs becomes clearer.
P2PKH Is Not the Only Script
P2PKH is a common template, but not the only way. BSV Script can express many more conditions, such as:
- Multisignature
- Hash locks
- Custom business scripts
- Data outputs
- Token protocol outputs
But P2PKH is the best template for beginners to understand ordinary payments.
Common Misconceptions for Beginners
- P2PKH is not an account model.
- An address is usually not the public key itself, but an encoding of the public key hash.
- A P2PKH output must be unlocked by a signature and public key in the future.
- P2PKH is a template for ordinary payments, not the only format for all BSV transactions.
- Both public key hash matching and signature verification must pass.
- The locking condition is in the output during receipt; the unlocking material is in the input during spending.
References
Collection
BSV Basics
Part 26 of 43
A curated series covering BSV, blockchain fundamentals, protocol capabilities, and ecosystem knowledge.
Previous part
Deep Dive into Unlocking Script: The 'Key' to Spending Blockchain Transactions
Next part
OP_RETURN: A Beginner's Guide to Writing Data on the BSV Blockchain
Reading path
Progress 26/43
- 01Read articlePart 1
Why BSV Still Matters for Long-Term Settlement
A compact note on settlement design, data permanence, and why builders keep looking at BSV.
Apr 30, 20265 min read - 02Read articlePart 2
P2P Electronic Cash: What Is Peer-to-Peer Electronic Cash?
Peer-to-peer electronic cash is the starting point for understanding Bitcoin and BSV. It emphasizes transferring digital value directly through transactions, signatures, and a public ledger, rather than relying on central platform accounts. This article explains peer-to-peer, cash, double spending, UTXOs, and why BSV emphasizes low fees, high-frequency transactions, and on-chain data.
May 19, 202615 min read - 03Read articlePart 3
Timestamp Server: Why Is Blockchain a Time-Ordered Record?
Blockchain is not just a ledger; it is also a public time-ordering machine. This article explains what the timestamp server means in Bitcoin/BSV, the role of block height and confirmations, and the value of timestamps in double-spend prevention and data attestation.
May 20, 202615 min read - 04Read articlePart 4
Proof of Work: Why Can Miners Order Transactions?
Proof of Work uses a mechanism that is expensive to compute and cheap to verify, allowing miners to compete for new blocks in an open network and using accumulated work to determine the ordering of transaction history. This article explains how PoW works, why miners can order transactions, its security significance, and the miner-economic logic behind BSV’s focus on large blocks, low fees, and high transaction volume.
May 20, 20265 min read - 05Read articlePart 5
How the BSV Network Works: Transactions, Blocks, Fees, and Miner Incentives
This article explains the basic mechanics of the BSV network: how transactions are constructed, how blocks organize them, how miners are incentivized, and why BSV places special emphasis on low fees, large blocks, and high-throughput on-chain transactions.
May 20, 202615 min read - 06Read articlePart 6
Introduction to SPV: Why Lightweight Clients Do Not Need to Download the Full Chain
SPV (Simplified Payment Verification) allows lightweight clients to verify that a transaction is included in a block without downloading the full blockchain. This article explains how SPV works, the role of Merkle proofs, what SPV can and cannot prove, and why SPV is a core capability in the BSV architecture.
May 20, 202615 min read - 07Read articlePart 7
How BSV’s Roadmap Differs from BTC and BCH: Why It Emphasizes On-Chain Scaling, Low Fees, and Enterprise Data
BTC, BCH, and BSV all come from Bitcoin, but their technical roadmaps differ significantly. This article explains why BSV chooses a low-fee, high-volume, large-scale on-chain scaling approach, through the lenses of on-chain scaling, low fees, a stable protocol, SPV, enterprise data, and real-world challenges.
May 20, 202615 min read - 08Read articlePart 8
WIFs, Mnemonic Phrases, and HD Wallets: An Introduction to Key Management in BSV Wallets
WIFs, mnemonic phrases, and HD wallets all relate to key storage, recovery, and derivation, but they mean different things. This article explains their differences, the role of xpubs, and security practices for BSV wallets and application development.
May 20, 202625 min read - 09Read articlePart 9
What Is the Difference Between BSV Mainnet and Test Environments?
Mainnet carries real value, while test environments are for learning and development. This article explains the differences between BSV mainnet and test environments, common risks, SDK usage considerations, and practical environment-separation recommendations for project configuration.
May 24, 20265 min read - 10Read articlePart 10
A Wallet Is Not an Account System: BSV Wallets Manage Keys and UTXOs
A BSV wallet is not a traditional account system. There is no single on-chain balance field; instead, the wallet calculates balances and creates transactions by managing private keys, UTXOs, inputs, outputs, signatures, and related data. This distinction is essential for understanding change, multiple inputs, non-custodial wallets, and application authorization.
May 24, 202615 min read - 11Read articlePart 11
BRC-100: A Standard Interface Between Wallets and Applications
BRC-100 is an interface standard in the BSV ecosystem that describes how applications and wallets communicate. It emphasizes that applications express business intent while wallets retain control of keys, helping non-custodial applications request transaction creation, signing, and returned results in a safer and more consistent way.
May 24, 20268 min read - 12Read articlePart 12
What Is a Transaction Input? Understanding BSV Transaction Inputs and UTXO References
A transaction input is the funding source of a BSV transaction. It references a specific unspent output from a previous transaction and provides unlocking data. Understanding inputs helps explain the UTXO model, outpoints, double-spend conflicts, fee calculation, and transaction debugging.
May 26, 202615 min read - 13Read articlePart 13
Understanding BSV Transaction Outputs: Amounts, Locking Scripts, and UTXOs
A transaction output is a new unit of value created by a BSV transaction, usually consisting of an amount and a locking script. Outputs can represent payments and change, but they can also carry OP_RETURN data, token state, or business records. Understanding outputs, UTXOs, and output indexes is fundamental to understanding BSV transactions and application protocol design.
May 26, 202615 min read - 14Read articlePart 14
What Is a TXID? Its Role, Common Misunderstandings, and Design Tips in BSV
A TXID is the most common transaction identifier in BSV. It can be used to look up transactions, reference outputs, store business records, and build SPV proof flows. But a TXID identifies the whole transaction, not a specific output, and it does not mean the transaction is final. Real applications should store it together with the output index, status, raw transaction, and proof materials.
May 26, 202615 min read - 15Read articlePart 15
Understanding Change Outputs in BSV Transactions: Why They Must Be Explicitly Included
A change output is a key concept in BSV’s UTXO model: old UTXOs must be spent in full, and any unspent amount must be returned to the payer through a new output. This article explains how change works, how it relates to fees, change addresses, privacy, and practical UTXO management.
May 26, 202615 min read - 16Read articlePart 16
How BSV Transaction Fees Are Calculated: Total Inputs Minus Total Outputs
BSV transaction fees are not stored as a separate field. They are calculated as total inputs minus total outputs. Understanding this rule helps developers handle change correctly, estimate fees, manage UTXOs, and avoid accidentally turning remaining balance into fees.
May 26, 202615 min read - 17Read articlePart 17
What Is a Raw Transaction? The Basics of BSV Transaction Serialization, TXIDs, and Signatures
A raw transaction is the original byte representation of a transaction after protocol-compliant serialization, usually shown as a hexadecimal string. It is central to TXID calculation, signing, broadcasting, and debugging, and is a key concept for understanding how BSV transactions work at the protocol level.
May 26, 202610 min read - 18Read articlePart 18
Endian Issues in BSV Transaction Debugging: Why TXIDs Can Look Reversed
Endian is a common byte-order issue when debugging BSV transactions, especially in raw transactions, TXIDs, outpoints, numeric fields, and Merkle proofs. Understanding the difference between display format and serialized bytes helps avoid false “TXID mismatch” or “proof calculation failed” conclusions.
May 26, 202612 min read - 19Read articlePart 19
What Is a UTXO? Understanding the Foundation of the BSV Transaction Model
A UTXO, or “unspent transaction output,” is the basic unit of the BSV transaction model. A wallet balance is not an on-chain account field, but the sum of controllable UTXOs. Understanding UTXOs helps explain BSV inputs, outputs, change, fees, double-spending, Script, and parallel processing.
May 27, 202615 min read - 20Read articlePart 20
In BSV, Spending Means Consuming Old UTXOs and Creating New Ones
In BSV, spending does not update a balance. It consumes old UTXOs and creates new ones. Understanding this model helps explain payments, change, transaction chains, and the basic logic behind tokens and application state transitions.
May 27, 202612 min read - 21Read articlePart 21
One Address Can Have Many UTXOs: Understanding Addresses, Balances, and Transaction Construction in BSV
In BSV’s UTXO model, an address is not an account or a single balance slot. The same address can be associated with multiple UTXOs, and a wallet balance is simply the sum of those outputs. Understanding this is essential for transaction construction, fee handling, UTXO fragmentation, and privacy.
May 27, 20265 min read - 22Read articlePart 22
Why the UTXO Model Is Suitable for Parallel Processing – The Technical Foundation of BSV Scaling
The UTXO model splits state into independent outputs, allowing transaction verification to proceed in parallel, providing a key data structure foundation for BSV's on-chain scaling and high throughput. This article compares the account model with the UTXO model, explains the principles of parallelism, practical limitations, and its relationship with Teranode and application design.
Jun 2, 20264 min read - 23Read articlePart 23
Understanding Bitcoin Double Spend: Why the Same UTXO Cannot Be Spent Twice
Double spending is a core problem for digital cash systems. This article explains the principle, transaction structure, miner's role, 0-conf risk, signatures and double spend, and engineering best practices.
Jun 2, 20264 min read - 24Read articlePart 24
Understanding Locking Script in BSV: The Core Mechanism of Spending Conditions
Locking script is an essential part of a BSV transaction, defining the conditions under which a UTXO can be spent. This article starts from the basics, gradually explaining the location of locking scripts, their relationship with addresses, how they are expressed, and their importance in applications.
Jun 2, 20264 min read - 25Read articlePart 25
Deep Dive into Unlocking Script: The 'Key' to Spending Blockchain Transactions
Unlocking script is the unlocking material in a transaction input that satisfies the locking conditions of a previous output. This article comprehensively explains the concept, location, working principle, and common misconceptions.
Jun 2, 20264 min read - 26Read articlePart 26Current
P2PKH: BSV's Most Common Payment Script Template Explained
P2PKH (Pay to Public Key Hash) is the most basic payment script in Bitcoin/BSV. This article breaks down its core logic, workflow, relationship with addresses, unlocking conditions, and why BSV developers need to understand it.
Jun 2, 20264 min read - 27Read articlePart 27
OP_RETURN: A Beginner's Guide to Writing Data on the BSV Blockchain
Learn the basics of OP_RETURN, how it differs from regular payments, data format requirements, privacy considerations, and use cases.
Jun 2, 20263 min read - 28Read articlePart 28
Understanding Bitcoin Script: A Stack-Based Scripting Language and Its Execution Model
Bitcoin Script is a stack-based scripting language used to verify transaction spending conditions. This article starts with the concept of a stack, illustrates its execution process with examples, and explores key points such as P2PKH, restricted design, and BSV applications, helping readers understand the core mechanism of this on-chain verification language.
Jun 2, 20263 min read - 29Read articlePart 29
Standard Scripts vs Non-Standard Scripts: The Easily Overlooked Boundary in BSV Development
A transaction that is valid under consensus rules may not be processed by the network. Understand standard scripts and miner policies to avoid broadcast failures.
Jun 2, 20264 min read - 30Read articlePart 30
Getting Started with @bsv/sdk: Installation, Verification, and First Steps
Introduces the installation, project setup, and verification process for @bsv/sdk, helping developers quickly enter the BSV development environment and understand the SDK's role in the tech stack.
Jun 15, 20264 min read - 31Read articlePart 31
WalletClient: The Communication Entry Point Between Applications and Wallets
WalletClient is a standardized client for connecting wallets in BSV applications. It enables applications to describe transaction intent while the wallet handles authorization, signing, and UTXO management, thereby isolating complexities like private keys, UTXOs, and signing.
Jun 15, 20264 min read - 32Read articlePart 32
Creating Your First BSV Transaction with createAction(): A Beginner's Guide
createAction() is the core method in the BSV SDK, allowing applications to describe transaction actions via a high-level interface while the wallet handles signing, fees, and broadcasting. This article explains its principles, parameters, and practical usage.
Jun 15, 20264 min read - 33Read articlePart 33
Auto-Select Inputs, Change, and Fees: How the Wallet Builds a Complete Transaction for You
When using the high-level SDK, the wallet automatically selects spendable UTXOs, generates change outputs, and calculates fees. This article explains how this process works, its benefits, and potential risks.
Jun 15, 20264 min read - 34Read articlePart 34
Writing Data to the BSV Blockchain: From OP_RETURN to Application Protocols
BSV transactions can do more than transfer satoshis. By including data outputs, you can record text, hashes, or business events on-chain. This article starts with the first Hello BSV transaction, explains the difference between data outputs and payment outputs, how to construct an OP_RETURN using the SDK, the reason for hex encoding, and how to move toward structured protocol design.
Jun 16, 20264 min read - 35Read articlePart 35
Viewing BSV Transactions with WhatsOnChain: A Complete Guide from txid to On-Chain Structure
This article teaches you how to use the block explorer WhatsOnChain to view transaction details, understand core concepts like inputs, outputs, scripts, and fees, and leverage the explorer to infer the underlying logic of the SDK.
Jun 16, 20264 min read - 36Read articlePart 36
Getting started with BSV transactions: the right way to manually specify inputs
In BSV's UTXO model, manually specifying transaction inputs is a must-have skill for advanced development. This article explains the essence of inputs, the required information, code examples, and common pitfalls, helping you avoid the mental trap of "debiting an address."
Jun 18, 20264 min read - 37Read articlePart 37
Manually Specifying Transaction Outputs: A Key Step in Designing BSV Applications
Learn how Bitcoin transaction outputs work by constructing transactions manually. This article covers output types, change rules, index ordering, and common pitfalls, helping you advance from “sending transactions” to “designing BSV applications.”
Jun 18, 20263 min read - 38Read articlePart 38
Bitcoin Transaction Fees: Calculation, Influencing Factors, and Practical Guidelines for BSV
Transaction fees are not an explicit field but the difference between total inputs and total outputs. Understanding the fee calculation logic, factors affecting transaction size, and BSV network policies is essential for building on-chain applications.
Jun 18, 20264 min read - 39Read articlePart 39
Why Every Input in a Bitcoin Transaction Needs Its Own Signature
Understand the necessity of multi-input signatures in Bitcoin transactions, avoid common misunderstandings, and learn the basics of P2PKH signing, SDK usage, and what signatures actually protect.
Jun 18, 20264 min read - 40Read articlePart 40
BSV Transaction Serialization: From Object to Broadcast
Understanding transaction serialization is key to connecting application development with the blockchain network. This article explains why serialization is needed, the standard transaction structure, the role of hex, serialization and deserialization in the SDK, the relationship with txid, and common misconceptions, helping you move from calling the SDK to debugging on-chain data.
Jun 18, 20264 min read - 41Read articlePart 41
BSV Transaction Broadcasting: A Complete Guide from Construction to Submission
In BSV development, constructing a transaction is only the first step. This article explains the significance of transaction broadcasting, common misconceptions, pre-broadcast checks, how to interpret the return value, and failure reasons, helping developers correctly submit transactions to the network.
Jun 18, 20264 min read - 42Read articlePart 42
Transaction Chains: How a Transaction Spends a Freshly Created UTXO
To truly grasp the Bitcoin white paper's definition of a coin as a chain of digital signatures, you must understand transaction chains. This article starts from the simplest model to explain how UTXOs transfer between transactions and why transaction chains are essential for state management in BSV applications.
Jun 18, 20264 min read - 43Read articlePart 43
The Bitcoin Block Header: The 80‑Byte Foundation for SPV and Light Clients
The block header is an 80‑byte summary of a Bitcoin block. It does not contain full transactions, yet it is the critical structure linking the proof‑of‑work chain and committing to the transaction set. This article explains the header fields, Merkle root, and SPV principles, helping you understand how BSV enables massive scaling.
Jun 20, 20265 min read
Recommended articles
BlockchainJun 2, 2026
OP_RETURN: A Beginner's Guide to Writing Data on the BSV Blockchain
Learn the basics of OP_RETURN, how it differs from regular payments, data format requirements, privacy considerations, and use cases.
BlockchainJun 2, 2026
Deep Dive into Unlocking Script: The 'Key' to Spending Blockchain Transactions
Unlocking script is the unlocking material in a transaction input that satisfies the locking conditions of a previous output. This article comprehensively explains the concept, location, working principle, and common misconceptions.
BlockchainJun 2, 2026
Understanding Bitcoin Script: A Stack-Based Scripting Language and Its Execution Model
Bitcoin Script is a stack-based scripting language used to verify transaction spending conditions. This article starts with the concept of a stack, illustrates its execution process with examples, and explores key points such as P2PKH, restricted design, and BSV applications, helping readers understand the core mechanism of this on-chain verification language.