A blockchain is the structure of data that represents a record of a transaction. it is a data structure to create and share distributed ledger of transactions among a network of computers. it contains a growing list of records called blocks which are linked using cryptography. The first major application of blockchain technology was bitcoin which was released in 2009. Bitcoin is a cryptocurrency and the blockchain is the technology that underpins it. A cryptocurrency refers to a digital coin that runs on a blockchain.
Blockchain data structure
A block is a container data structure, which brings together transactions for inclusion in the public ledger, known as the blockchain. The block is made up of a header; containing metadata, followed by a long list of transactions.
The block header consists of three sets of block metadata -data of data- there is a reference to a previous block hash, which connects this block to the previous block, lying in the blockchain. It does include
index It’s the position of the block on the blockchain. For instance, the first block for any blockchain has 0 as index
hash It’s the result of a hash function to the components of the block. For example, the hash function used in Bitcoin is a variant of the SHA2 with 256 bits digest which is SHA256, In Ethereum SHA3 is used.
previous Hash It’s the hash that links or chains a block to its predecessor. The reason behind the denomination “Blockchain”.
timestamp the UTC Unix timestamp of when the block was created.
nonce a 32/64 bits integer used in the mining process.
numTx the number of transactions in the block.
transactions an array of all the transactions that are found in that block.
represents a transfer of ownership. And what is more interesting with cryptocurrencies is you can create some of the most transactions you have ever dreamed of, It does include
hash It’s a message digest of the data included in a transaction like its type, the transaction outputs, and transaction inputs data.
type It’s the type of the transaction.
is where you declare where the token you plan to transfer comes from. It does include
txid The id of the blockchain aware transaction where the token you try to unlock comes from.
vout Its index on that transaction’s outputs array.
amount the amount of token you are trying to unlock.
unlockingScript this is a list of script operation codes + data like a digital signature and public key where you provide a script to unlock the tokens.
The transaction output represents where the tokens are being spent. It does include
amount: the number of tokens to be spent or transferred.
locking script: its the script that sets the rules on the address that will be receiving the tokens. it does contain most of the time some script operation codes and an address.
How does it work
The bitcoin blockchain is “decentralized,” meaning it is not controlled by one central authority. While traditional currencies are issued by central banks, Bitcoin has no central authority. Instead, the bitcoin blockchain is maintained by a network of people known as miners. These “miners,” sometimes called “nodes” on the network, are people running purpose-built computers that are actually competing to solve complex mathematical problems in order to make a transaction go through. For example, say lots of people are making bitcoin transactions. Each transaction originates from a wallet which has a “private key.” This is a digital signature and provides mathematical proof that the transaction has come from the owner of the wallet.