Introduction to Blockchains

To understand the scope and use of smart contracts, crypto currencies, and non-fungible tokens (NFTs), we need to start with the basic concept of a blockchain. This section of Bitlaw introduces the structure of a blockchain, how they are built, and the basics of how cryptocurrencies utilize this structure.

This page is divided into these parts:

The Structure of a Blockchain

A blockchain is effectively a ledger or a database that is duplicated across multiple, independent computers. This ledger is public, in that anyone can see its contents. It is verifiable, in that all changes to the data are stored in the blockchain itself. It is permanent, in that no data within the blockchain is ever deleted once it is accepted into the blockchain. Perhaps most importantly, a blockchain is decentralized and leaderless—it operates in a “trustless” environment in which there is no central authority that is trusted to hold the data securely. Instead, the security is based on the public, widespread, and permanent nature of the blockchain.

Each data element in the blockchain is referred to as a block, and the blockchain is composed of multiple blocks that are chained together to form a history or ledger. A blockchain is decentralized because it is implemented in a peer-to-peer network. Every peer computer (or "node") on the network contains all of the blocks that comprises the blockchain:

Simplified Blockchain--store data in blocks with each node containing the same data

Every block in the blockchain contains the same, standard elements. In particular, each block contains some element of data, which might represent a fungible token of digital currency, a non-fungible token (or NFT), or a transaction in which the ownership of such a token is changed. In addition, each block contains a timestamp identifying the date and time that the data was added to the blockchain. Simplified, these elements look like this:

Simplified Blockchain--store data in blocks with each node containing the same data

In addition, every block contains a cryptographic hash of the previous block. Hashing algorithms are complex, mathematical functions that take a (large) input number and effectively create a fixed-size random number. The algorithm is consistent, always producing the same result with the same input, but small changes to the input results in a completely different output number. Digital data (including computer code and normal data) can be fed into the hash algorithm as the input, which creates a hash result that can be used to verify that the input digital data hasn't changed at a later time. When a new block is created, the previous block is run through a hash function, the hash result is created, and this result is then insert into the new block. Because of the presence of this hash result, it is impossible to change any block that has been accepted into the chain without detection.

Simplified Blockchain--store data in blocks with each node containing the same data

If Block #1 below were changed after its hash result was put into block #2, then block #1 would not longer generate the correct hash result when run through the hash function. The hash result of block #1 would not match the value in block #2, and the alteration would be identified. In this way, a blockchain is immutable—it is permanent and unchangeable.

Simplified Blockchain--store data in blocks with each node containing the same data

Because blockchains don’t require a central authority, and yet are immutable, they are an ideal candidate for the creation of a digital currency. One of the key issues with any digital currency is preventing someone from spending the same currency twice (known simply as the “double-spending” problem). Because a blockchain is decentralized and immutable, it is difficult for anyone to change, alter, or take back a prior transaction, thus largely solving the double-spending problem.

Bitcoin and the Blockchain

One of the first, and still the largest, of the digital currencies is Bitcoin. The Bitcoin currency is maintained through its own Bitcoin blockchain. The primary type of data on the Bitcoin blockchain is a transaction. Each transaction specifies in input (source of Bitcoin funds) and an output (where the Bitcoins are being transferred to). Multiple inputs and multiple outputs are possible on each transaction, and each input must refer to an unspent output that already exists on the blockchain. The transactions are grouped together into a block of data, and a new block of data is added to the Bitcoin blockchain approximately every ten minutes.

These ten minutes are required to perform the “proof-of-work” calculations, and this imposes a limit on the Bitcoin blockchain of allowing only between four and seven transactions per second. This creates a transaction bottleneck and is a significant limitation of Bitcoin and other crypto currencies. By way of comparison, the VISA network performs about 1,700 transactions per second. The slow transaction speeds can create congestion. During high traffic times, there is an increase in the number of unconfirmed transactions waiting to be confirmed, with miners charging more than $60 to ensure a timely recordation of a transaction. The last such spike was in April 2021. Current per-transaction costs on the Bitcoin network are $2-3 per transaction.

Ownership and Mining

Ownership in blockchain digital currencies like Bitcoin is generally based on “addresses.” Addresses utilize public and private encryption keys. The private key is used to compute a unique address. In order to spend Bitcoins associated with your address, you must use your secret private key to digitally sign the transaction to transfer your Bitcoins. These private keys are a long, random stream of characters, and are generally stored on a digital device. If you lose that device and the private key is not otherwise backed up, the currency associated with that address is un-spendable and permanently lost. Experts estimate that 20% of all Bitcoins have been lost in this manner (worth about $10 billion). Furthermore, if the private key is stored in a manner where it can be hacked, the Bitcoins can be transferred away from that address and stolen.

New blocks are approved for addition to the blockchain through the use of miners. Miners group transactions together into a block and include in the block a “proof-of-work.” The proof is usually a mathematical task involving finding unique numbers that have certain properties that are extremely difficult to find, but very simple to verify. The difficulty in finding the numbers can be (and is adjusted over time). For the Bitcoin blockchain, the difficulty is manipulated to help ensure that approximately one new block is added to the blockchain every ten minutes. Each new block is awarded newly minted bitcoins as well as fees associated with the transactions in the block. The number of new bitcoins minted decreases over time and is limited to a total of 21 million bitcoins, which will be reached by the year 2140.