After confirming the authenticity of the transaction, the transaction is not yet completed. The transaction data must be written into the database to be considered valid and the counterparty can actually receive the money.
Bitcoin uses a special database called blockchain. For a detailed introduction, please see "Blockchain Introduction Tutorial". This article only discusses how transactions are written to the blockchain.
First, all transaction data will be transmitted to the miners. Miners are responsible for writing these transactions into the blockchain.
According to the Bitcoin protocol, the maximum size of a block is 1MB, and a transaction is about 500 bytes, so a block can contain more than 2000 transactions at most. The miner is responsible for packing these 2000 transactions together to form a block, and then calculating the hash of this block.
The process of calculating the hash is called mining, which requires a lot of calculations. There are also competitions among miners. Whoever calculates the hash first will be the first to add a new block to the blockchain, thus enjoying all the benefits of this block, while other miners will get nothing.
Once a transaction is written into the blockchain, it cannot be reversed. An idea needs to be established here: Bitcoin is not stored in wallets or other places, but only exists on the blockchain. The blockchain records every transaction you participate in, how many bitcoins you have received, and how many bitcoins you paid, so you can calculate how many assets you own.