How Bitcoin Transactions Work?

Reading time:

Views:

bitcoin transactions

What are Bitcoin Transactions?

Bitcoin transactions are records that inform the blockchain network for a transfer of digital value from one bitcoin address to another.

An easy way to think of a bitcoin transaction is the following:

  • The blockchain is like a notebook which keeps the records of all digital value transfers in the network.
  • A transaction is a line of this notebook.
  • A block is a page of this notebook, therefore it is made up of a number of transactions i.e. lines.
  • All users are able to read and write lines (transactions) and pages (blocks) on this notebook, in the case of the Bitcoin blockchain. This may not be possible on private blockchain networks like Hyperledger, but this is beyond the scope of this article.

Public Key Cryptography

Public Key Cryptography facilitates the transfer of the ownership of bitcoins. Therefore, it is significant to understand how the relationship between Private Key – Public Key – Bitcoin Address develops.

Private Key

Cryptocurrency wallets and clients generate private keys in the form of a random number, with the aim to validate ownership and authorize spending of bitcoins. The private key should be kept secret by the owner, since anyone with the private key can use it to sign and spend the value of the associated bitcoin address.

Think of it as the PIN number of your bank account.

Public Key

A mathematical formula based on the Elliptic Curve Digital Sugnature Algorithm (ECDSA), is applied to the private key in order to produce the public key. In addition, each public key associates with a given private key. An individual can use a private key to compute the public key but it is computationally very difficult to use the public key in order to calculate the private key.

The public key determines if a signature by the private key is genuine without revealing the actual private key to the network. It is visible to everyone in the network after the transfer of bitcoins from an address.

Bitcoin Address

A bitcoin address is the public identifier that users have, to receive and send digital funds. It derives from applying the cryptographic hash functions SHA 256, RIPEMD-160 and the Base58Check encoding, to the public key. Check this link for more details regarding the technical steps of creating a bitcoin address.

A hash function is a type of mathematical function which tranforms input data to a unique identifier. A malicious or even slight accidental modification of input data completely changes the hash output. Therefore, different input data generates a different result every time.

You can use this link to input different data using many hash generators and see how the output changes. For example, using the SHA 256 hash function, the word “TrustSwap” produces the output: 9504004ca3344d098c997c8756cb1a3500f5454ae25210083df82b19d7a40786. Using the word “trustswap”, the hash function produces the output: 03f8a477b0a53800502780db849db1af499f9cd3f07be71586329a42a72b6f85

The real magic of bitcoin transactions is that anyone can access the complete history of transactions. Consequently, anyone can verify who the current owner of any amount of bitcoins is, without owners revealing their private keys.

Types of Bitcoin Transactions

Each transaction contains one or more inputs and one or more outputs. You can think of inputs as debits and outputs as credits to a bitcoin account. However, unlike traditional accounts, the value of inputs can be a bit more that the value of outputs. This is because a miner takes this difference as a reward i.e. transaction fee. Let’s have a look at the most common types of bitcoin transactions.

Zero Inputs – One Output

A Coinbase transaction is the first transaction in each block and includes only one output. This occurs because input represents the new coins and the output represents the amount which a miner receives from finding a block. In the case below, the miner receives 6.25 bitcoins which is the current block reward, plus the transaction fees of the block.

One Input – Two Outputs

This is the most common type of a bitcoin transaction. A transfer from one bitcoin address to another which returns some “change” to the original owner.

The output of a transaction is the input of the next transaction from an address. Therefore, this amount must be fully spent in the next transaction. If the value of this amount is higher than what the sender wishes to spend, a new Bitcoin address generates from the recipient and sends the difference as “change” back to the sender’s address.

One Input – Multiple Outputs

Usually multiple outputs of a transaction could represent a payment from one person to many recipients. This can be the case of an organization paying out employees, or even batching outputs by mining pools and exchanges to save transaction costs.

Multiple Inputs – One or Two Outputs

A bitcoin transaction can have multiple inputs. This is usually the case when a wallet generates different addresses and sends multiple smaller amounts to the recipient. These small amounts have been previously received as “change”, therefore they are relatively small. Furthermore, the number of outputs may depend on the number of recipients or whether new “change” is created.

The Big Innovation

The Bitcoin Blockchain is public and available for anyone to access either through a Bitcoin client or an online explorer. This is the big innovation behind this technology – the combination of transaprency, timestamping and decentralization of transactions. Given what you have learnt today, can you find the first ever Bitcoin transaction which took place in 2009? Long Live Satoshi!

Follow The Crypto App blog for more blockchain educational material

Share this article:
Share

Keep Reading:

Staking: Earn rewards holding your crypto
Staking: Earn rewards holding your crypto
Staking can be a good way to earn passive income on your crypto while contributing to a project you believe in. Learn all about staking in this article.
Wrapped tokens: A tool to jump across blockchains
Wrapped tokens: A tool to jump across blockchains
Wrapped tokens are a type of cryptocurrency that keeps a 1:1 ratio to another coin. Learn about wrapped tokens, how do they work and what are they for here.
Crypto trading tips to survive the dip
Crypto trading tips to survive the dip
During market crashes, most people lose their money because they weren't well prepared. In this article, you'll find tips on how to secure your profits.

Stay up to date with our news and updates