## What exactly is Mining?

190

109

I have heard that mining is for people with ready hardware and blah blah blah... But what exactly is it? Does it operate like real mining? I mean, people talk about it like you are physically mining.

3

Transaction validation process is called mining. For each block of transactions validated, the successful miner receives bitcoin reward. http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/

– RP. – 2014-03-04T04:13:57.017

223

David Schwartz's answer is entirely accurate, but all that "bitspeak" might be a little intimidating to the average user. Let me try and put it into more plain language:

The way Bitcoin works is that instead of having one central authority who secures and controls the money supply (like most governments do for their national currencies), this work is spread out all across the network. Most of the heavy lifting for Bitcoin is done by "miners".

Miners collect the transactions on the network (like "Alice pays Karim 10 bitcoins" and "Liam pays Sofia 8.3 bitcoins") into large bundles called blocks. These blocks are strung together into one continuous, authoritative record called the block chain, which doesn't permit any conflicting transactions. This is necessary because without it people would be able to sign the same bitcoins over to two different recipients, like writing cheques for more money than you have in your account. The block chain lets you know for sure exactly which transactions count and can be trusted (so no bad cheques!).

The way Bitcoin makes sure there is only one block chain is by making blocks really hard to produce. So instead of just being able to make blocks at will, miners have to compute a cryptographic hash of the block that meets certain criteria. Bitcoiners refer to this process as "hashing". The only way to find a cryptographic hash that's "good enough to count" is to try computing a whole bunch of them until you get lucky and find one that works. This is the "lottery" that David Schwartz refers to, because miners who successfully create a block are rewarded some bitcoins according to a preset schedule. The difficulty of the criteria for the hash is continually adjusted based on how frequently blocks are appearing, so more competition equals more work needed to find a block. Modern dedicated mining hardware (e.g. ASIC miners) can try trillions of hashes per second, so to be competitive in this race to find hashes miners need specialised hardware, otherwise they will tend to spend more on electricity than they make in the "lottery".

In addition to the hash criteria, a block needs to contain only valid, non-conflicting transactions. So the other main task for miners is to carefully validate all the transactions that go into their blocks, otherwise they won't get any reward for their work!

Because of all this work, when a Bitcoin client signs on to the network it can trust the block chain that was most difficult to produce (since this is evidently the one that was being worked on by the most miners). If there was a "fake" blockchain competing with the real ones (say, where someone pretends that they didn't actually give Sofia those 8.4 bitcoins and they still have them), the fraudster would have to do as much work as the whole rest of the network to make their block chain look as trustworthy. So essentially, the intense work that goes into finding blocks through hashing secures the network against fraud. There is also, of course, some nifty code that figures out how to choose between conflicting transactions; and what to do if two people find valid blocks at the same time.

One last thing: why is it called mining? In the original analogy, people who performed this essential work were compared to gold miners digging the gold out of the ground so that everyone could use it. But in reality, Bitcoin "miners" are just running computer programs on very specialised hardware that automates the process of securing the network. To sum up, this software

• Collects transactions from the network
• Validates them, and doesn't allow conflicting ones
• Puts them into large bundles called blocks
• Computes cryptographic hashes over and over until if finds one "good enough to count"
• Then submits the block to the network, adding it to the block chain and earning a reward in return.

That's mining in a nutshell!

2Great answer. Perhaps just one thing to add - a Transaction being included in a Block constitutes its first Confirmation, and each successive block adds one more Confirmation. – ypocat – 2014-02-02T16:53:02.123

1You say can trust the block chain that was most difficult to produce (since this is evidently the one that was being worked on by the most miners) -- I don't understand the concept of collaboration which this statement implies. Miners can work together to create a single block? How does that work? – None – 2017-09-28T19:58:17.943

1Blockchain, not block. Miners produce blocks separately but produce blockchains together. – eMansipater – 2017-10-03T22:32:10.483

103

mining is doing the work of finding nonce so that sha256(sha256(data+nonce)) < difficulty

where

• nonce is an integer number the miner chooses freely (this choosing of the nonce and checking if the condition (< difficulty) is met comprises the work
• data is a hash over the contents of the block (transactions) and the previous block's hash
• sha256() is the SHA-256 cryptographic hashing function (wikpedia SHA-2 article)
• difficulty is a value that is adjusted consensually by the nodes of the bitcoin network to adjust for change in network computation power in order to have one block every 10 minutes found by the network

The resulting nonce is the proof of work: since it's impossible to find nonce without essentially trying different nonces and calculating the two hash functions, having found a nonce that satisfies the condition is proof this work of searching and calculating has in fact been done.

This is the central idea behind Bitcoin to solve the double spending problem: due to the inclusion of the previous block's hash in data (this links the blocks to form a chain) and the fact that the honest nodes of the network always do their work on the longest chain of blocks, a double spending attack involves calculating (and later publishing) a forked block chain in secret that is longer than the "honest chain" (containing the transaction that should be undone). Due to the work required to do this, this race can only be won if the attacker has greater computation power than the rest of the network together. Since using such computation power to honestly mine is likely more profitable than pulling a double-spend, the incentive for doing a double-spend attack is low.

5I think this answer is too terse for the audience. This might be fine on Cryptography.SE, but the typical Bitcoin user might not know what nonce or sha256 means. I suspect the typical Bitcoin user might have heard of something called a "hash" but has no idea that your answer is referring to the application of hash functions. – Michael McGowan – 2011-09-12T21:16:55.767

29Personally, I think that technical answers might cohabit with non-technical ones. In this case some explanations on what is data and difficulty are needed, otherwise nobody will learn anything. Not even a cryptographer. – Stéphane Gimenez – 2011-09-12T21:23:05.880

3I like Stéhane Gimenez' idea of explaining stuff (data, nonce, sha256, etc.) after the short and precise definition of mining. I'm new to stackexchange... can I (should I) edit my answer? – molecular – 2011-09-13T07:44:52.790

ok, I added explanations. Please, if anyone spots inaccuracies or worse, don't hesitate to add a comment, I will correct my answer. – molecular – 2011-09-13T08:07:04.253

The number isn't chosen by someone else--it's the solution to a math problem. On your first question, each valid block has to include the hash of the previous block--so that integer changes every time and sharing it after you already won the block wouldn't help. It also changes depending on which address you are using to claim your reward, so sharing that number before claiming the block would only allow someone else to send the reward to your address (not a very good deal for them). You should post some of these things as your own question--that way you can get a more complete answer. – eMansipater – 2013-04-12T19:25:43.790

So, here, when the value difficulty gets low, it becomes harder to find a block / nonce. So, why does the difficulty value regularly rise? See "difficulty" and "next difficulty" on this website...

– Totor – 2014-01-22T17:49:23.857

3Shouldn't "difficulty" be "target" in this case? I'm not a BTC expert, just wondering... – donutdan4114 – 2014-02-21T14:38:15.213

1Yes, it should be target, not difficulty. If you need to find a value below the difficulty, then that would get easier as the difficulty goes up - that wouldn't work very well. – Dr.Haribo – 2017-12-25T13:20:26.710

4This actually is more what I was looking for. Once you get the basics, it becomes more difficult to delve deeper. Thanks. – Kinnard Hockenhull – 2012-12-13T17:22:42.607

After reading David's and eMansipater's answers, i'm still no closer to understanding what "mining" is. At least now i understand how you "win" - you have to guess a (32-bit?) integer that someone else used. Who that someone else was, why they had to choose one, how they couldn't just share the integer, what i get out of guessing the integer, how i get it out of guessing the integer, is stuff for more research. – Ian Boyd – 2012-12-15T20:22:43.117

55

Mining is the process of securing transactions and committing them into the bitcoin public chain. It requires winning a kind of computational lottery where each hash you perform is like buying one ticket. The Bitcoin protocol currently permits the miner who generates a block to claim 50 bitcoins as well as any transaction fees for the transactions that miner chooses to include.

The Bitcoin system uses the mining process to generate coins, secure transactions, and publish transactions.

1The block reward is now 6.25 bitcoins. – darosior – 2020-06-27T10:16:26.000

15The block reward is now 25 bitcoins. – David Schwartz – 2013-06-29T06:36:05.570

16The block reward is now 12.5 bitcoins. – Dheeraj Vepakomma – 2016-10-23T14:41:46.467

13

Mining is just doing computational work to secure the transaction block chain. A side effect of mining is creation of new coins and earning additional money by signing on transactions.

3

In more simple terms: Actual mining means, you sweat digging something and then find some useful metals. In bitcoin mining, your computer sweats calculating blocks and in return the bitcoin protocol gives you some bitcoins.

And in actual mining, you find precious metals which doesn't belong to anyone. Similarly, in bitcoin mining, the bitcoin protocol generates new bitcoins (Only upto 21 millions though) (which are not belonged to anybody) and gives you.

So the word "mining" makes perfect sense.

0

Bitcoin mining is the process of adding transaction records to Bitcoin's public ledger of past transactions or blockchain. This ledger of past transactions is called the block chain as it is a chain of blocks.

Bitcoin mining is intentionally designed to be resource-intensive and difficult so that the number of blocks found each day by miners remains steady. Individual blocks must contain a proof of work to be considered valid. This proof of work is verified by other Bitcoin nodes each time they receive a block. Bitcoin uses the hashcash proof-of-work function.

The primary purpose of mining is to allow Bitcoin nodes to reach a secure, tamper-resistant consensus. Mining is also the mechanism used to introduce Bitcoins into the system: Miners are paid any transaction fees as well as a "subsidy" of newly created coins.

Miners do expensive computation to solve puzzle and they broadcast it over the network. It contains a number called nonce which can be used to easily verify that actual work was done. This is called proof of work. The solution takes lot of trials and is computationally difficult but it can be easily verified by other nodes on network. Any evesdropper, if tries to alter any block or transactions, will need to do alter all following blocks in blockchain that will get exponentially difficult. Thus it makes alterations in block impossible and a secure and tamper resistant ledger is created on blockchain.

Mining is also the mechanism used to introduce Bitcoins into the system. Miners are paid any transaction fees as well as a "subsidy" of newly created coins. This both serves the purpose of disseminating new coins in a decentralized manner as well as motivating people to provide security for the system.

-1

Mining is just running a application on your computer to confirm the transactions of the crypto currency for which you get paid as fees.

I will say mining is the soul of crypto currency, according to today's scenario everyone creating new coin everyday but some of them goes to the moon and some of them just vanish in a couple of weeks, why? because a coin is alive until there are people to mine it. Take a example of a coin which has only 100 miners and you bought 1000 such coins after a few days miners stopped mining that coin, now you cannot sell that coin to anyone even if you have a potential buyer, why? because your transaction will not confirm until there are people mining that coin. The price of coins go up because of mining, why? because as many miners start mining the currency the difficulty increases, with the increase of difficulty mining coins will take more time, more miners more demand less coins. Increment in rates.

-1

The answers in this section all present different, useful perspectives. Another useful, but non-technical perspective is:

Mining is a battle between those who want to see Bitcoin succeed for the greater good, and those who don't care if it is destroyed as long as they achieve some victory, even if only to be part of the destruction (they might not get any BTCs from their destructive efforts).

In other words, Bitcoin is a fascinating attempt to establish an alternate money system. Since the P2P, decentralised architecture is integral to its success it is, by design, open to any participant. The mining process assumes that some participants are evil. It pitches 'good' against 'evil' in the hope that 'good' will continue to succeed and maintain the integrity of the network.

1Why the downvotes? – Matthias – 2014-07-06T16:20:04.947

I up voted it. Since this gives a fresh perspective. Not suitable for a beginner though. – Sorter – 2017-11-20T19:11:16.120