How Do Bitcoin Transactions Actually Work?


For a blockchain developer or an enthusiast, it’s always wise to know how Bitcoin transactions work. You must know what happens when you send Bitcoins to your friend or once you broadcast a transaction to the blockchain network. 

Now, why is it important to have information about Bitcoin transactions – because the entire blockchain network is developed on such transactions. Bitcoin transactions are an amalgamation of inventive cryptography, non-Turing complete scripting, and data structures. Blockchain is extremely flexible as common transactions are simple, and it also allows developers to encode customized transactions.

Role of Bitcoin Transactions in the Bigger Picture

Nodes and blockchain are the two primary parts involved in Bitcoin transactions. The role of a node is to update the blockchain network at regular intervals. Now, we know that blockchain is a series of blocks, and these blocks contain all transactional data. 

Blockchain enthusiasts can use Bitcoin transactions in creative ways to fulfill a myriad of customized goals. So, let’s begin by understanding the most typical and common Bitcoin transactions, i.e., pay-to-script-hash type. These transactions amount to about 99% of all Bitcoin transactions. 

Now, let’s try and develop a mental model. Most people believe that Bitcoin is an account-based structure, which means that you send Bitcoin to your friend, and you have the balance amount. In the real banking world, the intermediary also charges a transaction fee from you. So, Bitcoin transactions, in the simple case, could be thought of as inputs and outputs. For example, if you send Bitcoin to your friend, the output will reflect in your friend’s account, while inputs are proof that you’ve paid to your friend. In such a case, there exists only one input and one output.

Exploring Different Aspects of Bitcoin Transactions

Now, it’s time to understand the mechanics of a Bitcoin transaction. Three crucial parts constitute a Bitcoin transaction- input(s), output(s), and header. These parts, in combination, create a raw transaction that gets broadcasted between peers.

Components of Header


Blockchain network uses hash values as a pointer, and a means to inspect the validity of a transaction’s data. 


It maintains a record of the total number of inputs in the transaction. Vout_sz keeps records of outputs.

Ver or Version

It’s the version of the header that gets used to verify the block. The latest version of the header was launched in a soft fork and was activated in December 2015.  


It depicts the earliest time that a block can be entered into the blockchain. 

Components of Input(s)


It’s an index that keeps records of outputs involved in the previous transaction. It’s the real output you’re sending.

Previous Output Hash 

Basically, it describes the money you’re about to spend on the transaction. It’s a hash pointer to any unspent transaction output. 


scriptSig is a spending list that verifies the developer of the transaction has access to spend the money.

Components of Output(s)


It’s one of the two scripts provided in any transaction and it’s a pointer to the receiver’s hashed public key. 


As the name suggests, it shows the value of Satoshi spent.

Verification of Transactions

The primary role of a node in a blockchain network is to check the validity of any incoming transaction. It verifies that money isn’t getting created or data isn’t getting tampered with. Few important aspects that a node checks are-

  • Unspent outputs can never be claimed. All claimed outputs get included in the unspent transaction output (UTXO) pool.
  • The signatures on every input must be valid. So, the combined scripts must be true after its continuous execution.
  • No more than once should UTXO be spent on the transaction. 
  • Transactional output values must be non-negative. 
  • The sum of input values in the transaction should be more than the sum of the output values.

A Typical pay-to-PK-Hash Transaction

We know that Bitcoin has its scripting language that is flexible enough to allow developers to develop customized transactions. There are around five types of transactions that generally get accepted by Bitcoin clients. However, clients that will accept other types of transactions for a fee also exist. 

A combination of a pair of scriptSig/scriptPubKey must evaluate a typical pay-to-script-hash transaction to be genuine. So, the spender gives a scriptSig that gets accomplished and is then followed by the scriptPubKey of the previous transaction. Both scripts share the same stack.

So, a typical pay-to-PK-hash type of transaction is extremely straightforward. It ensures the privacy and safety of any Bitcoin transaction because the recipient with the correct public key pair is able to claim and spend Bitcoin. When a transaction meets all criteria and gets verified by the nodes, it gets added to the blockchain network. The pay-to-PK-Hash transaction is the most basic type of Bitcoin transaction and knowing its aspects can help a developer to advance their career.