Blockchain
The basics of blockchain technology
Last updated
Was this helpful?
The basics of blockchain technology
Last updated
Was this helpful?
Blockchain is a political technology advocating the following general principles:
decentralization: the organization of work is horizontal and not hierarchical
responsibility: individuals assume responsibilities themselves, they do not delegate them. This implies a higher level of commitment and knowledge
disintermediation: interaction takes place directly between the parties involved, without intermediaries
autonomy: the system, once initiated and settled, evolves with minimal intervention from the outside
transparency: information is public and verifiable by all
incentive: every rational individual has both intrinsic and extrinsic incentives to participate actively and honestly to the system, increasing its value
sovereignty of the individual: individuals own what they create; they can value and monetize it
Instead of command-and-control structures, blockchains set the incentives in a way that individual actors optimize their own utility if they cooperate according to the rules of the game.
A blockchain is:
a distributed system
using cryptography
to secure an evolving consensus
about a token with social or economic value
Blockchains bring together:
mathematics (cryptography)
computer science (distributed systems)
politics (mechanisms for reaching consensus)
economics (exchange of valued tokens)
Combined with emerging information markets, crypto anarchy will create a liquid market for any and all material which can be put into words and pictures. Timothy C. May, Crypto Anarchist Manifesto, 1988
Haber and Stornetta were trying to deal with the epistemological problem of truth in the digital age:
The prospect of a world in which all text, audio, picture and video documents are in digital form on easily modifiable media raises the issue of how to certify when a document was created or last changed. Haber and Stornetta, How to Time-Stamp a Digital Document, 1991
In particular, they started from two questions:
If it is so easy to manipulate a digital file on a personal computer, how will we know what was true about the past?
How can we trust what we know of the past without having to trust a central authority to keep the record?
They include in the front page of the paper the following citation:
Time's glory is to calm contending kings, To unmask falsehood, and bring truth to light, To stamp the seal of time in aged things, To wake the morn, and sentinel the night, To wrong the wronger till he render right.
William Shakespeare - The Rape of Lucrece
The numerous components of blockchain technology can make it challenging to understand. However, each component can be described simply and used as a building block to understand the larger complex system:
A block is a container for data
In its simplest form it contains:
an identification number
a timestamp of block creation
a bunch of data (usually, transactions)
Each block has a fingerprint called hash that is used to certify the information content of the block.
Hashes of blocks are created using cryptographic hash functions, that are mathematical algorithms that maps data of arbitrary size to a bit string of a fixed size
it uses a hash of 256 bits (32 bytes), represented by an hexadecimal string of 64 figures
is huge (more or less the estimated number of atoms of our universe), an infinite number for any practical purposes
Let's create some hashes from quite similar lines of a famous poem:
Blocks are chronologically concatenated into a chain by adding to the block a field with the hash of the previous block in the chain
it follows that the hash of each block is computed using also the hash of the previous block
this means that the hash of a block encodes all previous history of the blockchain
moreover, if you alter one block you need to modify not only the hash of it but that of all following blocks for the chain to be valid
the first block of the chain is called the genesis block and represents the initial state of the system
Two notable genesis blocks are:
Next we write some code to mine a new block and to create a chain of blocks:
The problem faced by the Byzantine generals is the same as that faced by distributed computing systems, such as blockchain systems.
How to reach a consensus on a distributed network where some nodes may be faulty or voluntarily corrupted?
In the blockchain setting, the problem is solved using one of the following consensus mechanisms:
proof-of-work (currently used by Bitcoin)
proof-of-stake (currently used by Ethereum)
In proof-of-work blockchains, miners work to find a solution to a computational problem that is hard to solve and easy to verify
this is a cryptographic puzzle that can be attacked only with a brute-force approach (trying many possibilities), so that only computational power counts
typically, the proof of work problem involves finding a number (called nonce) that once added to the block is such that the corresponding block hash starts with a string of leading zeros of a given length called difficulty
the average work that a miner needs to perform in order to find a valid nonce is exponential in the difficulty, while one can verify the validity of the block efficiently by executing a single hash function
the implementation of this consensus model uses resource intensive computations
Here is the code implementing the proof-of-work method, as well as the updated mine
and chain
functions using proof-of-work:
A block contains a header with metadata (like block number and timestamp) and a data field with a certain number of transactions
a transaction represents an interaction between parties, typically a transfer from sender to receiver of cryptocurrencies or of any other token, possibly mediated by a smart contract
each transaction has a fee that must be paid by the sender and depends on the network congestion and the complexity of the transaction
user 0x9674 (the buyer) interacts with SuperRare smart contract 0x65b4 (an NFT marketplace) and buys an NFT sold by user 0xf8b3 (the seller)
the buyer pays 2.06 ETH (1.7 goes to the seller and 0.36 to the marketplace as a fee)
the seller transfers the NFT to the buyer
the transaction fee is 0.02 ETH and goes to the miner
Blockchain uses asymmetric cryptography (also known as public-key cryptography) to implement digital signatures of transactions
asymmetric cryptography uses a pair of keys: a public key and a private key
the public key is made public, but the private key must remain secret
each transaction is signed with the sender's private key and anyone can verify the authenticity of the transaction using the sender's public key
Here is a code chunk that implements digital signature:
Finally, the blockchain ledger is distributed over a peer-to-peer network of nodes (computers serving the blockchain and running its protocol software). In this way, no central authority has control on the blockchain.
The steps to run the network are as follows:
new transactions are broadcast to all nodes using a gossip protocol: the software wallet that emits the transaction is connected to some nodes of the network and share the transaction with all connected peers, which in turn do the same. This ensures the transaction spreads rapidly in a breath-first visit of the network
each node collects some transactions into a block
on a proof-of-work blockchain, each node works on finding a difficult proof of work for its block; the first node that finds the solution becomes the miner of the block
in a proof-of-stake blockchain, a validator node is randomly selected - the likelihood of a node being chosen is proportional to the the stake of the node
the miner/validator broadcasts the block to its peers in the network using the same gossip protocol as above
nodes accept the block only if all transactions in it are authentic and not already spent
nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash (notice that all previous work is lost in case of PoW since miners need to work on a different block)
the reward for the miner/validator is inserted as a first transaction (called coinbase) of the mined block; in this way the miner/validator has an incentive to remain honest
All the code shown in this part is contained in the following R Markdown document:
Game theory is one of the fundamental ingredients of blockchain, which can be viewed as a game where players are miners or validators. Let's explore how two important concepts in game theory - Nash equilibrium and Pareto optimality - have an impact on blockchain systems.
Nash equilibrium is a concept in game theory, named after the mathematician John Nash. It represents a situation in which each participant in a strategic interaction makes decisions, taking into account the choices of others, and no player has an individual incentive to unilaterally change their strategy given the choices of the others.
Nash equilibrium is a fundamental concept in various fields, including economics, political science, and computer science. It is widely used to analyze and understand strategic interactions among rational decision-makers.
On the other hand, Pareto optimality, named after economist Vilfredo Pareto, concentrates on overall social welfare and efficiency. While Nash equilibrium focuses on stable individual strategies, a Pareto optimal outcome signifies an efficient allocation of resources where no further changes can be made to improve overall welfare without adversely affecting someone.
Pareto optimality is related to maximizing collective welfare without making any individual worse off.
On the other hand, Nash equilibrium focuses on individual self-interest and lack of incentive to deviate from one's strategy given the strategy of others.
In a game context, Nash equilibria do not always lead to Pareto optimal outcomes. This means that a situation in which each player maximizes their own gain may not be the best for overall welfare.
Let's explore the two different concepts using the famous prisoner's dilemma. The prisoner's dilemma is a game theory thought experiment that involves two rational agents, each of whom can cooperate for mutual benefit or betray their partner for individual reward. It models many real-world situations involving strategic behavior.
Two members of a criminal gang are arrested and imprisoned. Each prisoner is in solitary confinement with no means of speaking to or exchanging messages with the other. The police admit they don't have enough evidence to convict the pair on the principal charge. They plan to sentence both to a year in prison on a lesser charge. Simultaneously, the police offer each prisoner a Faustian bargain. If the prisoner testifies against the partner, he will go free while the partner will get three years in prison on the main charge. If both prisoners testify against each other, both will be sentenced to two years in jail. The prisoners are given a little time to think this over, but in no case may either learn what the other has decided until he has irrevocably made his decision. Each is informed that the other prisoner is being offered the very same deal.
This leads to four different possible outcomes for prisoners A and B:
If A and B both remain silent, they will each serve 1 year in prison.
If A testifies against B but B remains silent, A will be set free (0 years in prison) while B serves 3 years in prison.
If A remains silent but B testifies against A, A will serve 3 years in prison and B will be set free (0 years in prison).
If A and B testify against each other, they will each serve 2 years.
The Nash equilibrium is the strategy in which both prisoners testify against (betray) each other. This strategy optimizes individual self-interest. Indeed, if A betrays B, then:
A serves 0 years in prison if B stays silent, or
A serves 2 years in prison if B also betrays A.
Hence, on average, A serves 1 year in prison.
On the other hand, if A remains silent, then
A serves 1 year in prison if B also stays silent, or
A serves 3 years in prison if B betrays A.
Hence, on average, A serves 2 years in prison. Notice that the penalty of the case A remains silent is (1, 3) and totally dominates the penalty of the other case A testifies which is (0, 2).
In this case the Nash equilibrium is not Pareto efficient: the best solution for the group of two prisoners is clearly achieved when both remain silent (do not betray), collecting 2 years of prison overall. All the other solutions are worse (namely, 3, 3, and 4 years).
Let's investigate some examples of these game theoretic concepts concerning the blockchain. Imagine a blockchain where miners compete to validate transactions and add blocks to the chain. Each miner decides whether to participate in a mining pool or mine independently. The reward structure favors participation in a pool due to more consistent returns, but there are concerns about centralization.
The Nash equilibrium might occur when a majority of miners join mining pools because, given the choices of others, individual miners find it more profitable to pool their resources for consistent rewards. Deviating from this strategy (e.g., mining independently) could lead to a lower expected return. However, this is not a Pareto optimum, since the best for the whole collectivity is decentralization of the blockchain, hence individual mining or mining in small pools, because a decentralized system is not controlled by any single entity and hence it is more robust.
As another example, consider mining as a competitive game, where each miner challenges others to create a new block and receive a reward, with no binding agreements between participants. Personal incentive is maximized by following the rules of mining game. In fact, if a miner who has just mined a brand new block misbehaves, such as by changing the coinbase transaction that rewards them by inserting a larger amount, then that block will be discarded from the network. Consequently the miner will lose the reward and also their reputation as a miner. Note that the Nash equilibrium strategy of maximum individual profit, which corresponds to a sound blockchain running stably, is also the Pareto optimum, i.e., it also realizes the best scenario for the entire collectivity of blockchain users, including miners themselves.
In summary, a clever economic incentive design that promotes honesty over cheating underpins proof-of-work blockchain consensus process. Miners voluntarily incur financial costs ex ante in the expectation of a potential future reward. The threat of sunk costs (i.e. not receiving the block reward because of dishonest behaviour but having already paid for the performed work) — creates the financial incentive for miners to play by the rules.
Assuming miners are profit-maximising economic agents, honesty is the most rational strategy. As a result, Bitcoin may be considered less a technical innovation and more a carefully calibrated socio-economic system that relies on a complex combination of economic incentives, game theory, and a solid technical foundation.
As Vitalik Buterin points out, however, money in not the only incentive in blockchain systems:
We've seen time and time again that purely financial incentives do not yield stable systems. Power concentrations, pump and dump schemes and rug pulls are all profitable to some, while damaging to most. When participants act only for their own profit, with no regard for the long game, every system is doomed.
Transactions in Bitcoin blockchain contain:
one or more inputs
one or more outputs
an amount to be transferred
The fee paid by the sender for a transaction on the Bitcoin network depends on how congested is the network at the transaction time and on the size of the transaction, which is affected primarily by the number of inputs.
The corresponding cryptocurrency is bitcoin (ticker: BTC).
A cryptocurrency is a permissionless system that operates without a central authority. Users are free to use the network and transact without prior approval by others. Like physical cash, users can transact pseudonymously and remain in full control of their own funds, a feature called self-custody. No single actor can unilaterally seize assets, reverse transactions, or change the ruleset. The blockchain also operates 24/7 around the clock and is cross-jurisdictional by nature. A cryptocurrency is secured by cryptography, which makes it nearly impossible to counterfeit or double-spend.
These properties do come at significant costs, however – a large network with massive redundancies, scalability and performance constraints, slow coordination and decision-making, and, sometimes, an expensive and energy-intensive consensus mechanism.
The market cap of a cryptocurrency (or of a company) is the the circulating supply multiplied by the current price of the crypto (or company's share). Here is a comparison of market caps of cryptos and largest US companies:
The origins of blockchain go back to the and movements of the late 80s, both influenced by the . These movements advocate widespread use of strong cryptography (highly resistant to ) in an effort to protect privacy, political and economic freedom.
An excerpt from the by Timothy C. May (1988):
An excerpt from the by Eric Hughes (1993):
The technical specification of blockchain was proposed in 1991 by Stuart Haber, a cryptographer, and Scott Stornetta, a physicist. They published their work in The Journal of Cryptography in 1991 under the title and one year later they registered it with a US .
a popular hash algorithm is , designed by the United States National Security Agency (NSA)
the of Bitcoin blockchain
the of Ethereum blockchain
Bitcoin total hashrate is measured in EH/s (exahashes per second, where 1 exa = ). Here is a of bitcoin total hashrate.
here is a real on the Ethereum blockchain:
(Rivest–Shamir–Adleman) is one of the first asymmetric cryptography algorithms and is widely used for secure data transmission
Asymmetric encryption is also employed to secure (encrypt) messages, as explained in the following video from that digs deeper into symmetric vs. asymmetric encryption:
here is a (funny) blockchain
Dig deeper:
Ron Howard's movie tells the story of John Nash, played by Russell Crowe.
We could say that Bitcoin miners don't collude because they are worried about their reputation, and the reputation of the Bitcoin blockchain as a whole.
In this Vito Lops interviews Federico Rivi about the importance of game theory for the blockchain (in Italian).
was in 2008 by Satoshi Nakamoto (a pseudonymous) and launched in 2009.
To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender — Satoshi Nakamoto,
was conceived in 2013 by programmer Vitalik Buterin and launched in 2015. On September 15, 2022, Ethereum underwent a significant change by transitioning from a proof-of-work-based consensus mechanism to proof-of-stake.
Ethereum allows anyone to deploy permanent and immutable - programs that executes the terms of a contract and run on the Ethereum Virtual Machine - written in a Turing-complete language called Solidity.
Smart contracts are the building blocks of decentralized applications (dapps) - applications that are deployed on blockchain networks - and the set of dapps forms the , a decentralized extension of Web 2.0.
is a high-performance blockchain designed to offer scalability, speed and low cost. While the idea and initial work on the project began in 2017, Solana was officially launched in 2020 by the Solana Foundation.
is a proof-of-stake programmable blockchain launched in 2018. Since transactions are very fast to resolve and cost a fraction with respect to Ethereum, Tezos became very popular as an entry door to Web3, in particular for young artists, mining on the marketplace Hic et Nunc (defunct and resurrected as ) as well as on and .
the of principal cryptocurrencies
the of the largest US companies