A blockchain, like a database, can be used to store data. However, the structure in which the data is stored is different. In a database, data is stored in the form of tables. However, in a blockchain, data is stored in blocks (chunks of data) that are chained together.
A transaction is a chunk of data stored on the blockchain. It can contain different forms of data depending on the purpose for which the blockchain is being used. A few types of data that can be stored in a transaction are as follows:
Votes: If we use the blockchain for electronic voting.
Property documents: If we use the blockchain for keeping property records.
Smart contracts: If we use the blockchain for running our code.
Local currency transactions (Bitcoin): If we use the blockchain for cryptocurrency.
The formats of Bitcoin and Ethereum transactions are as follows:
Bitcoin transaction format
Every Bitcoin transaction has some inputs and outputs (that are locked to the hash of the owner's public key) as shown below.
Every input points to a UTXO previously created in a transaction's output. This is done by using the ID of that previous transaction (where that UTXO was created), and as a transaction has an array of outputs, we need to provide an index of the output we need to use.
A unique index identifies every output, and it is locked to the hash of the owner's public key (contained in the ScriptPubKey). To unlock an output, we need to provide a valid public key and a signature to authenticate ourselves; only then will we be allowed to spend those Bitcoins.
Ethereum transaction format
Every Ethereum transaction has fields such as nonce, recipient address, the number of
A transaction is verified and added to the blockchain in the following steps:
A user generates a transaction and sends it to all the nodes on the network.
Nodes verify this transaction and add it to their
Nodes then broadcast their candidate blocks to the entire network.
A consensus is held, and every node verifies all the transactions in the candidate block before adding it to their
When most nodes add this block to their journals, this transaction is finally verified and becomes part of that blockchain.
Free Resources