In another article, we introduced the evolution, benefits, risks and exciting developments in the world of altcoins, so in this piece, we’re getting a little more technical. This article will take a look at just how cryptocurrencies work. From the creation of safeguards crafted to protect investors, like ‘smart contracts’ to ‘consensus algorithms’ and their transactions, let’s look at the structure of this at times enigmatic financial innovation that is crypto.
You may have heard that cryptocurrencies are programmable money. But what does that mean, and how is it achieved?
Smart contracts are simply pieces of code executed by a blockchain network to perform some set of tasks as defined by the smart contract author. Once deployed, the smart contract code can never be altered, and it can be automatically executed or enforced without the need for a third party.
Why do we need smart contracts?
Cryptocurrencies are distributed ledgers that are being kept in sync by the cooperation and agreement between multiple computers. At their core, cryptocurrencies allow you to transfer ownership of units of the currency from one person to another; this transfer is registered in the ledger for perpetuity. But what if you want to do more than just transfer units of some currency?
What if you want to transfer these units only after some specific amount of time has passed, or only if some event has occurred? Enter smart contracts!
Smart contracts make use of the immutability property of blockchains, and they are not reversible.
How are smart contracts created, and where are they deployed?
Smart contracts can be written in different programming languages depending on the smart contract platform for which they are destined.
A plethora of smart contract platforms exists today. The most well-known are Ethereum, NEO, EOS, Cardano, Stellar, and VeChain; the list is long. On Ethereum and many other platforms, smart contracts are written in a language called Solidity, which was designed specifically for smart contracts, whereas on other platforms, such as NEO, you can write smart contracts in generic languages such as C#, Java and Python.
What are use cases of smart contracts?
While the use-cases for smart contracts are limited by little more than the author’s creativity, the most common use-case for smart contracts is that of token creation. Most crypto tokens are nothing more than a smart contract running on a smart contract platform. In fact, this use-case is so common that there are standards for creating tokens on most, if not all, smart contract platforms. On Ethereum, this standard is called ERC-20, whereas, on NEO, it’s called NEP5. These standards define a minimum set of functions that a smart contract must have.
The beauty of public smart contract platforms is that anyone can write and deploy a smart contract and execute it on all the computers in the network. Since a smart contract uses resources on all the computers in the network to run, invoking a smart contract function is not always free. Most smart contract platforms measure the complexity of the invoked function to determine its cost. Once deployed, a smart contract cannot be changed.
Oracles and smart contracts
Smart contracts sometimes require input from the real world. Imagine a smart contract that allows people to enter wagers on the outcome of a football match. The smart contract is perfect for managing the funds and ensuring that those who win get their winnings and those who lose get nothing, but what it can’t possibly know is the outcome of the football match. For this purpose, one or more third parties are needed to feed the smart contract with the result of the football match by invoking a function. Such a third party is called an oracle.
An important property of a smart contract is that it verifiably does what it says it does – nothing more and nothing less, and its code cannot be changed once it has been deployed. The contract eliminates the need for transacting parties to trust each other because they know what the smart contract does, so everything is imbued with a sense of trust, no matter relationship or geographic location.
There’s a good chance that smart contracts will facilitate most transactions that we humans make with each other in the future. In everything from banking, insurances, digital identity management, supply chain, gaming, gambling, you name it, the use cases for tamper-free, verifiable, programmable interactions via smart contracts are vast, and we are just scratching the surface.
ERC-20 might sound like a military codename, but in reality, it is much simpler than that. An ERC-20 token is simply a token built on the popular cryptocurrency platform Ethereum.
ERC-20 stands for Ethereum Request for Comments. The “20” is simply the number that was attached to the original proposal. ERC-20 denotes the nine functions a cryptocurrency should abide by to operate within the Ethereum Network when creating a cryptocurrency.
The primary currency on the Ethereum network is Ether; however, the Ethereum Blockchain supports many cryptocurrencies that comply with ERC-20 standards. The network allows individuals to create their own cryptocurrency without rebuilding the entire wheel.
Functions of ERC-20 tokens
ERC-20 tokens must have nine built-in functions (six mandatory, three optional) to operate fluidly within the Ethereum Network. These functions maintain the ability of ERC-20 Tokens to communicate effectively with each other.
The three optional functions are simple. When creating a token, you have the option to give your token a Name, a Ticker Symbol (ex. ETH), and Adjust the Divisibility of the Token (how many decimal places your token will support.). The rest six are more technical, which for brevity, we’ll skip for the moment.
The birth of the ERC-20 standard allows all of the projects on the Ethereum Network to interact with one another without the need to program those interactions on a one to one basis. It ensures complete flexibility and fluidity between all ERC-20 Tokens.
ERC-20 isn’t as complicated as it seems. It is merely a set of nine functions that allow projects built on the Ethereum Network to interact seamlessly in a controlled and predictable way.
The standard also acts as built-in security within the Ethereum Network by ensuring certain constraints that mitigate illegitimate activity.
The creation of the ERC-20 Standard is directly responsible for the massive amount of projects built on the Ethereum Network and the 2017 ICO boom. It allowed the average user to design and implement their own cryptocurrency projects with ease, which is why it remains the most popular token format today.
In our article ‘What is Consensus?‘ we introduce consensus and why a cryptocurrency requires consensus between nodes to validate transactions. However, not all cryptocurrencies reach consensus in the same way; these different methods are called Consensus Algorithms. The Consensus Algorithm a cryptocurrency uses is a fundamental part of its design. It determines how many nodes the network will support, how easy the network is to attack, and how fast the network can confirm transactions. For these reasons, it is important to choose a consensus algorithm that can achieve the right amount of decentralisation, speed, and security for each use case.
There are many algorithms, and more are being developed every day, but here are the most popular:
Proof of Work
The oldest and most popular cryptocurrency, Bitcoin, uses the proof of work (PoW) consensus algorithm, a concept presented originally in 1993. In proof of work, miners compete using computers of higher speeds to solve a mathematical problem. The first miner that solves the mathematical problem then confirms the transactions in that block and receives the block reward and transaction fees. As the total processing power of the network increases, the maths problems become more complex so that they are not solved faster. In this consensus algorithm, a 51% attack can only be made by having 51% of the network’s total computing power, which is why bitcoin is so difficult to attack today.
Proof of Stake
Proof of stake or PoS was a consensus algorithm first implemented by Peercoin in 2012. It is seen as one possible solution to the large amount of electricity used by proof of work. Like the other systems that follow, it does not require computers to compete to confirm transactions. Instead, proof of stake uses random selection weighted based on a node’s coin balance to select which node will confirm the next block and receive the corresponding block reward.
Delegated Proof of Stake
Delegated proof of stake (DPoS) is a type of proof of stake that reduces the number of nodes that participate in validating blocks. It does this by requiring users to vote for representatives who will validate blocks on their behalf. Block rewards are then passed down to the voters of the nodes in a similar way to a mining pool. By having only a handful of validating nodes, the transaction speeds are much higher, however, some question the level of decentralisation these platforms can achieve. EOS is most famous for using this algorithm, however, it has quickly become one of the most popular other than proof of work due to its faster transaction speeds. Unfortunately, having a low number of nodes increases the chances of collusion, and as demonstrated by the public Lisk cartel that formed, this can be a very real threat.
Byzantine Fault Tolerance
Practical Byzantine Fault Tolerance (BFT) is a method of reaching consensus as long as at least two-thirds of the network is trustworthy. The nodes in these cryptocurrencies are preselected and vote in BFT rounds to validate blocks. This method of consensus is normally more ‘scalable’ with high throughput and fast finality. Unfortunately, they are more centralised since they cannot support a large number of nodes. BFT consensus is deterministic and has a fixed number of participants in each round of voting.
There are too many PoX protocols to introduce them all. Interested readers can read our beginner’s guide to consensus mechanisms for a summary of the most well-known PoX consensuses today.
The Role of Altcoins in the Crypto World
As you’ve probably learned from this piece, the crypto world is a self-policing world. It’s built on both the freedom to explore and innovate, as well as a mutual, technology assisted series of checks and balances designed to ensure that the system is fair and free from corruption. When done right this financial form could be considered the utopian ideal. While it’s still early days, we’re excited to see just what happens to the future of crypto.