New: Wallet recovery made easy with Ledger Recover, provided by Coincover

Get started

Up your Web3 game

Ledger Academy Quests

  • Test your knowledge
  • Earn POK NFTs
Play now See all quests

The Classroom

PATHWAY F) Blockchain Basics

chapter 1/4

How Does a Blockchain Transaction Work?

Read 5 min
Beginner
BOOK WITH PAGES
KEY TAKEAWAYS:
— Even if you’re familiar with crypto, you might still be unsure of exactly how a blockchain transaction works.

— Blockchain is a distributed ledger that is kept running by various parties, such as nodes and miners, all of whom have the incentive to act.

— Factors such as transaction size, timing, block size and network usage all affect how your transaction will take place. Understanding the mechanics of that system will help you navigate your future transactions.

You might already know about blockchain technology, and maybe even how your favorite cryptocurrency works, but do you know what a blockchain transaction is and how it works under the hood?

Well on a base level, blockchain is just a massive distributed ledger or database, with its data stored on every computer in the system rather than a server. Its primary purpose is as a method of peer-to-peer (P2P) transfer. In short, it allowed people across the world to send digital assets amongst themselves without a need for a central entity. But it’s not just about the transfer of digital assets either. Blockchain transactions offer great solutions for digital verification and authentication too. 

That said, there’s one core feature of blockchain networks that make these use-cases slightly tricky. Since many blockchains are completely transparent and public, it can make the storage of sensitive information challenging. So how does the blockchain get around that?

Well, there’s a lot more to transactions than just how they handle transparency. But before we get there, let’s dive into the basics. In fact, what is a blockchain transaction exactly?

What is a Blockchain Transaction?

In very simple terms, a blockchain transaction is when one person transfers a digital asset they own to another person. The transaction itself will always include; the amount, the destination of the funds and a signature to prove its authenticity. Plus, you’ll usually initiate a blockchain transaction using a crypto wallet’s interface. 

But there’s a bit more to it than that.

To explain, these features mean blockchain transactions are potentially revolutionary in the realm of transferring valuable assets. To understand exactly why, let’s explore what blockchain transactions are for in the first place:

What is a Blockchain Transaction For?

Decentralized Peer-To-Peer Transfer

The most obvious use-case of a blockchain transaction is the decentralized peer-to-peer transfer of digital assets. See, the information on a public blockchain is stored, maintained and processed by multiple computers in the network called nodes. Whereas internet data lives on servers with a single gatekeeper, there are multiple nodes storing blockchain data, with each node storing a full copy of the chain. This means blockchains can process peer-to-peer transfers in a way that wasn’t previously possible. 

Since transactions are processed by nodes in a network, you don’t need to rely on a centralized entity. Plus, you can transact with strangers without worrying about if they will hold up their end of the bargain—the network will make sure they do. 

Authentication and Verification 

A blockchain transaction is also for proving ownership over funds, a specific address, or even a specific asset. It may surprise you that this doesn’t always need to be for financial reasons though. Many blockchain transactions are also for the purpose of proving ownership over on-chain certificates or even specifically for allowing users access to token-gated platforms.

How Does a Blockchain Transaction Stay Secure?

The whole point of a blockchain transaction is to allow peer-to-peer transfer without revealing sensitive information to anyone other than the intended recipient. You wouldn’t want someone to intercept your transaction and steal the gift intended for your friend, right?

So how does your information stay secure on a public and transparent network? 

Public Key Cryptography

Well, it’s mainly thanks to Public Key Cryptography. To explain, you can’t have a transfer from person to person without separate accounts. Accounts on blockchain networks work using public and private key pairs. These two “keys” are each a series of letters and numbers but they have an important purpose.

Your private key has the power to control your entire account. This allows you to make decisions on the blockchain, or in other words, sign transactions. Your public key serves the opposite purpose. Although it is derived from your private key, meaning they have an inherent link, your public key is safe to share with anyone. No one can gain access to your account with only the public key, meaning this is the address you can use to receive assets—even from strangers. In fact, the blockchain address you use to receive crypto from friends is simply a hashed version of this public key. 

Since your public key is included in any transaction you sign with your private key, all participants on a blockchain can check the validity of a transaction. The system verifies the signature itself, all the nodes have to do is check that the person who signed the transaction has the corresponding public key. Once the system processes the transaction, only the owner of the corresponding private key can access the funds. Each account only has a single private key, meaning no other signature can unlock the funds at that address.

Essentially, this is how public key cryptography works to keep your blockchain transactions safe on a public network.

How Does a Blockchain Transaction Work?

So now you know what a blockchain transaction is and what they are for, what about how they work?

Well, to initiate a transaction, you probably know you’ll need these public and private keys, and you’ll typically access them through the interface of a crypto wallet. But beyond that, how does the transaction process work exactly? Let’s explore each phase step-by step:

Creating a transaction

Before a blockchain transaction actually becomes a transaction, it starts life as the “intent” in a crypto wallet. This is essentially like an electronic proposal, and it will show you the details of a proposed transaction before you agree to it. For example, if you were initiating a transaction to send ETH to a friend, it would contain the sender’s address (your public key), the destination address (wherever you’re sending funds), the subject of the transfer (the amount of ETH you want to send) and any other conditions.

Signing the Transaction

When you approve a transaction, you sign it with your private key. This proves that you own the account you intend to send money from and agree with the conditions of the transfer. This signed transaction also contains the information for where the assets should move—a specific public address. That allows the recipient to access the funds with their associated private key later.

Distribution To The Nodes

Once you sign a transaction, it’s then distributed to the crypto nodes. Within each node, the transaction enters the mempool. This is like a waiting room for transactions, but it’s important to note that there’s not a single mempool, there is one for each node. This means the nodes may validate transactions in a different order in this phase. Plus, some mempools are completely private. Since anyone can be a block creator, it actually means you can validate your own transactions and include them in a block. This means that some block creators will make their mempool private, only processing transactions from themselves and their associates.

Verification in the Mempool

It’s within the mempool that a node categorizes a transaction into one of two different statuses: queued or pending. Queued transactions are yet to be validated. To validate your transaction, nodes use your public key (which was included in the transaction) to check if your account has the digital assets you want to move. It also checks the validity of your signature. If everything is fine, the node validates the transaction and passes it on to the next node. Then the process continues. 

Block Creators

So in a system that has no central structure, you might wonder who actually adds the transaction to a block and broadcasts it. Well, most blockchains have a set of special nodes that can add new blocks to the chain. If you’ve ever wondered why we pay gas fees; here’s your answer: They compensate for the financial burden of creating a block.

On proof-of-work networks, like Bitcoin, those are miners, and these participants create new blocks by solving complex mathematical problems, which requires specialized equipment and a lot of energy. 

On a proof-of-stake blockchain these block creators are named validators. Instead of racing to solve a complex mathematical problem, validators must lock up a certain amount of cryptocurrency in order to create a block. In this system, the creator of the block is chosen using either a voting mechanism, or simply by which validator has the most “stake”, i.e. coins locked up in the system.

So, each blockchain has a different method of choosing a block creator, and it’s these special nodes which are responsible for proposing blocks.

Block proposal

Next, the block creator will choose a transaction from the mempool and propose to add it to the chain. The block is sealed with a hash, which basically includes all of the transaction information. 

Broadcasting and Verification

Next, the miner or validator node will broadcast the transaction to the network. This means all of the nodes will receive the information of the proposed block and verify its details.

For example, on a proof-of-work network, the block creator must find the correct solution to an incredibly complex computational problem. Only the quickest accurate block creator will get to propose the block. But following that, all of the other nodes will also solve the problem too–essentially checking that the proposed solution is correct. Plus, they will check all of the transaction details, verifying the sender has the funds they want to send, and the transaction fits the network’s underlying rules, also known as its consensus mechanism. These rules are the same in all network nodes scattered across the planet – meaning they will all come to the same conclusion for each block. 

Consensus

Consensus is reached when the majority of nodes reach the same conclusion: If the proposed block is valid, the nodes agree to add it to the ledger. So if you were sending cryptocurrency to a friend, the copy of the blockchain in each node would update to remove the funds from your account and add them into your friend’s. At this point, the transaction is finalized and the block creator receives the block reward.

Next, the other nodes in the system remove the transaction from their mempools and they all move on to the next block.

How Do Blockchains Solve Discrepancies in The Chain?

Unlike in the mempool, nodes must all receive validated blocks in the same order. Once the transaction is included in a block, it becomes an immutable part of the blockchain’s history. That’s because each block’s hash relies on the subsequent and previous blocks. This means, if a transaction is altered, it will undermine the security of the whole network. Essentially, the nodes can identify bad transactions as a single mistake will affect the validation of subsequent blocks.

So, we know how this can protect us from bad actors pushing through invalid transactions, but what about mistakes?

Well, some nodes might be slower or faster to send around information than others. To help curb any discrepancies, many networks also have in-built rules. For example, on the Bitcoin network, the version of the chain with the longest valid chain of transactions is the “true copy”. This is because Bitcoin prioritizes the version of the chain which the most work already completed. This guarantees all nodes update to the most recent chain.

How Blockchain Transactions Work: The Bus Station Analogy

Understanding block times, mempool size, and pending transactions are key to understanding not only how the blockchains work but for comparing different chains. It can be technical, so let’s use an example to illustrate exactly how it works.

Block size is like the Bus

Imagine a bus station. Each bus represents a block that is going to be included on the blockchain and each person at the station represents a blockchain transaction waiting to be processed. Each bus can only hold a certain number of people, but depending on the sizes and needs of the people, that number can vary from bus to bus. 

Some people are smaller than others, and therefore take up less space on the bus. Some people are richer than others, and more willing to pay for a first class ticket- just to board before the rest.

Blockchain transactions are similar. Some contain lots of information, and some contain less. However, there’s only a limited amount of space in a block. Then, just like our first class passengers, some participants are willing to pay a higher fee to slip their transaction in first. 

The Ticket Officer is Your Consensus Mechanism

Just like a bus station’s ticket officer will check all of the passengers have the correct tickets for the bus, the consensus mechanism of a blockchain will allow the nodes to verify if a transaction is valid. Using this information, they send each person to the waiting area.

Once the passengers are ready to depart, or our transactions are ready to be included in a block, it’s time to broadcast them. For this, we rely on a block creator (or a bus driver in this analogy). For doing this work, the bus driver receives payment, just like our block creator receives rewards for their work.

However, this leads the bus driver, or our block creators, to prioritize the transactions with the highest fees. Simply, their rewards are entirely dependent on how much the passengers (or transactors) are willing to pay. Unfortunately, this has a knock-on effect. During times of high network congestion, this can skyrocket network fees. To explain, if the network is busy, you’re fighting to pay a higher fee than other transactors. Essentially if there are only a few buses, and the bus drivers get paid by the passengers, those willing to pay the most go first. And that’s essentially how block creators handle blockchain transactions too.

Image credit: TxStreet.com

Blockchain Demystified

Now you know all about how a blockchain transaction works, and how the mempool, block creators and consensus rules all work together to keep you secure. So, it’s easy to see that these transactions are at the heart of our decentralized future. Without them, decentralized finance, on-chain governance and even creative innovations like blockchain games and metaverses wouldn’t exist! In short, they are creating a fairer balance of power between big central entities and regular people.

But it’s not just decentralization either. Blockchain transactions open up a whole new world of possibilities in the way we look at verification and authentication. Yes—a blockchain transaction is not just for transfer of assets. It also has a strong use-case as a tamper-proof form of validating ID, ownership over assets and much much more.

In short, blockchain transactions are about much more than money: They offer ownership, validation—and essentially—freedom.

Knowledge is Power.

Trust yourself and keep on learning. Understanding the mechanics of blockchain gives you a major edge when it comes to navigating the space. So dive into our School of Block episode all about the details.


Related Resources

Stay in touch

Announcements can be found in our blog. Press contact:
[email protected]

Subscribe to our
newsletter

New coins supported, blog updates and exclusive offers directly in your inbox


Your email address will only be used to send you our newsletter, as well as updates and offers. You can unsubscribe at any time using the link included in the newsletter.

Learn more about how we manage your data and your rights.