Blockchain and Bitcoin Explained

Blockchain and Bitcoin

Blockchain Basics

  • Blockchain involves a network of nodes (computers), each maintaining their own copy of the blockchain.
  • There isn't one central blockchain; instead, each participant has their own, synchronized version.
  • Nodes agree on the state of the blockchain through consensus mechanisms.
  • Initially, each blockchain contains three blocks represented by different colors (red, orange, and green).
  • Nodes then independently try to build a fourth block.

Transactions and the Memory Pool (Mempool)

  • Blocks contain transactions made between people using a cryptocurrency (e.g., Bitcoin).
  • Bitcoin was the first cryptocurrency to utilize blockchain technology.
  • When a user initiates a transaction, the request goes to the mempool, which is a pool of pending transactions.
  • Nodes fetch transactions from the mempool to build their blocks.
  • Each node builds its fourth block independently.

Block Structure: Hash, Block Number, and Transaction Data

  • Each block has a unique hash, determined by its block number and the transaction data it contains.
  • A hash is like a fingerprint, generated by an algorithm.
  • Bitcoin uses the SHA-256 hashing algorithm.
  • Example: Inputting "Anakin Skywalker" into SHA-256 generates a unique hash.
  • Changing the input data results in a different hash.
  • The block number and transaction details are inputted into the hashing algorithm to generate the block's hash.
  • If any transaction detail changes, the hash will also change.

Nonce and Mining

  • A nonce is a user-decided number that also influences the hash output.
  • Changing the nonce value alters the generated hash.
  • The block number and transaction data remain constant, but the nonce can be manipulated.
  • Mining is the process of searching for a nonce that results in a hash that complies with the blockchain's rules.
  • For example, a rule might state that a valid block hash must start with two zeros.
  • The mining process involves trial and error to find a nonce that produces a valid hash.
  • A nonce that leads to a valid hash is called a golden nonce.
  • In reality, the requirement is more like 18 leading zeros instead of just two.
  • The difficulty (number of leading zeros required) changes approximately every two weeks.
  • As a reward for finding the golden nonce, miners receive freshly minted Bitcoin.

Block Validation and Chain Extension

  • The node that finds the golden nonce first announces it to the other nodes.
  • Other nodes verify the found nonce and the resulting hash.
  • If valid, they add the new block to their own chain.
  • The node that found the golden nonce receives newly minted Bitcoin as a reward.
  • Finding the nonce requires significant electricity consumption, making it an expensive endeavor.

Mining Difficulty

  • The mining difficulty level (number of leading zeros required) changes every two weeks to ensure mining remains worthwhile.
  • The difficulty is adjusted based on network participation to balance the cost and reward.
  • If fewer people are mining due to high electricity costs, the difficulty decreases, requiring fewer leading zeros.

Linking Blocks: Previous Hash

  • The hash of the previous block is included in the calculation of the current block's hash.
  • The first block in the chain is called the genesis block, and its previous hash is all zeros.
  • Each subsequent block includes the hash of the block that precedes it, forming a chain.

Tampering and Chain Immutability

  • If a transaction in a previous block is altered, the hash of that block changes.
  • This invalidates the hash of the subsequent block because it contains the previous (now incorrect) hash.
  • To alter a transaction, one must remine the block containing the transaction and all subsequent blocks.
  • This requires enormous computational power.

The Longest Chain Rule

  • Nodes only accept the longest valid blockchain.
  • If a node tries to create a fraudulent block, its chain will differ from the others.
  • Even if the fraudulent node successfully remines the altered block, the other nodes will reject it.
  • To successfully attack the blockchain, a node must remine the altered block and all subsequent blocks faster than the rest of the network combined.
  • This is considered practically impossible due to the computational power required and the associated costs.
  • The cost of electricity to perform such an attack would likely outweigh any potential reward.
  • These mechanisms contribute to the immutability of the blockchain.

Bitcoin and Blockchain Relationship

  • Bitcoin was the first blockchain application.
  • Blockchain is the underlying technology, and Bitcoin is just one use case.
  • Analogy: Blockchain is like the Internet, and Bitcoin is like email.
  • The Bitcoin white paper, published in 2008 by Satoshi Nakamoto, introduced the concept.
  • The white paper doesn't use the term "blockchain;" it was termed later
  • Satoshi Nakamoto is an anonymous person or group who disappeared around 2011.
  • Wallets associated with Satoshi Nakamoto hold a significant amount of Bitcoin (approximately R1,900,000,000,000) that hasn't been spent since 2012.

Bitcoin's Origins

  • The first Bitcoin block was mined in early 2009.
  • Blocks can be inspected using a block explorer.
  • Each block contains the hash, nonce, and transaction details.
  • The hash starts with a predetermined number of zeros (currently around 18).
  • The nonce is the value that, when combined with other block data, produces the required hash.
  • A timestamp (the second of time) is also included in the hashing algorithm, increasing the difficulty of finding a valid nonce.
  • Mining farms and pools:
    • Due to the difficulty, people create mining farms, and mining pools
    • People contribute money to mining pools; when that farm finds a nonce, the reward is distributed between the pool users.

Pizza Transaction

  • In 2010, someone offered 10,000 Bitcoins for two pizzas on a forum.
  • This is considered the first transaction with Bitcoin.
  • At today's value, 10,000 Bitcoins is approximately R19,000,000,000.

Acquiring and Storing Bitcoin

  • Ways to Acquire Bitcoin:
    • Buy it at an exchange:
      • Such as LUNO
    • Peer-to-peer:
      • If a person already has Bitcoin, you can buy it from them
    • Bitcoin ATMs
    • Mining:
      • If you find a golden nonce, you get Bitcoin that way
  • You can store Bitcoin in two ways:
    • Store your Bitcoin in an exchange such as LUNO
    • Buy a hardware wallet:looks like a USB stick and you can transfer your bitcoin over to that hardware wallet
  • Misconception about Wallets:
    • Wallets don't contain bitcoin; it's rather a historical transaction, and the blockchain contains the Bitcoin
    • Wallets have a public key that enables you to control Bitcoin on the blockchain
    • The key will let you send the Bitcoin to someone else on the blockchain
  • Exchanges store your keys on a server, but the server could be hacked, but that does not mean the Blockchain got hacked; just the exchange did.
  • Andreas Antonopoulos says that there are two types of exchanges, ones that have been hacked and ones that will be hacked.
  • If you have a large amount of Bitcoin, get yourself a hardware wallet that costs R2,000 and buy it from a supplier to make it much safer.

Bitcoin vs. Fiat Currency: Pros and Cons

  • Decentralization: Bitcoin operates on decentralized networks, so there is no bank.
  • Limited Supply
  • Transaction fees
    • The transaction fee making a Bitcoin transaction is fixed
    • It's not related to how much money you're making, so it is R35 per transaction.
    • If you send someone a million rand, R35 Is nothing
    • It is not worth it if you are buying a cup of coffee
  • Payments are irreversible.