Blockchain Fundamentals: Inner Workings

Blockchain Fundamentals: Inner Workings

Wednesday Feb 21, 2024

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.

  1. 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.

  2. Network propagation Each node that receives the transaction verifies the format and digital signature and then sends it to its peers.

  3. 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.

  4. 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.

  5. 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.

  6. 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?

  1. Header
  2. Metadata
  3. Hash as a reference to the previous block
  4. Hash
  5. A unique identifier for this block
  6. Transactions
  7. 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:

  1. To: Bob’s address
  2. From: Alice’s address
  3. Amount: 1 ETH
  4. Timestamp: The time when the transaction was broadcasted
  5. 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!