Index
Ethereum and Smart Contracts
If you’re watching cryptocurrency news, you’ve probably heard about Ethereum and the phrase “smart contract”. You may even know that Ethereum is the original smart contract platform but do you know what a smart contract is or how it works? If not, we’re here to help.
What is a Smart Contract?
How Does a Smart Contract Work?
Now that we know what a smart contract is, how does it work? How do you “execute code on the blockchain”? Here, we’ll talk about how the Ethereum network in particular (and smart contracts networks in general) works.
Normal applications and code run on a computer. Someone builds your computer, someone else write the operating system and then application developers write code that runs in that operating system to do whatever they want. The functionality of the code is dependent on the developer’s goals and the capabilities of the computer that it’s running on (you can’t run programs designed for quantum computers on your desktop at home). This isn’t the paradigm used for smart contracts, it’s completely centralized and running on hardware you own.
The next step up is a virtual machine. This is a program that pretends to be a standard computer but runs on another computer. This other computer could be your computer at home or one owned by someone else (which is how Amazon Web Services or AWS works). In Ethereum, smart contracts run on a virtual machine but instead of running on a single machine (either at home or the cloud datacenter), it runs on every node in the Ethereum network. The Ethereum development team created the Ethereum Virtual Machine (EVM) to allow smart contracts to run on the blockchain.
The Ethereum Virtual Machine
Running a Smart Contract
A smart contract starts when a developer writes code in Solidity (Ethereum’s programming language) and uploads it to the blockchain. Once added to the blockchain, the smart contract is assigned an address (just like any other Ethereum user).
Under the hood, Ethereum runs on messages. To run a smart contract, a user sends a message to the smart contract including some Ether and possibly some data. The Ether that is sent is used to pay the nodes running the contract for their effort.
Each operation in the Ethereum Virtual Machine is assigned a Gas value. In Ethereum, Gas is a fraction of an Ether and works just like gas in your car: you need to put some in to make it run and how long it lasts depends on how hard you’re working it (it takes more gas to pull a trailer uphill than to coast downhill). An Ethereum smart contract will run successfully is the amount of Gas required is less than or equal to the amount provided. The Gas used goes to the node in the network that creates the block containing the execution of the smart contract.
What is an Ethereum Token?
You may have heard of Ethereum tokens but what are they? Many of the new cryptocurrencies that have been coming out in recent years are Ethereum tokens. Ethereum tokens are coins hosted on the Ethereum blockchain that are designed for a specific purpose. It’s like a wristband that you get at an amusement park that gives you access to the rides. You buy the wristband using money but money won’t get you onto a ride, you need the wristband for that. The same principles apply to Ethereum tokens. Someone develops a product (like the rides at the amusement park) and you have to pay them in their chosen currency (the tokens). The way that you get a token is by buying it with Ethereum.
Here, we’ll briefly discuss how Ethereum tokens are created and some of the current more popular Ethereum tokens.
How Ethereum Tokens are Created
The creation of Ethereum tokens is one of the possible uses of smart contracts on the Ethereum platform. A smart contract to create an Ethereum token is pretty straightforward. In a nutshell, the token needs three things:
- An initial allocation of tokens (all to the creator is a common option)
- A mapping of Ethereum addresses to balances (lets people look up how much of the token someone owns)
- A way to send tokens from one address to another (in exchange for Ethereum’s token, Ether)
If a smart contract implements this functionality (along with the necessary checking for transaction validity), then it creates a functional Ethereum token. This can easily be implemented in less than fifteen lines of Solidity code, making the development of new cryptocurrencies on the Ethereum platform extremely easy.
To make things work more smoothly, Ethereum has released Ethereum Requests for Comments (modeled on how the rules for how the Internet works are named Requests For Comment or “RFCs”) that describe optional compliance standards for tokens. Compliance with these standards (implementing a few functions with set names and basic functionality) lets other smart contracts interact with the token, making interaction within the Ethereum environment easier.
If you want to create your own Ethereum token but don’t want to mess around with the details of coding it up in Solidity, there are other options. The simplest is to check out Token Factory, which provides a user interface for defining a smart contract for a new Ethereum token. By entering some necessary information (total supply, name, smallest acceptable denomination, and symbol), you can generate a smart contract that can be uploaded to the blockchain to implement your new cryptocurrency token.
Most Popular Ethereum Tokens
At the time of writing, there were a little over seventy-seven thousand smart contracts on the Ethereum blockchain that implemented tokens in existence (check out https://etherscan.io/tokens for an updated number). This is a huge number and going through each one to determine the details of its functionality would take quite a while, not to mention the fact that (since smart contracts can’t be removed from the blockchain once they’re added) some of them may be defunct or updated versions of other tokens.
In order to give a bit of a feel for the types of tokens that are doing well on the Ethereum platform (and what is possible), in this section we’ll explore the tokens with the highest market cap at time of writing. Due to volatility of the cryptocurrency market and the influx of new tokens (the first release of Ethereum was in May 2015 and within three years, there are over 77,000 tokens), this list is a snapshot of the state of the Ethereum ecosystem. By the time that you’re reading this, any one or all of these tokens may have been overtaken by a different token or Ethereum may have been dethroned as the leader in the smart contract space. For an up-to-date list, check out https://ethplorer.io/top.
-
EOS
Ironically, the Ethereum token with the largest market share at time of writing is EOS, a smart contract platform and direct competitor to Ethereum. Compared to Ethereum, one of the main selling points of EOS is the capacity for parallelization. On Ethereum, a smart contract can only run sequentially, one instruction at a time. EOS gives smart contracts the ability to take advantage of the parallel processing capabilities of the computers in the network. This increases the speed and efficient of the EOS network compared to Ethereum.
The EOS token on the Ethereum network is intended as a means for people to buy into the EOS network before its launch and for the EOS developers to raise money for development. Once an EOS network is launched, tokens will probably be transferred from the Ethereum network to the EOS network via premining (recording transactions in the first block of the blockchain that give tokens to people who have purchased them on the Ethereum network). Despite being a token that doesn’t do anything on the Ethereum blockchain, EOS tokens have the current highest market cap.
-
Tron
-
VeChain Thor