When a transaction takes place, miners compete to validate it by solving complex cryptographic puzzles. Those who solve the puzzle first validate the transaction, which is written to a block and added to the blockchain.