How to send Bitcoin/Money
Assuming that you have implemented P2P communication, mechanisms for creating digital identities (private and public keys), and provided ways for users to sign documents using their private keys, you are ready to start sending information to your peers.
Since we do not have a central authority that will validate how much money you have, the system will have to ask you about it every time, and then check if you lied or not. So, your transaction record might contain the following information:
- I have 100 Topcoins
- I want to send 10 coins to my pharmacist for the medication (you would include your pharmacists public key here)
- I want to give one coin as transaction fee to the system (we will come back to this later)
- I want to keep the remaining 89 coins
The only thing left to do is digitally sign the transaction record with your private key and transmit the transaction record to your peers in the network. At that point, everyone will receive the information that someone (your virtual identity) is sending money to someone else (your pharmacist’s virtual identity).
Your job is done. However, your medication will not be paid for until the whole network agrees that you really did have 100 coins, and therefore could execute this transaction. Only after your transaction is validated will your pharmacist get the funds and send you the medication.
Miners – New Breed of Agents
Miners are known to be very hard working people who are, in my opinion, heavily underpaid. In the digital world of cryptocurrency, miners play a very similar role, except in this case, they do the computationally-intensive work instead of digging piles of dirt. Unlike real miners, some cryptocurrency miners earned a small fortune over the past five years, but many others lost a fortune on this risky endeavour.
Miners are the core component of the system and their main purpose is to confirm the validity of each and every transaction requested by users.
In order to confirm the validity of your 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 your transactions to verify that you actually had 100 coins to begin with. Once your account balance is confirmed, they will generate a specific HASH value. This hash value must have a specific format; it must start with certain number of zeros.
There are two inputs for calculating this HASH value:
- Transaction record data
- Miner’s proof-of-work
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 your system requires a minimum of 40 zeros in each validated transaction, the miner will need to calculate approximately 2^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 (the single coin you were willing to pay), 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 goes up, 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 Cryptocurrency 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 your 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,000,000 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, Bitcoin system supports fractional values down to the eight 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 (21m) 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” Your Own 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.
- All transaction are made over the Internet using P2P communication, thus removing the need for a central authority
- Users can perform anonymous transactions by utilizing asynchronous cryptography and they are identified only by their private key/public key combination
- You have implemented a validated global ledger of all transactions that has been safely copied to every peer in the network
- You have a secured, automated, and controlled money supply, which assures the stability of your currency without the need of central authority
One last thing worth mentioning is that, in its essence, cryptocurrency 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 cryptocurrency system might be an interesting way to enable communication between our stove and toaster.
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.