1) Okay so the first question I have is about blocks. If you go here:
https://blockchair.com/bitcoin you will see a transaction live count. It gets increased and decreased as well.
Why it does? Are miners involved in this?Transaction number hasn't yet changed for me but I assume when a block is found, they may find the average and add it on or it may decrease when a block becomes orphaned.
2) Why block generation time is always standard? Every day 144 blocks are created (since 210240 every 4 years, I did the maths). Why? I've never seen such question anywhere. I think on our wiki it says new block every 10 minutes.
The blocktime adjusts every 2 weeks (2016 blocks) to amek the time for a block to be found 10 minutes. This is all based on the computation power dedicated to the chain over the past 2 weeks.
Block discovery is a bit like radioactivity, we know the average will be around 144 a day but there won't always be 144 a day there might be less, block discovery can be anywhere from around a second before to 2 hours after.
3) Mining is the main source of questions. To start with, miners want to mine for 2 reasons. For guessing the hash of a block meaning that they will earn 12.5BTC and for earning bitcoins from transactions fees.
Yes? Is this a question or just a statement? They get both of these - fees are just an additive difference between transactions so a standard block may see 100.1
BTC move and 100
BTC be assigned, the other 0.1
BTC gets added to the block reward.
After a lot of research I have understood that each block's hash has to do with the previous block and some other things (like SHA256(some stuff in here including the prevBlockHash)). What exactly are we trying to guess? And even we if we guess that "thing" correctly, who promises me that it will write to the blockchain that "this guy mined 12.5BTC from x block".
The start of every block begins with a Coinbase, this is a transaction that has null inputs but outputs a 12.5+fee amount to the creditors' public key/address.
They're trying to get a hash of the block to fall below a certain amount, this was originally done by chainging the nonce in the coinbase (which is an up to 20 byte number that is stroable in any transaction before it's signed).
And then how my blockchain file will be shared to all the other blockchain files of the world? So the network will confirm that I really earnt 12.5BTC.
The block gets shared with new nodes and is sent to them as a packet. If you use a mining pool this is handled by them, but essentially, when you run an instance of a miner it will normally have to connect to a full node where it gets information of what it has to put in the block and also publishes the newly found block to other nodes. This needs alright connection to the internet since each block has to point to the last block in it's header and give the height of the block it will be.
These funds take a day to become spendable, for standard nodes on the network that conform to current rules.
Now about the transaction fee. When I send 50BTC to an address with a fee of 0.002BTC, does this mean that I write publicly something to the last block?. Since there is no main database of bitcoin transactions, how will the blockchain updates that I want to send x number of bitcoins to an address? And then miners see the last block's transactions and choose what transaction to solve. I know that if they solve the transaction hash (?) they will get the fee as a reward. But what exactly are they trying to do in order to solve it?
When you broadcast a transaction to neighbour nodes, they will verify it and continue it's propagation through the network.
These transactions are collated and added to a block which then has it's information changed more than 1000 trillion times a second in order to find a number below the target nonce.
4)
What is a target and why the block's header must be equal or lower than this number?In our wiki we have written what's a target:
https://en.bitcoin.it/wiki/TargetThe thing I don't get is here:
Each hash basically gives you a random number between 0 and the maximum value of a 256-bit number (which is huge). If your hash is below the target, then you win. If not, you increment the nonce (completely changing the hash) and try again.
If my hash is below the target?? The hash is a string and the target is a 256-bit number right? How to compare a string with an int?
Examples
(Hash: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
Target: 0000000000000000001320bc0000000000000000000000000000000000000000)
Take this a bit simpler if you want, and use a target in real terms...
If your target is simple like 512 and you have a function that gives 2048 outputs, you're after running it 4 times on average to get below 512.
You can also look at trying to convert hexadecimal into binary since that's how the block hash is stored as it's probably better to watch a youtube video on it.
Essentially it's like normal numbers but with a base of 16:
(Hash: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
Target: 0000000000000000001320bc0000000000000000000000000000000000000000)
would mean the hash is far from the target, however: 0000000000000000001220bc0000000000000000000000000000000000000000 won't be.
5) If I want to send 50BTC to an address with a fee of 0.0002 do I spend 50.0002BTC and the receiver gets 50BTC or do I send 50BTC and the receiver gets 49.9998BTC?
No, bitcoin was developed well.
10^-8 of a bitcoin is stored as a 1 (and is known as a satoshi) this may be subject to change but is currently the numbering system used.
You spend the full
500(00020000), they get 500(00000000) and the 20000 goes as a fee to the finder of the block.