DEV Community

Cover image for How bitcoin works?
random
random

Posted on

How bitcoin works?

What is Bitcoin?

images

  • Electronic payment system
  • A conduit by which 2 parties can transact over internet ( say Alice and Bob)
  • A bitcoin transaction b/w Alice and Bob basically amounts to a specially constructed sequence of numbers that Alice will send over to Bob. And this will be done entirely over the internet. These numbers will have certain mathematical properties that make it hard for someone to defraud the system.
  • Alice can do this in 2 ways:
    1. Install a special software = bitcoin client
    2. Work with a 3rd party service that will handle these mechanics for her.
  • But in either case, the client or the service will generate these numbers for Alice. And Bob will also be using a software or using a 3rd party service that will take these numbers and allow him to do something else with those numbers. (for example, Bob can buy something else on his own or he can trade these numbers for real money and so on)

Why even accept Bitcoin?

images

  • After all, bitcoin is just a bunch of numbers. What intrinsic value could it possibly have?
  • Bitcoins actually have value and there are more and more people accepting bitcoin these days for transactions.
  • The value of the bitcoin is going to be derived from the faith you have in the value of what you can procure with that bitcoin.

Why even bother with Bitcoin?

  1. Privacy - transactions can be done without divulging real world identity.
  2. Open - anyone can make a bitcoin transaction. Only thing to do to get started is download the special bitcoin client(or 3rd party service).
  3. Decentralised - when u do a transaction, there is no bank that gets in between the transaction.

How Bitcoin works?

howdoesbitcoinwork

  • Bitcoins transactions are not like traditional coin transactions.They are more like a global ledger.
  • In a transaction from Alice to Bob, Alice has to specify how many bitcoins she wants to allocate to Bob. She can also specify how much change she's going to get. And there can also be a transaction fee. images
  • A transaction fee is basically an incentive for other nodes in the network to help Alice in essentially validating some of the details of this transaction for Bob.
  • Now Alice will take these transaction details and apply what's known as a digital signature to these transaction details. Screenshot 2021-06-19 at 12.46.38 PM
  • A Digital Signature is the mathematical analog of a traditional signature. It really binds Alice's identity(her identity within the bitcoin system) to the details of this transaction. And this binding is done in a cryptographically strong way.
  • The details of this transaction once it takes place are going to be broadcast out to all the nodes in the peer-to-peer network that represents bitcoin nodes.
  • Now Bob when he receives it over the peer-to-peer network, he'll probably sandy check some part of the transaction. For example, he might check whether the numbers workout correctly. And he's going to have some mathematical assurance because of some of the cryptography involved that some of these claims are accurate - Alice has the bitcoins which she claimed to possess and she's expressed an interest to assign those bitcoins to him. But he won't know whether Alice has tried to transfer those same bitcoins to anyone else over the course of time or maybe just prior to that point. Bitpanda-Infographics_4-double-spending.png
  • This problem of Alice trying to spend bitcoins twice is known as "double spending".
  • This problem is handled via a specific set of nodes known as the bitcoin miners.
  • They take all the transactions they see and compiles them into a transaction block. So it's basically a recording of the previously unrecorded transactions.
  • So if you think of a single transaction as a ledger item, you could think of a transaction block as representing an entire page in the ledger book.
  • The bitcoin miners will also include in this block, a special transaction that is just meant for themselves to basically reward themselves for the effort of doing this mining.
  • A transaction block will also contain an encoding of the previous transaction block, so there's going to be some level of continuity. 1*0kAUMg4UCZYXHDuMHoBoog
  • Bitcoin miners will also include a specially crafted sequence of numbers associated with these transactions and these sequence of numbers is known as a "Proof of work".
  • It's called "Proof of work" because it's something that is really hard to generate, something that requires a lot of effort to do and that kind of makes it hard for just anybody to get involved with bitcoin mining. It requires that they really exhibit or exert some computational effort basically in exchange for getting this extra reward of a payment and also in exchange for getting this transaction fee that they're going to be promised by Alice to engage in this sort of work.
  • Because each transaction block contains information about previous transactions, what you end up having is not just a single block, you end up having a chain of transactions known as "transaction block chain" Proof of work no purple line
  • As soon as bitcoin miner is able to construct a transaction block chain containing all these unrecorded transactions, and this proof of work, it'll broadcast the details of that chain out to all of the nodes, all of the peers in that peer-to-peer network for bitcoin.
  • Once the newly broadcast chain gets verified and meets the right properties the nodes on the network are just going to start using it and they're going to append new transactions blocks to that chain.
  • They are going to take anything that hasn't yet been processed and start incorporating it into the transaction chain that was broadcast out by the node who came up with the proof of work correctly.

Reference:

Khan Academy

Top comments (1)

Collapse
 
mccurcio profile image
Matt Curcio

But have you read this: