Build on BNB Chain - Course 1 | BNB Chain Fundamentals
Blockchain Demo - Part 1
Hi! In this video, we’re going to do a blockchain demo. We’ll be using a website we’ve seen before. Before we start, I’d like to thank Andrew Brownwood for making this website public so that everyone can benefit from it.
Understanding SHA-256
We’ve previously discussed the SHA-256 algorithm. Since it’s a cryptographic hash algorithm, it has certain key properties:
- One-way function: You can get a hash from data, but you can't reverse the process to retrieve the original data from the hash. It’s like a digital fingerprint.
- Deterministic: No matter where or when you use it, inputting the same data always produces the same hash. For example, typing "hi" always results in the same hash that starts with 3639. However, changing even a single character (like using a lowercase "h" or adding a space) alters the hash completely.
Introducing the Block and Nonce
Let’s dive into the concept of a block. Here, we introduce the nonce value. A nonce is a number that miners manipulate to find a hash that satisfies certain conditions.
Miners use powerful computers to mine blocks and earn block rewards. To ensure fairness and security, the system sets a difficulty level—defined by the number of leading zeros required in a hash.
For example, if the difficulty is 4 leading zeros, a valid hash might look like "0000..." and the system adjusts this difficulty dynamically based on how many miners are participating.
Difficulty and Probability
To better understand difficulty, consider flipping a coin:
- One tails = 50% chance.
- Two tails in a row (tails-tails) = 25% chance.
Similarly, increasing the number of required leading zeros decreases the chance of randomly finding a valid hash, making it more difficult.
If mining becomes too easy or too hard, the blockchain system adjusts the difficulty accordingly to maintain balance.
The Role of Miners
Miners collect transactions from the transaction pool, then use their hardware to find a valid nonce value. Once a miner finds it, they broadcast the solution to the network. The new block is added to the blockchain, and others adopt this new block.
If two miners are competing to find the same nonce, the one with the better hardware will likely succeed first. The other miner, despite their effort and energy usage, won’t be rewarded.
Real-Time Example
Let’s look at a practical example on the website:
- I enter some data.
- Click “Mine.”
- You’ll notice it takes time—sometimes a lot—because the system is trying to find a valid nonce that results in a hash with the required number of leading zeros.
The longer it takes, the higher the nonce value that’s being tried. This also reflects the computational effort required.
Summary
We’ve explored how SHA-256, nonces, hash functions, and difficulty levels work together to secure blockchain networks. In the next lecture, we’ll continue exploring more aspects of blockchain technology.
Comments
You need to enroll in the course to be able to comment!