What is mining?

@danielabrozzoni - Shoes in Bitcoin

(For beginners)

Bitcoin basics

Transaction

A document stating that you're moving Bitcoin from one address to another

Block

A "file" which contains various transactions, plus some other metadata

Mempool

Set of all the transactions not yet included in a block

Blockchain

Each block contains a reference to the previous one, creating a chain. A new block is added to the chain every 10 minutes on average

Miner

An entity who adds blocks to the blockchain

What happens when you use Bitcoin?

You just met a cute girl and want to send all your BTC to her...

...You open your wallet and she gives you her address...

...Your wallet prepares a transaction...

...You send the transaction to the network, and it ends up in mempool...

...A miner sees your transaction and decides to put it in a block...

...The miner successfully mines the block...

...After six blocks, your transaction can't be reverted!

Mining

  • Miners use energy to add new blocks to the blockchain
  • Miners have a economic incentive to work
  • The first transaction of the block is called coinbase
    • Pays to the miner some Bitcoin for the work done
      • Newly issued Bitcoin
      • Transaction fees

Incentives

Incentives - newly issued

  • At the moment each block issues 6.25 new Bitcoin
    • Those are called "virgin", because they have no previous history
  • The number of Bitcoin issued each block decreases over time
  • In 2140 no more Bitcoin will be issued
    • There will never be more than 21 milion Bitcoin!

Incentives - newly issued

  • Miners also earn the fees of all the transactions in the block
    • Each transaction must include a small fee to pay the miner
    • The miners choose the transaction with higher fees first
    • If you're in a rush, just pay more!

Incentives - transaction fees

  • The fee doesn't depend on how many Bitcoin you're moving!
  • It depends on the traffic in the Bitcoin network
    • The more congested the network is, the higher the fees
  • It depends on how quickly you want the transaction to be confirmed
    • You can pay a super low fee if you're fine with waiting days
  • It depends on your address type
    • It's cheaper to spend from addresses starting with "bc1..."

Incentives - transaction fees

  • The miner chooses some transactions to include from the mempool
  • The miner adds the coinbase transaction, which pays the reward
  • The miner has to solve a puzzle to make the block valid
  • When the puzzle is solved, the miner can publish the block

How to build a block

  • Mathematical puzzle needed to create a new block
  • The only way of solving it is trying random answers until you find one that works
  • Let's try to understand the mining puzzle with an analogy...

The mining puzzle

The mining puzzle: an analogy

The game is rolling dices, to win score less than the target

The mining puzzle

  • Imagine playing rolling dices against thousands of opponents
  • Only the first player who beats the target wins
  • The more times you roll the dices, the higher the chance of winning
    • You would roll the dices as quickly as possible
    • You would avoid wasting time between the rolls

The mining puzzle

  • Mining is really similar to our rolling dices game:
  • Mining devices spend all day trying random numbers until they find the solution to the puzzle
  • The first one who finds the solution gets the reward, and the game starts again
  • Miners have to be as efficient as possible to maximize their reward

Adjusting the difficulty

  • The more players join the rolling dices game, the quicker the solution will be found
  • We don't want that! We want one block to be found every 10 minutes
  • Game difficulty is adjusted every 2016 blocks
    • If the previous 2016 blocks where mined too slowly, the game becomes easier
    • If the previous 2016 blocks where mined too quickly, the game becomes more difficult

Mining device

  • A mining device is a computer built only for Bitcoin mining
    • You can't surf the internet on a mining device, you can only try solving the puzzle

Mining device

  • You can't mine Bitcoin on your own computer/ smartphone
    • They're not powerful enough
    • You would ruin your hardware
    • You wouldn't earn anything
  • Any app who claims to make you mine BTC on your device is a scam. Be aware!

Mining pool

  • Let's say you have some mining devices and you're able to find one block once a year
  • That's ~7 BTC in revenue per year
  • You would have to spend one whole year paying bills before being able to earn something
  • That's unfortunate!

Mining pool

  • Joining a mining pool means starting to mine with other people, and then sharing the reward
  • Each miner gets a reward proportional to how many calculations their devices did
  • Miners get paid a bit less (due to pool fees), but they're paid multiple times a day

Questions?