Blockchain Fundamentals: Inner Workings
In this course, we will be exploring how exactly the blockchain works. This course assumes you have a general understanding of the moving parts of the blockchain. If you do not, please look at our Blockchain Fundamentals - Introduction course.
How does the blockchain actually work?
Now that we understand the individual parts that make up the blockchain let’s dig into how it all functions together.
We’ll use an example involving the classic Alice and Bob. Alice wants to send 1 ETH to Bob. Once Alice submits her transaction, a few things happen.
-
Transaction broadcasted to the network Alice’s wallet broadcasts the transaction it compiled to the blockchain network. This is usually done through a Remote Procedure Call (RPC) node.
-
Network propagation Each node that receives the transaction verifies the format and digital signature and then sends it to its peers.
-
Validation by Miners Miners will then decide which transactions to include in the next block. They perform more thorough validation by checking if Alice has a sufficient balance to make the transaction, that her signature is valid, etc.
-
Block building Once a miner successfully validates the transaction, they add it to their candidate block. Other miners continually check transactions and fill up their blocks to create a valid block that is appendable to the blockchain. The block is also assigned a header, a hash and the previous block’s hash.
-
Consensus and Block Addition The blockchain network reaches a consensus on the next valid block through the consensus mechanism. The new block is then added to the blockchain, becoming the latest block in the sequence.
-
Confirmation The transaction is now deemed as confirmed and considered part of the blockchain’s history. Multiple confirmations from subsequent blocks increase the security and finality of the transaction.
What are block confirmations, and why are they important?
Block confirmations are simply how many blocks have followed in the chain after your transaction. They are important because there is a chance a blockchain may be reversed (meaning your transaction is undone), which would, in our example above, return the 1 ETH to Alice.
Let me present a different scenario where this could have been used maliciously:
Instead of sending the funds to Bob, Alice sends the 1 ETH to an exchange, which, on first confirmation from a single node, allows Alice to withdraw the funds into her bank account. In doing so, she could receive funds in her bank account, and then when the blocks are reversed, she would still have her 1 ETH. This kind of interaction is called double-spending. It’s a simple attack but also one that can easily be mitigated by waiting a certain number of blocks before allowing Alice to withdraw her funds.
Additionally, the exchange could also monitor different nodes to make sure that the transaction was confirmed on multiple nodes.
This amount of block confirmations varies from chain to chain. On Ethereum, the block confirmation is suggested to be ~7 blocks. On Bitcoin, it’s ~12 blocks.
What exactly do blocks contain?
- Header
- Metadata
- Hash as a reference to the previous block
- Hash
- A unique identifier for this block
- Transactions
- A list of transactions that will be processed with this block
Please check the resources for a link to a block on Etherscan so you can see what it looks like.
What is a transaction?
A transaction contains data that will alter the state of the blockchain. In our example above, the transaction that Alice broadcasted may include the following:
- To: Bob’s address
- From: Alice’s address
- Amount: 1 ETH
- Timestamp: The time when the transaction was broadcasted
- Other metadata (Check the resources for a random transaction on Etherscan)
Of course, depending on the blockchain, this data may vary.
What are the different types of chains?
While there aren’t set “types” of chains, we commonly refer to chains running on the Ethereum “type” of blockchain as EVM chains.
So when we talk about a type of chain, we mean that - under the hood - they are running on the same blockchain technology.
For instance, Bitcoin is its own chain type, different from Ethereum, while Polygon and Binance Smart Chain use the same blockchain technology as Ethereum.
Conclusion
And that's it! You have successfully covered the essentials to truly grasp the blockchain. I know that all of this information might be a LOT to take in, so for now...digest it and then dig into our other courses!