This is where Proof-of-Work (PoW) comes in.
PoW means that a node needs to prove that it worked really hard on that new block.
Only then is it allowed to add that block to the chain.
What is work?
Unfortunately it can't be anything that is intrinsically valuable...
In the context of Bitcoin's PoW, work is essentially: solving puzzles.
(This puzzle-solving is also known as mining.
Nodes get to create new coins
in each block they create,
i.e., for each puzzle they solve.
They are mining these coins
...)
But what kind of puzzles are we talking about?
Depending on how you explored this website, you might have already come across our page
about cryptographic hash functions.
What we didn't tell you there is that they are not only used for securing the integrity of the blockchain -
they are also used for building the puzzles that ensure that nodes are working hard.
And the puzzles look like this: Given all the data that you want to include in a block,
including the hash of the previous block,
find some extra data to add to that block
(the so called nonce)
so that the hash of the resulting block starts with a certain number of zero bits.
(It's actually a tiny bit more complicated than "starts with a number of zero bits",
but this is a good enough approximation.)
The number of zero bits describes the difficulty target - the more they are,
the harder it gets.
It's basically impossible to guess how many leading zero bits a cryptographic hash will have,
so the only way to solve this puzzle is to try out many, many nonces...
Each nonce is like a lottery ticket,
nodes check it by calculating a hash with it,
and if that hash has enough leading zero bits - then the ticket was a winning ticket!
Enough theory. Why don't you try it yourself?
The example below is similar to the one above.
But now you only control one of the nodes and you are only allowed to publish a block if you
have solved the puzzle.
You need to find a value (in the "Type anything" field) that leads to a hash with enough leading zero bits.
We set the difficulty target to a mere 8 zero bits.
That shouldn't be too hard, right?
Oh and by the way that other node... it's also puzzle-solving...