top of page
Search
  • Writer's pictureShruti Jain

Journey of a Transaction...


The smallest unit of the Blockchain is the transaction that has to executed, being the main function of this technology. Transaction in a blockchain means the same as it means in common, i.e., transfer of assets between two parties. In blockchain, the transferred value is the cryptocurrency/tokens from one wallet to another over the network. There are many centralized examples of transferring money digitally. For instance, Paytm, GPay, .etc. Blockchain offers a decentralized mechanism to process these transactions worldwide.


Before getting into steps of processing these transactions, let's define the structure of a transaction.


Structure of a Transaction


Transaction Hash:

Hash values generated by putting all the contents of the transaction in the hashing algorithm, for example, SHA256, Keccak256, .etc.


Timestamp:

The exact time at which the transaction was created. This field also mention the time at which teh transaction gets executed.


From Address:

Public key of the sender (initiator of the tx).


To Address:

Public key(s) of the recipient(s).


Value:

Amount intended to be transferred from the sender's wallet to the receiver's wallet.


Fees:

Now this is a controversial field. Transaction Fee is a small about of crypto that the sender needs to send with the transaction. This increases the probability of the transaction to be included in the next block. Greater the fee, greater are the chances of the tx to get picked.

BUT. Who pick these txs?

THE MINER.

YES!. The miner picks the transactions with greater fee to include them in the block. This fee is redeemed by the Miner along with the Block reward. All the conducted transactions are recorded in a temporary ledger, The Memory Pool or Mempool in short. These are there referred to as the pending transactions. The miners are required to pick the oldest transactions from this pool with maximum fees and include them in the Block. But why the oldest transactions? This we will understand in a while.


Block Number:

The number/height of the Block it is included in. If the transaction in still pending, it will just say Mempool.


Status:

The status of the transaction, i.e., pending or confirmed.


Tx Nonce:

This is actually the sender's wallet transaction count, i.e., number of transactions conducted with that wallet +1. Here comes the explanation of the question: Why miners have to pick the oldest transactions? Actually the Txs have to be the oldest one from that specific wallet. For example, let's suppose, Alice has conducted 3 transactions with her wallet. The Tx Nonce of these will be 1, 2 and 3 respectively. The transaction are currently in the Mempool. The Miner picks up the 2nd transaction and mines the block. Now according to Alice she first conducted Tx with Nonce 1 but according to Blockchain network she has conducted Tx with Nonce 2. This creates discrepancy.

Therefore, Miners have to pick the oldest transaction of a specific wallet to maintain the sequence of the events.


Input Data(Optional):

Any optional message sender needs to include in the transaction. This message is encrypted and can only be decrypted with recipient's private key. It is mostly confidential.


Apart from these, different blockchain architectures may have other parameters. But these are the most idea parameters that every architecture must define.



Now let's talk about how a transaction is created, processed and executed.


Processing of a transaction




As shown in the figure above, the sender first fills out the required fields(amount, fee, recipient's public key) and creates the transaction through his wallet. After the Tx creation, the sender signs the transaction with his private key, and the wallet application includes this signature in the transaction for verification.


Once the transaction is sent from the sender's wallet, it gets stored in the memory pool(pending state).

The miner picks up the transaction and includes it in a block. After mining the block, it is broadcasted over the network. Other peers receive this block and validate it as well as the transactions included in the block by validating the signature using the public key of the sender of a particular transaction.


If the block is valid, the peers add it to their blockchain and the transactions of that block get executed and removed from the memory pool. In case the block gets rejected, all the transactions fail and are sent back to the memory pool.


Different blockchains may have different methods of taking input, output or recording the transactions. For instance, Bitcoin uses the concept of Unspent Transaction Outputs (UTXOs). This means, that the whole balance of the sender's wallet goes inside the input field of the transaction, and the amount to be sent and the remaining balance is included in the output. This remaining balance output is considered as a UTXO. Bitcoin blockchain stores these UTXOs to keep track of balances of the wallets. We will study about it later in detail.


For now, let's discuss consensus algorithms and more about mining in the next post...


Till then KEEP READING AND STAY TUNED!.




22 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post
bottom of page