DEV Community

Tisha
Tisha

Posted on

What is Blockchain, bitcoin?!

What's blockchain?

As Wikipedia says it is"an open, decentralized, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way."` (I know you didn't click this link to read Wikipedia article, patience my friend!)
Distributed Ledger: It is a way of recording digital transactions in a way that the transaction is recorded in multiple places at the same time.
Decentralized: This means unlike traditional databases this doesn't have a database and operates in a peer-to-peer network.

Digging Deeper

Once data is put in a block it's impossible to change it. Each block contains some data, the hash of the block, and the hash of the previous block.

1. What data is stored?
The data stored depends on the type of blockchain. E.g. Bitcoin stores information about the sender, receiver, and the amount.

2. What is this hash?
Well, each block is hashed using a hashing algorithm (If you need a brusher, I explained, hashing here). It identifies a block and all of its contents and is always unique, like a fingerprint. The hash is created after the data for the block is generated and if you change the data the hash changes. It also contains the hash of the previous block and this is how we have a block-chain.

So if you try and tamper with the data of a block, its hash changes, and the next block no longer points to the previous block making it all invalid.

Is it really impossible to tamper with the data?
Okaayy fine, even though it is secure. Impossible is a very strong word. Computers are pretty fast these days and can calculate thousands of hash per second. There's a chance you can tamper with the block and recalculate all the following block hashes to make it valid again. So what do we do....?

Proof of Work Mechanism

This is a process that slows down the creation of blocks making it hard for computers to tamper with the block. E.g. In Bitcoin, it requires approximately 10 mins to add a new block to the chain. So if someone wants to tamper with one block they will have to calculate the proof of work for all the following blocks. Thus, both hashing and proof of work make blockchain pretty secure but there's more that adds to the security...!

Peer-to-peer Network

As we saw above blockchain is decentralized so no single entity manages the chain rather a P2P network is used and anyone can join this. When a person (referred as node) joins the network they get the full copy of the blockchain. So when a new block is created everyone gets the new block and each of them would verify it to make sure it's not tampered. Then all the nodes in the network creates a consensus and agree which nodes are valid so if a block is tampered with the other nodes will reject it.

Soo that makes it really hard to tamper because to tamper with a blockchain you need to redo the proof of work for each block, and take control of more than 50% of the peer-to-peer network so that you can get a consensus and agree on the node. Now this is **impossible* to do!*

Now, What's Bitcoin?

So you might have used bitcoin and blockchain interchangeably but they're not the same! Blockchain is a technology and the above explanation is a surface-level overview of the same whereas Bitcoin is one of the first demonstrable use of Blockchain technology! It was invented by an unknown person or group of people under the name Satoshi Nakamoto in 2008.

This is the whitepaper that was created by Satoshi Nakamoto that introduced the world to Bitcoin. It was the first decentralized cryptocurrency but there are a number of cryptocurrencies out there now like Ethereum, Monero, Stellar etc.

How does Bitcoin work?

Sooo, I'm going to try and explain bitcoin and I'll try and make it easy but would encourage you to read the whitepaper if you wanted to dive deeper!
The steps:

  1. Traditional currencies go through centralized payment processors like your bank but Bitcoin transactions are processed by a large distributed network of computers running special software!
  2. So when a transaction occurs the network records the sender and the receiver's bitcoin addresses along with the amount transferred and enters this information on the end of a ledger called Blockchain.
  3. Now each ledger is updated with the new transaction and each transaction is encrypted with public-key cryptography and verified by multiple nodes in the network, (Remember, the consensus we talked about above) making it impossible to counterfeit.
  4. This update process is done by Bitcoin Miners and anyone who wants to do so can do it, they need to guess a random number that would solve an equation generated by the system. But as a miner you don't sit and guess this random number, it's done by the computer, and more powerful the computer, more guesses and better a chance for you to win.
  5. So, the miner who gets it right, gets the chance to write the next bitcoin transaction that gets added to the blockchain. So the block that you have just created gets sent to the whole network for other users to validate it and update their copy of the ledger. This miner is also rewarded for this in bitcoins for this!
  6. This mining is basically a way the proof of work we discussed above works for bitcoins!

Wow, that sounds like free money? Why am I here writing this and you there reading it, instead of mining bitcoins!

Well, Nakamoto crafted the mining rules in a way so that the more mining power a network has the more difficult mining would be i.e. if there are more miners joining then it gets harder to guess the mining math problem, and if miners drop-off it gets easier.
This is done to create a steady flow of new bitcoins and keep a check on inflation. The way it's programmed is on average it takes 10 mins to add a new block!

Conclusion

In a nutshell, that's my attempt to give a high-level explanation of how Blockchain and bitcoin works. Blockchain technology is not limited to cryptocurrency only though, it's used in logistics and food safety as well as healthcare.

That was a bit of a long read, so thank you if you reached till here and I hope you know a bit more about blockchain and bitcoin then what you did before you clicked this link!
Find me on Insta and twitter! :)

Top comments (0)