How Does Cryptocurrency Work?

You need an explanation of how cryptocurrency works? Simple.
Dec 28, 2022
10 min

What is Cryptocurrency?

Don’t be confused by the name: Virtual money is NOT the only use case for cryptocurrency, but using cryptocurrency as virtual money is a popular use case.

What is Currency?

Whenever you want something of value, you trade something (of value) to get it. There are many types of value (monetary, social, sexual, etc) that humans use to trade. In the modern day, fiat cash (fake cash) is the most popular form of value used to exchange goods and services. This money is a type of currency (i.e U.S Dollar, Eurodollar).

What is Cryptography?

Cryptography is a practice that uses math to encode and decode messages for various purposes, including secure communication and password protection. 

The Combination

When you combine cryptographic technology (used for encryption) and currency (used to provide value), the result is cryptocurrency.

How Does Cryptocurrency Work?

Cryptocurrency itself is a concept: In the modern day, cryptocurrencies are implemented via software. As a result, it’s important to understand what software is and how it’s developed.

What is Software?

Software represents a virtual set of instructions used to execute operations using hardware. In other words, software uses hardware (computers, phones, etc) to run applications (i.e calculator). For example, your web browser is software that runs on your computer (hardware) to load web pages.

When the web browser application starts, the computer executes instructions to load a Graphical User Interface (GUI) that you can see. Then, the computer sends network requests to other computers to retrieve webpage information, processes that information, and so on.

For more information, read “What Happens When You Search Google?

What is Object Oriented Programming?

Software developers use programming paradigms to conceptualize their programs. Object Oriented Programming is a programming paradigm that organizes code (sets of instructions) using “objects”. In the context of this article, Object Oriented Programming is important as it highlights how programmers model virtual objects (in software programs) using physical objects (in the real world).

Let’s say you want to create a virtual representation of a Dog. To do this, you can create a Dog data type and give that type properties that a physical dog has.

// Data Type
type Dog struct {
// Type Properties
Name string
Breed string
Weight string
Eyes int
Limbs int

}

You can also give this dog actions using functions.

func (d Dog) bark() {
fmt.Println(“arf”)
}

Why Does It Matter?

While there is no guarantee for a program to use Object Oriented Programming, it’s typical for a program to maintain the name of its physical representation. The usage of words such as “portfolio” within stock market trading applications, “mail” within email programs, and files (paper) within computer file systems (storage) are no exception.

Remember this as you learn about the technologies that power cryptocurrencies (such as Bitcoin and Ethereum).

What is a Transaction?

transaction is an exchange of goods or services between multiple people. For example, when you purchase bread at the store in exchange for money. In the physical world, you store information about a transaction on a receipt. On the internet, you store it in a database (base of data).

What is the Blockchain?

Traditionally, you use a relational database to store transactional data — containing information about your transaction (i.e bread, cost, etc) — in a relational table: A relational database itself is a program — that runs on a computer — in a similar manner to any other program (i.e web browser) that computers run. Read When to Use a Database as a Spreadsheet for more information about databases.

Storing transactional data in tables is beneficial because it allows you to retrieve that data back efficiently as long as the computer running the database (program) is available. However, the database will be unusable if the computer (server) becomes inaccessible or hacked.

This is a significant problem.

blockchain decentralizes the functionality of a database: Data is stored in a chain of blocks instead of tables, hence the name. Decentralization is implemented using multiple computers (servers) connected via a network (internet, lan, etc). These computers communicate over the network to validate the blockchain.

Suppose a single computer on a network becomes inaccessible or gets hacked. The information you need from a blockchain is still accessible from other computers.

A cryptocurrency uses a blockchain because being unable to use the currency when a single (centralized) server goes down would be catastrophic. The downside of using a blockchain is that it requires communication among multiple servers, whose latency slows down the speed of each transaction. Furthermore, using cryptographic operations (encryption) to secure a network can be relatively time-consuming. So a decentralized blockchain may be slower than a centralized database by hundreds of nanoseconds (which adds up over millions of transactions).

Graph of time measurements from second to nanosecond to attosecond.

How Does a Transaction Work?

Here is how a typical transaction on a blockchain works. 

The Transaction

John has a (free) virtual wallet that allows him to store a specific cryptocurrency coin and ONLY that coin. In this case, Bitcoin. John’s wallet has 2 keys: A public key used by the public to send John currency and a private key used to access his currency.

The wallet’s private key is randomly generated by encrypting a 24-word password known as a seed phrase. If John loses or deletes his wallet from his device(s), he can regenerate it on another device using the wallet’s seed phrase.

John wants to send a birthday gift to Sarah, who also owns a Bitcoin wallet. Sarah gives John the public key to her Bitcoin wallet so that he can send Bitcoin to her (from his wallet). John carefully copies and pastes Sarah’s public key into a function that initiates an action to send Bitcoin to Sarah’s wallet: This action is executed if John’s private key is valid.

In the case of Bitcoin, time is required for other computers in the network to validate this transaction using a proof of work algorithm. When the transaction is validated, it’s (publicly) stored on the blockchain (of every computer in the network): Sarah will receive the Bitcoin John sent and be able to use it instantly.

No single entity can stop this transaction.

Every cryptocurrency works differently: You can learn how a specific cryptocurrency token works by reading its White Paper, which states the problem the cryptocurrency token aims to solve and its technical details. For example, read Bitcoin’s White Paper.

What is an Exchange?

cryptocurrency exchange is an abstraction of the basic features wallets have. As a reminder, a cryptocurrency wallet holds one type of cryptocurrency token. However, you may want to exchange many different types of cryptocurrencies. So what’s the solution?

If you create a wallet for each cryptocurrency token, you can exchange every cryptocurrency token. If everyone does the same thing, then everyone could exchange every cryptocurrency token with each other. This logic is the idea behind a cryptocurrency exchange: It manages your wallets to make transactions among multiple cryptocurrencies easier.

How Does an Exchange Work?

A cryptocurrency exchange is implemented using software. As a result, you cannot describe how a cryptocurrency exchange works without its code. That said, there are typically two types of cryptocurrency exchanges: Centralized and Decentralized.

What is a Centralized Cryptocurrency Exchange?

centralized cryptocurrency exchange (CEX) functions similarly to the NYSE stock market: A single entity and its servers manage every account and every transaction. As a result, the centralized cryptocurrency exchange maintains its own order book and decides how a “representation of cryptocurrency” is distributed. In other words, there is no guarantee that the funds you own in centralized exchanges exist on the blockchain.

Centralized cryptocurrency exchanges typically manage funds within their own wallets. As a result, the private keys required to access your “funds” are owned by them. So just as banks can lose your fiat cash, centralized cryptocurrency exchanges can lose your fiat cryptocurrency coins. Hence the phrase, “Not your keys, not your coins.”

What is a Decentralized Cryptocurrency Exchange?

A decentralized cryptocurrency exchange (DEX) functions as a supervisor in an exchange between two people (peers) without being a third party in a transaction. Multiple entities run computers (servers) with automated programs which manage transactions between actual cryptocurrency wallets. In other words, you use a DEX with your wallet to perform transactions on the blockchain that exchange your funds.

It’s typical for a decentralized cryptocurrency exchange to be governed by its own cryptocurrency token: This exchange token controls the platform and rewards people supporting the DEX’s operations. As an exchange token is a cryptocurrency, the benefits to holding it will be outlined in its White Paper.

What is a Swap?

You must perform a swap when you need to exchange two different types of cryptocurrencies: A swap directly exchanges one cryptocurrency token with the equivalent value of another token through a smart contract. This “smart contract” is simply another set of instructions (software) that is automatically executed upon confirmation of the transaction. 

Smart contracts are called “smart” because — unlike real-life contracts — they are automatically executed.

Swaps have many use cases. Especially when you need to transfer a token with a high network fee between exchanges: When the transaction cost is high for a given cryptocurrency coin (i.e Bitcoin), consider swapping it to a feeless cryptocurrency coin (i.e Nano) on the original exchange. Once the cryptocurrency has been swapped, send it to the new exchange and swap it back.

How Does a Swap Work?

A swap is an abstraction over multiple transactions between wallets. While the details of a swapping algorithm may differ depending on the exchange, the algorithm typically comes down to the following steps (where cryptocurrencies A and B are swapped between person 1 and 2).

  1. Send cryptocurrency A from wallet A1 to wallet A2.
  2. Send cryptocurrency B from wallet B2 to wallet B1.
  3. If either transaction fails (due to an error), revert the other transaction.

How Do I Swap Fiat Cash?

Fiat cash is a currency managed in a centralized system (typically by a government). While fiat cash is exchangeable for cryptocurrency tokens in any exchange that supports it, you must understand its legal implications. If a cryptocurrency token isn’t recognized as a form of currency by your government, then the exchange of fiat cash for cryptocurrency coins is recognized as a digital asset transaction (which carries tax implications).

For this reason, many DEX’s avoid cash-to-crypto transactions while CEX’s adhere to Know Your Customer (KYC) laws.

What are Layers?

As cryptocurrency evolves, so do the mechanisms behind it. Layers refer to the level a cryptocurrency coin operates on. A layer one cryptocurrency token (L1) is a standalone token that operates on its own blockchain (i.e Bitcoin, Ethereum). A cryptocurrency that contributes or operates under a layer one token’s existing blockchain is known as a layer two cryptocurrency token (L2).

Ethereum is an example of a layer one token that provides important building blocks for creators of cryptocurrency by being able to store code (smart contracts) in its layer two tokens. These layer two tokens benefit from Ethereum’s ecosystem and security protocols. In addition, a person can store any and multiple types of ERC-20 layer two tokens within a single Ethereum wallet.

rollup is another example of a layer two token. These types of tokens aim to improve certain aspects of the layer one token. If the network fees for Bitcoin become too expensive or time-consuming, you can use a layer two token for faster and cheaper transactions. This functionality can be implemented by storing multiple transactions in a faster database or blockchain, batching them together as a single transaction, then rolling them up to the main blockchain.

Why Do People Use Cryptocurrency?

This article analyzes the first modern cryptocurrency coin — Bitcoin — to demonstrate why someone would use it. However, you must understand that every cryptocurrency has its own objective, use case, logic, etc. You must read a cryptocurrency’s White Paper and confirm that the cryptocurrency does what the paper actually says before using it.

Bitcoin aims to provide a decentralized financial system. In the modern day, people use fiat cash which maintains no value beyond its belief. In other words, fiat cash is only valuable because people believe it is. So how is fiat currency created? An entity (i.e government) that manages the fiat cash makes it out of thin air by typing a “1” followed by many “0” s in a centralized database.

So what’s the problem with this?

Understanding Inflation

Have you ever walked into a store and noticed the price of a Loaf of Bread went from $1 to $2? Well, there are two ways this can happen. The first being that the value of the Loaf of Bread increased: Perhaps, more bread was included in the package. Since there is more bread, there is more value you have to pay for.

The second way the price of the Loaf of Bread can increase is when the value of your money decreases: When your money is worth less, the Loaf of Bread costs more. The amount and quality of the bread didn’t change, but your money did. So how did that happen?

When more money is created, and the demand for it stays the same, the Law of Supply and Demand indicates that the value of the money will decrease. This results in inflation — which measures the increase in prices over time — and is an issue for the 99% who don't own many assets.

Understanding Centralization

In a centralized financial system, the owner — in this case, the government and banks — can withhold information or prevent transactions from occurring. For example, American Banks control large amounts of fiat cash and decide who, when, and where you can send money. Banks can also decide to reverse transactions or create money out of thin air through loans and credit.

While the above practices are not inherently positive or negative, they allow bad practices to go unnoticed. Events such as the Subprime Mortgage Crisis in 08’ and Naked Shorting in 20’ are only possible in opaque (non-transparent) systems. The financial crimes that lead to these events are worse than murder since they destabilize entire communities.

But no one goes to jail for them.

Understanding Bitcoin

Bitcoin aims to solve these issues through a system that is verified by the public and virtually impossible to manipulate (in a technical manner). No bitcoin is created unless it follows the exact protocols set forth by the Bitcoin code, which is also open to the public (GitHub). When source code is available to the public, the software it builds is Open Source Software (OSS).

Understanding Cryptocurrency Concepts

As a reminder, each cryptocurrency token works differently and is subject to change over time. For this reason, this article doesn’t spend much time on specifics such as Proof of Work, Proof of Stake, or Non-Fungible Tokens (NFTs). However, you can use the information you have learned to better understand those things on your own.

What are the Issues With Cryptocurrency?

The largest issue with cryptocurrency is you. If you cannot keep the ownership of your digital assets secure — by mishandling them or trusting bad cryptocurrencies — you will lose them. In the rawest form of cryptocurrency usage, no one can reverse these mistakes (due to the nature of decentralization).

Cryptocurrency is a technology: It does NOT stop scams, Ponzi schemes, or any other fraudulent financial crime — that stems from the human usage of currency — from occurring.

Read More

link