Bitcoin Forum
May 14, 2024, 03:25:09 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: I need an explanation about how mining works  (Read 242 times)
disloyalraisin (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 08, 2018, 09:36:11 AM
 #1

Hey there!
I''ve recently become interested about cryptocurrencies (and this forum, as well) so I'd like to learn more about it and I'll probably think about investing in them in future. But before I do, I'd like to learn about the technical side of it.

Could you please explain to me, as easily as possible, how does mining work? How does it happen that we "mine" bitcoins and that we get them?

I try to understand but I can't find anything but technical descriptions, and since I'm not so familiar with this, I need a simple explanation Smiley

Thanks a lot Smiley
1715700309
Hero Member
*
Offline Offline

Posts: 1715700309

View Profile Personal Message (Offline)

Ignore
1715700309
Reply with quote  #2

1715700309
Report to moderator
1715700309
Hero Member
*
Offline Offline

Posts: 1715700309

View Profile Personal Message (Offline)

Ignore
1715700309
Reply with quote  #2

1715700309
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715700309
Hero Member
*
Offline Offline

Posts: 1715700309

View Profile Personal Message (Offline)

Ignore
1715700309
Reply with quote  #2

1715700309
Report to moderator
NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6396


Looking for campaign manager? Contact icopress!


View Profile
March 08, 2018, 11:41:11 AM
 #2

Hey there!
I''ve recently become interested about cryptocurrencies (and this forum, as well) so I'd like to learn more about it and I'll probably think about investing in them in future. But before I do, I'd like to learn about the technical side of it.

Could you please explain to me, as easily as possible, how does mining work? How does it happen that we "mine" bitcoins and that we get them?

I try to understand but I can't find anything but technical descriptions, and since I'm not so familiar with this, I need a simple explanation Smiley

Thanks a lot Smiley

The information was written a good number of times, so I will not do the same again. If you want non technical info you should add ELI5 in the list of keywords you are searching for.
I searched for Bitcoin mining eli5
Of course, some results are still technical, but I will give two links from the same reddit thread which seem to cover the story pretty good, so you can start with them: main explanation and fix and completion

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 08, 2018, 02:53:16 PM
 #3

Of course, some results are still technical, but I will give two links from the same reddit thread which seem to cover the story pretty good,

Personally, I wouldn't recommend either of those links. BOTH of them are rather misleading and get some details entirely incorrect.  There are definitely better sources of information.

To get a grasp on the general concepts, I suggest watching this:

https://www.youtube.com/watch?v=bBC-nXj3Ng4

Some of the specific details are generalized or simplified in that video, so it won't give you an exact understanding of every technical detail, but it is a good introduction to the more basic concepts.

Then once you've watched it, let me know if you still have some questions.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 08, 2018, 03:10:55 PM
 #4

Could you please explain to me, as easily as possible, how does mining work? How does it happen that we "mine" bitcoins and that we get them?

I'll give it a try:

You can think of hashing as a 'mathematical equation' where you produce a (random) output depending on the input.
Now, when you mine, you are basically calculating hashes (with the TX's as input) until you have found a hash with X leading 0's.
How much 0's are needed is defined by the difficulty of the network. This difficulty adjusts every 2 weeks to get a 6 blocks per hour 'speed'.
Each time you mine a block the first transaction in this block is the coinbase transaction (has nothing to do with coinbase.com).
This coinbase transaction contains the freshly mined BTC's to the miners address.

Basically its a probability game. The miner with the highest hashrate (most calculations per second) has the highest chance of mining a block (calculating a valid hash) proportionally.


Thats just a very basic description of the mining process. Feel free to ask more detailed questions.

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 08, 2018, 03:37:15 PM
Merited by HCP (1)
 #5

You can think of hashing as a 'mathematical equation' where you produce a (random) output depending on the input.

"Random" makes it sound like it is different every time.  If you use the exact same input, you will get the exact same output, every time you calculate it.  It might be better to describe it as "unpredictable".  There is no known way to predict what the output will be without actually performing the calculation. Even the smallest possible change (one bit) to the input will completely change the output in unpredictable ways.

Now, when you mine, you are basically calculating hashes (with the TX's as input)

More specifically, the BLOCK HEADER as the input.  The 80 byte block header consists of 6 pieces of information:

  • The 4 byte version number
  • The 32 byte SHA256 hash of the previous block in the chain
  • The 32 byte Merkle Root (calculated by hashing the transactions that are included in the block)
  • The 4 byte timestamp (represented as number of seconds since Midnight the morning of January 1, 1970)
  • The 4 byte representation of current mining difficulty
  • The 4 byte nonce (a value that has no meaning and exists solely so that you can change the input to the mining function)

The miner manipulates the value of the nonce prior to each hashing attempt so that they can get a new hash result.

until you have found a hash with X leading 0's. How much 0's are needed is defined by the difficulty of the network.

Actually, you are looking for a hash that has a lower value than the current difficulty target.  Smaller targets do result in more leading zeros (0000123 has 4 leading zeros and is less than 0001234), but it is possible that two values could have the same number of leading zeros and only one of them is a valid proof-of-work (imagine that the target is 0004567, in that case 0005678 and 0003210 BOTH have 3 leading zeros, but only one of them is lower than the target)

This difficulty adjusts every 2 weeks to get a 6 blocks per hour 'speed'.

Actually, the difficulty adjusts every 2016 blocks.  If the blocks are being solved at an average rate of 10 minutes per block, then that works out to 20160 minutes (which is 14 days).  If blocks are being solved faster than an average of ten minutes each, then the adjustment will happen sooner. If blocks are being solved slower than an average of ten minutes each, then the adjustment will happen later. The adjustment is proportional to the difference between 20160 minutes and the actual amount of time that it takes to solve the 2016 blocks.  That way the new difficulty should result in an average amount of time to solve a block which is closer to 10 minutes.

Each time you mine a block the first transaction in this block is the coinbase transaction (has nothing to do with coinbase.com).
This coinbase transaction contains the freshly mined BTC's to the miners address.

Correct.  It is also sometimes called the "generation transaction" or the "block reward".  In addition to the block subsidy, aka "freshly minted BTC's" (currently 12.5 bitcoins), this transaction ALSO includes the sum of all the transaction fees of all the transactions in the block.

The description "coinbase transaction" existed prior to the Coinbase business.  Since the business was built as a way to buy and sell bitcoins, they used an existing bitcoin word as the name of their business.

This is also true of blockchain.info.  Bitcoin, and the bitcoin blockchain, existed before the blockchain.info website.  Since the website was created as a way to see information about the bitcoin blockchain, they used the existing bitcoin word as the name of their website.

Basically its a probability game. The miner with the highest hashrate (most calculations per second) has the highest chance of mining a block (calculating a valid hash) proportionally.

Correct.
NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6396


Looking for campaign manager? Contact icopress!


View Profile
March 08, 2018, 06:18:00 PM
 #6

Of course, some results are still technical, but I will give two links from the same reddit thread which seem to cover the story pretty good,

Personally, I wouldn't recommend either of those links. BOTH of them are rather misleading and get some details entirely incorrect.  There are definitely better sources of information.

To get a grasp on the general concepts, I suggest watching this:

https://www.youtube.com/watch?v=bBC-nXj3Ng4

Some of the specific details are generalized or simplified in that video, so it won't give you an exact understanding of every technical detail, but it is a good introduction to the more basic concepts.

Then once you've watched it, let me know if you still have some questions.

I still believe that what I provided is just fine for OP. Although the explanations I linked are not 100% accurate, they give a good sense of what happens there to somebody who don't want to spend more than 5 minutes to understand the big picture.
I don't know the deep details as good as maybe I should (and you know that maybe even better than myself) and imho most users don't need them for normal use of Bitcoin.

Your details are great, accurate, but too many and too deep for OP, no offense.

PS. At the first occasion I get enough time I will clearly watch that video, not just "scan" it.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 08, 2018, 07:08:41 PM
 #7

imho most users don't need them for normal use of Bitcoin.

Your details are great, accurate, but too many and too deep for OP, no offense.

This is the Technical Support sub-forum, isn't it?

If you ask questions in the Technical Support sub-forum, you should expect (and should receive) technically correct answers.

If you don't want details or you want a good sense of what happens which is not 100% correct, then you should ask in the Beginners and Help or the Bitcoin Discussion sub-forums.

NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6396


Looking for campaign manager? Contact icopress!


View Profile
March 08, 2018, 07:55:50 PM
 #8

imho most users don't need them for normal use of Bitcoin.

Your details are great, accurate, but too many and too deep for OP, no offense.

This is the Technical Support sub-forum, isn't it?

If you ask questions in the Technical Support sub-forum, you should expect (and should receive) technically correct answers.

If you don't want details or you want a good sense of what happens which is not 100% correct, then you should ask in the Beginners and Help or the Bitcoin Discussion sub-forums.



Yep, this is correct and I cannot argue. From the way the question looked I had the feeling it's indeed another section.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
March 12, 2018, 11:39:07 AM
Last edit: March 12, 2018, 11:53:02 AM by Xynerise
 #9

Okay, thanks, you explained the issue greatly! The answers weren't too technical for me. Now I have another question.

A block is like a "page" of history transactions, right?
If you want to put it that way, yes.

Quote
And from what I understand, a new one is created when the previous one is "full" and when it's created, the miner gets awarded with bitcoins.
Sort of.
The "page" doesn't have to be full.
The miner can decide to put only the Coinbase transaction (the one paying himself the block reward) and leave the rest of the rest of the "page" blank (i.e include no other transactions in the block)
Quote
When is it that the block completes and a new one is created? Is it a specific amount of transactions or does it differ each time?
No.
There's no specific number of transactions.
Actually there is, but it's relative, not absolute.
There's a block weight limit (previously a block size)
Transactions can be different sizes, but the total size of a block is limited, so the number of transactions that can fit in a block depends on the size of the transactions.
(That's the basis of how Segwit is a block size increase: it reduces the sizes of transactions so more transactions can fit in a block)
So a block can have either 1 transaction, or (theoretically) ~12,000 if all transactions were segwit transactions with 1 input and 1 output.

TL;DR: A block can be any size less than or equal to 4MB (kWU)
Any block must include the Coinbase transaction
So a block can have only the Coinbase transaction and be valid
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 12, 2018, 11:46:01 AM
 #10

A block is like a "page" of history transactions, right?

I guess you could call it 'page' under given circumstances, yes.



And from what I understand, a new one is created when the previous one is "full" and when it's created, the miner gets awarded with bitcoins.

Thats not how it works.
Blocks are 'created' when a miner finds a valid hash (linking to the previous block).
A miner can inlcude as much unconfirmed transactions as he wishes into a block (block size (non-witness part) has to be < 1 MB).
In addition to the unconfirmed transactions from the mempool a miner (usually) includes the coinbase transaction (block reward, currently 12.5 btc).



When is it that the block completes and a new one is created? Is it a specific amount of transactions or does it differ each time?

A new block is 'completed' each time a miner has calculated a block.
When a new block is published all miner start working on a new block (with a link to the previous block).
Basically its a probabilitygame. The difficulty of the network adjusts to have a block generation time of about 10 minutes (on average).

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 12, 2018, 05:52:21 PM
 #11

Okay, thanks, you explained the issue greatly! The answers weren't too technical for me.

Glad we could help.

Now I have another question.

Great.  Does it have anything to do with the video that I posted a link to?

A block is like a "page" of history transactions, right?

In what way do you mean that it is a "page"?  This isn't a book.  It isn't typically printed on paper.

A block is a selection of one or more bitcoin transactions and an 80 byte header that contains about the block.

And from what I understand, a new one is created when the previous one is "full"

Did you even watch the video?

New blocks are created continuously and constantly.  On average, the necessary proof-of-work is completed on one new block every 10 minutes.

The miner earns the transaction fees from the transactions that are included in their block if their block is added to the blockchain.  Therefore, if there are enough unconfirmed transactions, a miner will typically fill their block with transactions (more transactions = more total fees).  However, a miner is allowed to create a block that is smaller than the maximum allowed size, and they may do so for various reasons (such as if there are not enough transactions waiting to be confirmed).

and when it's created, the miner gets awarded with bitcoins.

Ok, it is clear that you did not watch the video.

Go watch it, then let me know if you still have some questions.

The miner includes a special transaction in his block that is not funded with any existing bitcoins and which pays himself the allowable reward (block subsidy plus fees)

When is it that the block completes and a new one is created?

These questions were answered in that video that I linked to.  Why didn't you watch the video before wasting time asking these questions.

The block "completes" when the miner finds a nonce value that results in a block hash which is below the target value.  At that point the miner can brodcast his block to all connected peers.

A new one is created whenever a completed block is received, or whenever the miners decides to abandon the block they are working on and start over with new data.

Is it a specific amount of transactions or does it differ each time?

Please go watch the video.  Then come back and ask any questions that you still have.

The amount of time that it takes to complete the proof-of-work on a block is not meaningfully effected by the number of transactions.

Thanks for replying and sorry if I'm asking obvious questions Smiley

The problem isn't that they are "obvious".  The problem is that they've already been answered (if you watched the video at the link that was provided).
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 13, 2018, 01:45:31 PM
 #12

Okay, sorry, you're right. I should've watched the video before asking all these questions, but I was on a bus when I wrote the message and thought you wouldn't mind clearing that up for me before I had access to my computer. Well, turns out I was wrong.

You were wrong?

I thought I answered the questions.  Which question didn't I clear up for you?

Sorry I've taken your time, although a simple "watch the video, then ask questions" would do the job just as fine as the long message. I appreciate the time you've taken to write it, though.

Yep. I said that.  Twice. There were 4 days between when you were told to watch the video and when you asked more questions.  That's a really long bus ride.  Why bother asking questions if you aren't going to pay attention to the answers?

Once again, thanks for all the help and thank you for replying!

You're welcome.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!