- PROJECT HELP
By Demir Selmanovic, lead technical editor at Toptal, a company that provides freelance engineering talent, including virtual currency engineers.
While bitcoin continues to grow, blockchain technology, the supporting technology behind bitcoin, has allowed for the creation of more than 700 “altcoins” that provide many of the same benefits of bitcoin.
In part one of this two-part series, we discussed several of the key elements needed in creating a decentralized, anonymous system for exchanging money and information: decentralized sharing, cryptographic hashing and digital signature.
Next we come to a core component of a virtual currency system, miners, whose main purpose is to confirm the validity of every transaction requested by the users of the virtual currency.
Miners do the computationally-intensive work.
In order to confirm the validity of a transaction (or a combination of several transactions requested by a few other users), miners will do two things.
First, they will rely on the fact that “everyone knows everything,” meaning that every transaction executed in the system is copied and available to any peer in the network. They will look into the history of a given user’s transactions to verify that they actually had 100 coins to begin with. Once the user’s account balance is confirmed, they will generate a specific HASH value. This hash value must have a specific format; it must start with a certain number of zeros.
There are two inputs for calculating this HASH value:
Considering that even the smallest change in input data must produce a significant difference in output HASH value, miners have a very difficult task. They need to find a specific value for a proof-of-work variable that will produce a HASH beginning with zeros.
If the system requires a minimum of 40 zeros in each validated transaction, the miner will need to calculate approximately two to 40 different HASH values in order to find the right proof-of-work.
Once a miner finds the proper value for proof-of-work, he or she is entitled to a transaction fee which can be added as part of the validated transaction. Every validated transaction is transmitted to peers in the network and stored in a specific database format known as the blockchain.
But what happens if the number of miners increases, and their hardware becomes much more efficient? Bitcoin used to be mined on CPUs, then GPUs and FPGAs, but ultimately miners started designing their own ASIC chips, which were vastly more powerful than these early solutions. As the hash rate goes up, so does the mining difficulty, thus ensuring equilibrium. When more hashing power is introduced into the network, the difficulty goes up and vice versa; if many miners decide to pull the plug because their operation is no longer profitable, difficulty is readjusted to match the new hash rate.
Blockchain: the global crypocurrency ledger
The blockchain contains the history of all transactions performed in the system. Every validated transaction, or batch of transactions, becomes another ring in the chain.
So, the bitcoin blockchain is, essentially, a public ledger where transactions are listed in a chronological order.
The first ring in the bitcoin blockchain is called the Genesis Block.
To read more about how the blockchain works, I suggest reading “Blockchain Technology Explained: Powering Bitcoin” by Nermin Hajdarbegovic.
There is no limit to how many miners may be active in a virtual currency system. This means that it is possible for two or more miners to validate the same transaction. If this happens, the system will check the total effort each miner invested in validating the transaction by simply counting zeros. The miner that invested more effort (found more leading zeros) will prevail and his or her block will be accepted.
Controlling the money supply
The first rule of the bitcoin system is that there can be a maximum of 21 million bitcoins generated. This number has still not been achieved, and according to current trends, it is thought that this number will be reached by the year 2140.
This may cause you to question the usefulness of such a system, because 21 million units doesn’t sound like much. However, the bitcoin system supports fractional values down to the eighth decimal (0.00000001). This smallest unit of a bitcoin is called a Satoshi, in honor of Satoshi Nakamoto, the anonymous developer behind the bitcoin protocol.
New coins are created as a reward to miners for validating transactions. This reward is not the transaction fee that you specified when you created a transaction record, but it is defined by the system. The reward amount decreases over time and eventually will be set to zero once the total number of coins issued (21 million) has been reached. When this happens, transaction fees will play a much more important role since miners might choose to prioritize more valuable transactions for validation.
Apart from setting the upper limit in maximum number of coins, the bitcoin system also uses an interesting way to limit daily production of new coins. By calibrating the minimum number of leading zeros required for a proof-of-work calculation, the time required to validate the transaction, and get a reward of new coins, is always set to approximately 10 minutes. If the time between adding new blocks to the blockchain decreases, the system might require that proof-of-work generates 45 or 50 leading zeros.
So, by limiting how fast and how many new coins can be generated, the bitcoin system is effectively controlling the money supply.
Start ‘printing’ currency
As you can see, making your own version of bitcoin is not that difficult. By utilizing existing technology, implemented in an innovative way, you have everything you need for a cryptocurrency.
One last thing worth mentioning is that, in its essence, virtual currency is a way to transfer anonymous value/information from one user to another in a distributed peer-to-peer network.
Consider replacing coins in your transaction record with random data that might even be encrypted using asynchronous cryptography so only the sender and receiver can decipher it. Now think about applying that to something like the Internet Of Things!
A number of tech heavyweights are already exploring the use of blockchain technology in IoT platforms, but that’s not the only potential application of this relatively new technology.
If you see no reason to create an alternative currency of your own (other than a practical joke), you could try to use the same or similar approach for something else, such as distributed authentication, creation of virtual currencies used in games, social networks and other applications, or you could proceed to create a new loyalty program for your e-commerce business, which would reward regular customers with virtual tokens that could be redeemed later on.