April 25, 2024

How cryptocurrency transactions are processed and confirmed

How Cree <span id = are processed and confirmed</span>cross-currency transactions&#8221; /></p>

Ever wondered howDoes mining work on a blockchain, or how are transactions confirmed and added to the blockchain? And me too. But due to the fact that I never came across a clear and accessible step-by-step explanation of this process, I decided to write it myself. So, we present to you the result of a study on how transactions are processed in the blockchain.

Only seven steps:

  • Step 1: The user, intending to send someone else a certain amount of cryptocurrency or token, confirms the transaction in his wallet application.
  • Step 2: The transaction is then transmitted by the applicationwallet to the network of the corresponding blockchain. There, she falls into the “pool of unconfirmed transactions”, where she will be located until some miner picks her up. Such a pool is a collection of unconfirmed transactions pending processing. Most often, unconfirmed transactions are collected not in one giant pool, but in small, divided local pools.
  • Step 3: Miners located on the network (sometimescalled nodes or nodes, but this is not exactly the same thing as miners!), select transactions from mining pools and assemble a new “block” from them. A block is essentially a collection of transactions (at that point in time still unconfirmed transactions), plus additional metadata. Each miner collects his own block of transactions. The same transactions can be added to their blocks by different miners.
  • Example: Consider two miners, miner A and miner B. Both of these miners may decide to include some transaction X in their blocks. Each blockchain has its own restrictions on the maximum block size. In the Bitcoin blockchain, the maximum block size is 1 megabyte (MB) of data. Before adding a transaction to the block, the miner needs to check whether the transaction meets the execution requirements in accordance with the transaction history in the blockchain. If the sender’s wallet balance contains enough funds according to the existing blockchain transaction history, the transaction is considered valid and can be added to the block. If the Bitcoin owner wants to speed up the processing of his transaction, he can offer a higher reward for mining. In this case, as a rule, miners will assign a higher priority to this transaction compared to others, due to the possibility of receiving a greater reward for the mining process.
  • Step 4: By selecting transactions and adding them to your block,miners thereby create a block of transactions. In order for a block to later be added to the blockchain (meaning that all nodes on the blockchain will record the transactions contained in that block), the block first needs a signature, also called a “proof of work.” -work or PoW). This signature is created by solving a very complex mathematical problem that is unique for each block of transactions. Different blocks correspond to different mathematical problems, so each miner will work on solving his own problem, unique to the block he formed. All problems are equally difficult to solve. Solving such a mathematical problem requires a lot of computing power (and, accordingly, a large amount of electricity). You can compare this to performing calculations on a calculator, only in this case everything is much more complicated and is done on a personal computer. This process is called mining. If you want to learn more about the math problems involved in the process (it's actually not that difficult), then please continue reading. Otherwise, if you need a “lighter” material, go straight to “step 5”.

Mining, also known as hashing (Proof of Work consensus algorithm).

Mathematical problem to be solvedEach miner's job when trying to add a block to the blockchain is to find a hash sum (also called a digital signature) for the data in that block. Moreover, the signature must begin with a certain number of consecutive zeros. Looks like quite a difficult task, doesn't it? It's actually not that complicated. Let me try to explain this in a simplified way.

Before we continue, it is important to know what a hash function is. In simple terms, a hash function is a mathematical problem that is verydifficult to decide, but the response received is verysimplycheck.

The hash function takes a string of input data,consisting of numbers and letters (any, in the literal sense of the word, string of random letters, numbers and/or symbols) and converts it into a new 32-character string consisting ofrandomletters and numbers. This 32-character string ishash amount. If any number or letter in the input string changes, the hash sum will also change randomly. However, the same input stringalwaysthe output will have the same hash sum.

Now bear in mind that the data insidea block is the input for hashing (the same data row). As a result of processing this input data with a hash function, we get the hash sum (32-character string).

The Bitcoin blockchain stipulates thatonly those blocks can be added to the blockchain whose signatures (hash amount) begin with a certain number of zeros. However, the generated output row is always random for different rows of data in the input. But what if the data line of the block as a result of processing by the hash function does not give a signature (hash sum) at the output, starting with that certain number of consecutive zeros? So this is the reason that miners have to repeatedly change a piece of data in their block, called “nons” (English nonce). Each time the miner changes the nons, this entails a slight change in the layout of the block data. And when the data structure inside the block (that is, its input data) changes, its signature (or its output data) also changes. So, every time a block's nons changes, this block gets a new random signature.

This procedure for changing nonse is repeatedminers an infinite number of times, until in the end they accidentally stumble upon an output line that satisfies the requirements for block signing (a certain number of zeros at the very beginning).

The following is an example illustrating this process. The example uses seven zeros, but the number of zeros actually depends on the complexity of the block in the blockchain. The complexity of the block is a somewhat more advanced topic, so I suggest you familiarize yourself with it in a separate article.

How cryptocurrency transactions are processed and confirmed

</p>

This is how miners have to looka suitable signature for your block, and this is also the reason why so much computing power is required to solve this mathematical problem. Iterating through such a huge number of non-numbers in an attempt to guess the right one takes a lot of time and large computing power.

It should also be borne in mind that with increasing powerhashing (the number of miners) in the blockchain will increase the complexity of the mathematical problem, which will entail an increase in the average cost of electricity required to solve the block. You are great fellows if you read up to this point! Let's continue and go to step 5.

Note:This process is not actually defined asmathematical problem, but is rather something deterministic—computers perform predetermined operations on a number to find out whether the result is exactly what is required.

  • Step 5: The miner, the first one to find a signature that satisfies the requirements for its block, broadcasts this block and its signature to all other miners.
  • Step 6: Other miners now check for legitimacysignature by taking the data string of the broadcast block and hashing it to check if the resulting hash sum actually results in a signature included in the block with the correct number of zeros (remember, right? –hard to decide, Buteasy verify).If the signature is valid, then all other miners will confirm its validity and agree that this block can be added to the blockchain (that is, they will reach consensus, in other words - everyone will agree with each other - hence the term consensus algorithm). This is also where the term “proof-of-work” comes from. The signature is precisely the required “proof” that the work was done (the computing power was spent). The block can now be added to the blockchain and distributed to all other nodes in the network. They, in turn, will accept the block and store it, adding it to their transaction data, provided that all transactions within this block can be executed in accordance with the history recorded in the blockchain.
  • Step 7: After a block has been added to the chain,all other blocks that are added after it will be considered a "confirmation" for that block. For example, if my transaction is included in block 502 and the blockchain is 507 blocks long, that means my transaction has 5 confirmations (507-502). This is called confirmation because every time a new block is added after yours, the blockchain again reaches consensus on the entire history of completed transactions, including your transaction and your block. You can also say that the blockchain has confirmed your transaction 5 times at this point. This is also what Etherscan relies on when it shows you the detailed details of your transaction. The more confirmations your transaction has (in other words, the deeper in the chain your block is), the more difficult it will be for attackers to replace it. Once a new block is added to the blockchain, all miners need to start over from “step 3” and form a new block of transactions. Miners cannot continue (actually they can, but this is somewhat beyond the scope of this article) to mine the same block, in other words - solve the problem - the same block that they were working on previously for two reasons:
  1. First: it may contain transactions that wereconfirmed by the last block already added to the blockchain (remember that different miners can select / include the same transaction (s) in the block that they decide). Any of those transactions, if they are started again, may be invalidated, because there may already be insufficient funds on the balance of the sender's wallet.
  2. Second: each block must add a hash amount (signature)The last block added to the blockchain in its metadata. This is what makes blockchain blockchain (block chain). If a miner suddenly continues to mine the same block that he was already working on, other miners will notice that its hash amount does not match the one that was in the last block added to the blockchain and, as a result, this block is rejected.

5
/
5
(
2

vote
)