Digital Currency What Is Digital Currency?

By Jake Frankenfield Reviewed by Somer Anderson Updated Mar 23, 2021 Digital currency is a form of currency that is available only in digital or electronic form, and not in physical form. It is also called digital money, electronic money, electronic currency, or cyber cash. Key Takeaways

• Digital currencies are currencies that are only accessible with computers or mobile phones, as they only exist in electronic form. • Since digital currencies require no intermediary, they are often the cheapest method to trade currencies. • All cryptocurrencies are digital currencies, but not all digital currencies are crypto. • Digital currencies are stable and are traded with the markets, whereas cryptocurrencies are traded via consumer sentiment and psychological triggers in price movement.

Understanding Digital Currency

Digital currencies are intangible and can only be owned and transacted in by using computers or electronic wallets connected to the Internet or the designated networks. In contrast, physical currencies, like banknotes and minted coins, are tangible and transactions are possible only by their holders who have their physical ownership. Like any standard fiat currency, digital currencies can be used to purchase goods as well as to pay for services, though they can also find restricted use among certain online communities, like gaming sites, gambling portals, or social networks. Digital currencies have all intrinsic properties like physical currency, and they allow for instantaneous transactions that can be seamlessly executed for making payments across borders when connected to supported devices and networks. For instance, it is possible for an American to make payments in digital currency to a distant counterparty residing in Singapore, provided that they both are connected to the same network required for transacting in the digital currency. Digital currencies offer numerous advantages. As payments in digital currencies are made directly between the transacting parties without the need of any intermediaries, the transactions are usually instantaneous and low-cost. This fares better compared to traditional payment methods that involve banks or clearing houses. Digital currency-based electronic transactions also bring in the necessary record keeping and transparency in dealings. Difference between Digital, Virtual, and Crypto Currencies Since they exist in a lot of variants, digital currencies can be considered a superset of virtual currencies and cryptocurrencies. If issued by a central bank of a country in a regulated form, it is called the “Central Bank Digital Currency (CBDC).” While the CBDC only exists in conceptual form, England, Sweden, and Uruguay are a few of the nations that have considered plans to launch a digital version of their native fiat currencies. NEW DIGITAL ECOLOGIC CURRENCY ACCORDING TO CBDC STANDARDS Along with the regulated CBDC, a digital currency can also exist in an unregulated form. In the latter case, it qualifies for being called a virtual currency and may be under the control of the currency developer(s), the founding organization, or the defined network protocol, instead of being controlled by a centralized regulator. Examples of such virtual currencies include cryptocurrencies, and coupon- or rewards-linked monetary systems. Since cryptocurrencies are unregulated, they are also considered to be virtual currencies. A cryptocurrency is another form of digital currency which uses cryptography to secure and verify transactions and to manage and control the creation of new currency units. Bitcoin and ethereum are the most popular cryptocurrencies. Essentially, both virtual currencies and cryptocurrencies are considered forms of digital currencies. Digital Currencies Virtual Currencies Cryptocurrencies Regulated or unregulated currency that is available only in a digital or electronic form. An unregulated digital currency that is controlled by its developer(s), the founding organization, or the defined network protocol. A virtual currency that uses cryptography to secure and verify transactions as well as to manage and control the creation of new currency units. What Is Convertible Virtual Currency? Convertible virtual currency is an unregulated digital currency that can be used as a substitute for real and legally recognized currency even though it does not have the status of legal tender. Convertible digital currencies are easily exchanged for fiat currencies such as dollars via cryptocurrency exchanges. This can be contrasted with non-convertible virtual currencies that are not used in external commerce or directly exchangeable for other currencies, such as virtual currency contained within a video game environment. Key Takeaways • Convertible virtual currency is a cryptocurrency that can be traded for fiat currencies on exchanges, or which are used directly for legitimate forms of commerce and payments. • These currencies are mainly different from state-backed currencies like the dollar or the euro in that they have no physical presence and are not issued by a government. Rather they run on decentralized blockchain networks. • Bitcoin, Ether, and Ripple are examples of convertible virtual currencies. How Convertible Virtual Currency Works

Convertible virtual currency is an example of how technological advances are driving disrupting changes in the traditional way of doing things across the globe. This is especially true of the way goods and services are paid for and acquired. Definitions of Convertable Virtual Currency Virtual currency is defined by the Financial Crimes Enforcement Network (a bureau of the U.S. Treasury) as "a medium of exchange that operates like a currency in some environments, but does not have all the attributes of real currency."1 Convertible virtual currency usually has a measurable value in real money, but what makes it convertible lies in its ability to be exchangeable. Not all virtual currency can be exchanged for legal tender; therefore, not all virtual currency is convertible. The Internal Revenue Service of the U.S. government defines a convertible virtual currency as a virtual currency that has a value in real currency.2 That means for the IRS, "Bitcoin, Ether, Roblox, and V-bucks are a few examples of a convertible virtual currency. Virtual currencies can be digitally traded between users and can be purchased for, or exchanged into, U.S. dollars, Euros, and other real or virtual currencies." Another feature of convertible virtual currencies that make them similar to state-backed currencies is their tax liability, at least in the U.S.: "The sale or other exchange of virtual currencies, or the use of virtual currencies to pay for goods or services, or holding virtual currencies as an investment, generally has tax consequences."2 Popular Convertable Virtual Currencies The most popular form of virtual currency remains Bitcoin. Bitcoin runs on a decentralized peer-to-peer network that employs blockchain technology to prevent fraud and control the money supply. By way of contrast, the central banks and treasuries of states (like the United States) control the money supply by printing money and taking it out of circulation, raising and lowering interest rates on borrowing, and prosecuting counterfeiters. Bitcoin is a convertible virtual currency because it can be exchanged for real money based on its determinable value in the market. The value of a Bitcoin in dollars has been exchanged from as low as $13 sometime in 2012 to more than $40,000 in December 2020.3 Other popular virtual currencies are Ether, Zcash, Monero, Dash, Ripple, and Litecoin. What is Blockchain? Blockchain seems complicated, and it definitely can be, but its core concept is really quite simple. A blockchain is a type of database. To be able to understand blockchain, it helps to first understand what a database actually is. A database is a collection of information that is stored electronically on a computer system. Information, or data, in databases is typically structured in table format to allow for easier searching and filtering for specific information. What is the difference between someone using a spreadsheet to store information rather than a database? Spreadsheets are designed for one person, or a small group of people, to store and access limited amounts of information. In contrast, a database is designed to house significantly larger amounts of information that can be accessed, filtered, and manipulated quickly and easily by any number of users at once. Large databases achieve this by housing data on servers that are made of powerful computers. These servers can sometimes be built using hundreds or thousands of computers in order to have the computational power and storage capacity necessary for many users to access the database simultaneously. While a spreadsheet or database may be accessible to any number of people, it is often owned by a business and managed by an appointed individual that has complete control over how it works and the data within it.

So how does a blockchain differ from a database? Storage Structure

One key difference between a typical database and a blockchain is the way the data is structured. A blockchain collects information together in groups, also known as blocks, that hold sets of information. Blocks have certain storage capacities and, when filled, are chained onto the previously filled block, forming a chain of data known as the “blockchain.” All new information that follows that freshly added block is compiled into a newly formed block that will then also be added to the chain once filled. A database structures its data into tables whereas a blockchain, like its name implies, structures its data into chunks (blocks) that are chained together. This makes it so that all blockchains are databases but not all databases are blockchains. This system also inherently makes an irreversible timeline of data when implemented in a decentralized nature. When a block is filled it is set in stone and becomes a part of this timeline. Each block in the chain is given an exact timestamp when it is added to the chain.

The Legal Status of Convertible Virtual Currencies The nature of convertible virtual currencies makes them susceptible to use as vehicles for money laundering, tax evasion, and terrorist financing. This has led to some countries proposing regulatory measures on how the currencies will be observed and used for tax purposes. In the US, FinCen guidelines rule that virtual currency that can be exchanged for legally recognized money is property, not money, and will be treated as such. Tax principles that apply to property transactions, therefore, apply to these types of currencies. A taxpayer who receives Bitcoin or Linden dollars in exchange for goods and services has to record the fair value of the virtual currency in US dollars as of the date it was received. This value is included in computing the taxpayer’s annual gross income. In addition, a virtual currency used for investing is regarded as a capital asset and is thus subject to tax on its capital gains or losses. The blockchain is an undeniably ingenious invention – the brainchild of a person or group of people known by the pseudonym, Satoshi Nakamoto. But since then, it has evolved into something greater, and the main question every single person is asking is: What is Blockchain? Is Blockchain Technology the New Internet? By allowing digital information to be distributed but not copied, blockchain technology created the backbone of a new type of internet. Originally devised for the digital currency, Bitcoin blockchain, (Buy Bitcoin) the tech community has now found other potential uses for the technology. In this guide, we are going to explain to you what the blockchain technology is, and what its properties are what make it so unique. So, we hope you enjoy this, What Is Blockchain Guide. And if you already know what blockchain is and want to become a blockchain developer please check out our in-depth blockchain tutorial and create your very first blockchain.

A blockchain is, in the simplest of terms, a time-stamped series of immutable records of data that is managed by a cluster of computers not owned by any single entity. Each of these blocks of data (i.e. block) is secured and bound to each other using cryptographic principles (i.e. chain). So, what is so special about it and why are we saying that it has industry-disrupting capabilities? The blockchain network has no central authority — it is the very definition of a democratized system. Since it is a shared and immutable ledger, the information in it is open for anyone and everyone to see. Hence, anything that is built on the blockchain is by its very nature transparent and everyone involved is accountable for their actions. What exactly is Blockchain? A blockchain carries no transaction cost. (An infrastructure cost yes, but no transaction cost.) The blockchain is a simple yet ingenious way of passing information from A to B in a fully automated and safe manner. One party to a transaction initiates the process by creating a block. This block is verified by thousands, perhaps millions of computers distributed around the net. The verified block is added to a chain, which is stored across the net, creating not just a unique record, but a unique record with a unique history. Falsifying a single record would mean falsifying the entire chain in millions of instances. That is virtually impossible. Bitcoin uses this model for monetary transactions, but it can be deployed in many other ways.

Think of a railway company. We buy tickets on an app or the web. The credit card company takes a cut for processing the transaction. Blockchains, not only can the railway operator save on credit card processing fees, it can move the entire ticketing process to the blockchain. The two parties in the transaction are the railway company and the passenger. The ticket is a block, which will be added to a ticket blockchain. Just as a monetary transaction on the blockchain is a unique, independently verifiable and unfalsifiable record (like Bitcoin), so can your ticket be. Incidentally, the final ticket blockchain is also a record of all transactions for, say, a certain train route, or even the entire train network, comprising every ticket ever sold, every journey ever taken. In the financial world the applications are more obvious and the revolutionary changes more imminent. Blockchains will change the way stock exchanges work, loans are bundled, and insurances contracted. They will eliminate bank accounts and practically all services offered by banks. Almost every financial institution will go bankrupt or be forced to change fundamentally, once the advantages of a safe ledger technology without transaction fees are widely understood and implemented. After all, the financial system is built on taking a small cut of your money for the privilege of facilitating a transaction. Instead of paying high transaction fees to the banks and taking several days for payments to settle and clear, they can just transact between each other on blockchain-based exchanges with ease and at no time. Bankers will become mere advisers, not gatekeepers of money. Stockbrokers will no longer be able to earn commissions and the buy/sell spread will disappear. How Does a Blockchain Work? The reason why the blockchain has gained so much admiration is that: • It is not owned by a single entity, hence it is decentralized • The data is cryptographically stored inside • The blockchain is immutable, so no one can tamper with the data that is inside the blockchain • The blockchain is transparent so one can track the data if they want to The Three Pillars of Blockchain Technology The three main properties of Blockchain Technology which have helped it gain widespread acclaim are as follows: • Decentralization • Transparency • Immutability

Pillar #1: Decentralization Before Bitcoin and BitTorrent came along, we were more used to centralized services. The idea is very simple. You have a centralized entity that stored all the data and you’d have to interact solely with this entity to get whatever information you required. Another example of a centralized system is the banks. They store all your money, and the only way that you can pay someone is by going through the bank. The traditional client-server model is a perfect example of this:

When you google search for something, you send a query to the server who then gets back at you with the relevant information. That is a simple client-server. Now, centralized systems have treated us well for many years, however, they have several vulnerabilities. • Firstly, because they are centralized, all the data is stored in one spot. This makes them easy target spots for potential hackers. • If the centralized system were to go through a software upgrade, it would halt the entire system • What if the centralized entity somehow shuts down for whatever reason? That way nobody will be able to access the information that it possesses • Worst case scenario, what if this entity gets corrupted and malicious? If that happens then all the data that is inside the blockchain will be compromised. So, what happens if we just take this centralized entity away? In a decentralized system, the information is not stored by one single entity. In fact, everyone in the network owns the information. In a decentralized network, if you wanted to interact with your friend then you can do so directly without going through a third party. That was the main ideology behind Bitcoins. You and only you alone are in charge of your money. You can send your money to anyone you want without having to go through a bank.

Pillar #2: Transparency One of the most interesting and misunderstood concepts in blockchain is “transparency.” Some people say that blockchain gives you privacy while some say that it is transparent. Why do you think that happens? Well… a person’s identity is hidden via complex cryptography and represented only by their public address. So, if you were to look up a person’s transaction history, you will not see “Bob sent 1 BTC” instead you will see “1MF1bhsFLkBzzz9vpFYEmvwT2TbyCt7NZJ sent 1 BTC”. The following snapshot of Ethereum transactions will show you what we mean:

So, while the person’s real identity is secure, you will still see all the transactions that were done by their public address. This level of transparency has never existed before within a financial system. It adds that extra, and much needed, level of accountability which is required by some of these biggest institutions. Speaking purely from the point of view of cryptocurrency, if you know the public address of one of these big companies, you can simply pop it in an explorer and look at all the transactions that they have engaged in. This forces them to be honest, something that they have never had to deal with before. However, that’s not the best use-case. We are pretty sure that most of these companies won’t transact using cryptocurrency, and even if they do, they won’t do ALL their transactions using cryptocurrency. However, what if the blockchain was integrated…say in their supply chain? You can see why something like this can be very helpful for the finance industry right? Pillar #3: Immutability Immutability, in the context of the blockchain, means that once something has been entered into the blockchain, it cannot be tampered with. Can you imagine how valuable this will be for financial institutes? Imagine how many embezzlement cases can be nipped in the bud if people know that they can’t “work the books” and fiddle around with company accounts. The reason why the blockchain gets this property is that of the cryptographic hash function. In simple terms, hashing means taking an input string of any length and giving out an output of a fixed length. In the context of cryptocurrencies like bitcoin, the transactions are taken as input and run through a hashing algorithm (Bitcoin uses SHA-256) which gives an output of a fixed length. Let’s see how the hashing process works. We are going to put in certain inputs. For this exercise, we are going to use the SHA-256 (Secure Hashing Algorithm 256).

As you can see, in the case of SHA-256, no matter how big or small your input is, the output will always have a fixed 256-bits length. This becomes critical when you are dealing with a huge amount of data and transactions. So basically, instead of remembering the input data which could be huge, you can just remember the hash and keep track. A cryptographic hash function is a special class of hash functions that has various properties making it ideal for cryptography. There are certain properties that a cryptographic hash function needs to have in order to be considered secure. You can read about those in detail in our guide on hashing. There is just one property that we want you to focus on today. It is called the “Avalanche Effect.” What does that mean? Even if you make a small change in your input, the changes that will be reflected in the hash will be huge. Let’s test it out using SHA-256:

Do you see that? Even though you just changed the case of the first alphabet of the input, look at how much that has affected the output hash. Now, let’s go back to our previous point when we were looking at blockchain architecture. What we said was: The blockchain is a linked list that contains data and a hash pointer that points to its previous block, hence creating the chain. What is a hash pointer? A hash pointer is similar to a pointer, but instead of just containing the address of the previous block it also contains the hash of the data inside the previous block. This one small tweak is what makes blockchains so amazingly reliable and trailblazing. Imagine this for a second, a hacker attacks block 3 and tries to change the data. Because of the properties of hash functions, a slight change in data will change the hash drastically. This means that any slight changes made in block 3, will change the hash which is stored in block 2, now that in turn will change the data and the hash of block 2 which will result in changes in block 1 and so on and so forth. This will completely change the chain, which is impossible. This is exactly how blockchains attain immutability. Maintaining the Blockchain – Network, and Nodes The blockchain is maintained by a peer-to-peer network. The network is a collection of nodes that are interconnected to one another. Nodes are individual computers that take in input and performs a function on them and gives an output. The blockchain uses a special kind of network called “peer-to-peer network” which partitions its entire workload between participants, who are all equally privileged, called “peers”. There is no longer one central server, now there are several distributed and decentralized peers. Why do people use the peer-to-peer network? One of the main uses of the peer-to-peer network is file sharing, also called torrenting. If you are to use a client-server model for downloading, then it is usually extremely slow and entirely dependent on the health of the server. Plus, as we said, it is prone to censorship. However, in a peer-to-peer system, there is no central authority, and hence if even one of the peers in the network goes out of the race, you still have more peers to download from. Plus, it is not subject to the idealistic standards of a central system, hence it is not prone to censorship. If we were to compare the two:

The decentralized nature of a peer-to-peer system becomes critical as we move on to the next section. How critical? Well, the simple (at least on paper) idea of combining this peer-to-peer network with a payment system has completely revolutionized the finance industry by giving birth to cryptocurrency. The use of networks and nodes in cryptocurrencies. The peer-to-peer network structure in cryptocurrency is structured according to the consensus mechanism that they are utilizing. For cryptocurrency like Bitcoin and Ethereum which uses a normal proof-of-work consensus mechanism (Ethereum will eventually move on to Proof of Stake), all the nodes have the same privilege. The idea is to create an egalitarian network. The nodes are not given any special privileges, however, their functions and degree of participation may differ. There is no centralized server/entity, nor is there any hierarchy. It is a flat topology. These decentralized cryptocurrencies are structured like that is because of a simple reason, to stay true to their philosophy. The idea is to have a currency system, where everyone is treated as an equal and there is no governing body, which can determine the value of the currency based on a whim. This is true for both bitcoin and Ethereum. Now, if there is no central system, how would everyone in the system get to know that a certain transaction has happened? The network follows the gossip protocol. Think of how gossip spreads. Suppose Alice sent 3 ETH to Bob. The nodes nearest to her will get to know of this, and then they will tell the nodes closest to them, and then they will tell their neighbors, and this will keep on spreading out until everyone knows. Nodes are basically your nosy, annoying relatives. So, what is a node in the context of Ethereum? A node is simply a computer that participates in the Ethereum network. This participation can be in three ways: • By keeping a shallow-copy of the blockchain aka a Light Client • By keeping a full copy of the blockchain aka a Full Node • By verifying the transactions aka Mining However, the problem with this design is that it is not really that scalable. Which is why a lot of new generation cryptocurrencies adopt a leader-based consensus mechanism. In EOS, Cardano, Neo, etc. the nodes elect leader nodes or “supernodes” who are in charge of the consensus and overall network health. These cryptos are a lot faster but they are not the most decentralized of systems. So, in a way, cryptos have to make the trade-off between speed and decentralization. Transactions online are closely connected to the processes of identity verification. It is easy to imagine that wallet apps will transform in the coming years to include other types of identity management. Blockchain and Mainstream Adoption The impact of blockchain technology is genuinely far-reaching and has far more use-cases than being a facilitator for transactions. Several industries have discovered the benefits of blockchain integration. While Bitcoin and Ethereum are examples of public blockchains, most of these industries require specific functionalities out of their distributed ledger architecture. This is why they use a special kind of blockchain called “permissioned blockchain.” What is a Permissioned Blockchain? So, what’s the difference between a public and a permissioned blockchain? Public blockchains are open protocols. Anyone can join the network and participate in the protocol and take care of the overall network consensus. Plus, the data stored in the blockchain is pretty much open for all to see since everything is public. While transparency is a very desirable trait, the fact remains that enterprises don’t want to use a network wherein any average Joe can peek into their daily dealings and be a party to some confidential information. As such, enterprises prefer using a unique form of blockchain called “permissioned” chains, limiting the number of nodes entering the network. Permissioned chains can also be differentiated into public permissioned and private permissioned blockchains. Public Permissioned Blockchain In a public permissioned system, anyone can join the network, but just a select few can take care of the consensus and overall networks. Let’s take a real-life example to understand how this system works. Anybody can access a public ATM and use it. You don’t need to have any special privileges to use it (save for an ATM card). But, not everyone can open up the machine and add new functionalities and cash. Only the bank that owns the machine has the right to do so. Blockchains like stellar, ripple, EOS, sovrin, etc. are examples of public and permissioned blockchains. In EOS, anybody can join the network. However, to take part in the consensus, you will need to be elected as one of the 21 block producers and lock up some stake in the ecosystem. Private Permissioned Blockchain A private permissioned blockchain is one where members need to gain permission to enter the system and only a chosen few nodes are allowed to make administrative decisions. Think of a university. Not everyone can enter this university. Aspirants first need to pass an entrance exam. Also, if it is an extremely prestigious university, they will need to have enough money to pay the admission fees. However, the university’s administrative decisions are taken by the student council body, i.e., students elected/selected to take care of these roles. Not every student gets to handle the administrative side. Many companies have created consortiums using protocols like Hyperledger Fabric, which are private permissioned blockchains.

#1 Smart contracts

Distributed ledger technology enable the coding of simple contracts that will execute when specified conditions are met. Ethereum is an open-source blockchain project that was built specifically to realize this possibility. Still, in its early stages, Ethereum has the potential to leverage the usefulness of blockchains on a truly world-changing scale. At the technology’s current level of development, smart contracts can be programmed to perform simple functions. For instance, a derivative could be paid out when a financial instrument meets a certain benchmark, with the use of blockchain technology and Bitcoin enabling the payout to be automated. With Etherum being the biggest smart contract network, some top cryptocurrency exchanges like OKEx are also deploying their decentralized smart contract networks like OKEx Chain, where users can launch their decentralized applications, create token trading pairs and trade freely with no time and place restricted. #11 Identity management There is a definite need for better identity management on the web. The ability to verify your identity is the lynchpin of financial transactions that happen online. However, remedies for the security risks that come with web commerce are imperfect at best. Distributed ledgers offer enhanced methods for proving who you are, along with the possibility to digitize personal documents. Having a secure identity will also be important for online interactions — for instance, in the sharing economy. A good reputation, after all, is the most important condition for conducting transactions online. Developing digital identity standards is proving to be a highly complex process. Technical challenges aside, a universal online identity solution requires cooperation between private entities and the government. Add to that the need to navigate legal systems in different countries and the problem becomes exponentially difficult. An E-Commerce on the internet currently relies on the SSL certificate (the little green lock) for secure transactions on the web. Netki is a startup that aspires to create an SSL standard for the blockchain. Having recently announced a $3.5 million seed round, Netki expects a product launch in early 2017. #12 AML and KYC Anti-money laundering (AML) and know your customer (KYC) practices have a strong potential for being adapted to the blockchain. Currently, financial institutions must perform a labor-intensive multi-step process for each new customer. KYC costs could be reduced through cross-institution client verification and at the same time increase monitoring and analysis effectiveness. Startup Polycoin has an AML/KYC solution that involves analyzing transactions. Those transactions identified as being suspicious are forwarded on to compliance officers. Another startup, Tradle is developing an application called Trust in Motion (TiM). Characterized as an “Instagram for KYC”, TiM allows customers to take a snapshot of key documents (passport, utility bill, etc.). Once verified by the bank, this data is cryptographically stored on the blockchain.

What is a blockchain and how exactly does it work…code-wise? A blockchain is basically a chain of blocks which contain data. It is basically a glorified linked list. However, what makes it so special? A blockchain is immutable. Meaning, once a data goes inside a block, it can never be changed. How does a blockchain attain immutability? It is because of a simple but ingenious mechanism called “hashing”. Check out the diagram below:

Image Courtesy: Lauri Hartikka medium article Each block is connected to the previous block via a hash pointer which contains the hash of the previous block. So, how does this make the chain immutable? One of the most fascinating properties of cryptographic hash functions is that if you even change the input by a little bit, it can greatly affect the output hash. Eg. Check this out:

Just changing the first “T” from upper to lower case drastically changed the output hash so much. So, how does this affect the blockchain? Each block is connected to the previous one via the hash pointer. So, if someone were to tamper the data in a block, it would change the hash drastically and as a result, end up affecting the whole chain (as all the blocks are linked). This would freeze up the chain which is an impossibility and hence the blocks remain unchanged. So, how do we make a block? What does a simple block consist of? In our simple cryptocoin that we are going to make (Let’s call it “BlockGeeksCoin”), each block will have the following pieces of information: • Index: To know the block number. • Timestamp: To know the time of creation. • Data: The data inside the block. • Previous Hash: The hash of the previous block. • Hash: The Hash of the current block. Before we continue. You need to understand certain terms that we are going to use in our program: • this: The “this” keyword is invoked inside a function and enables you to access the values inside a specific object that calls that particular function. • Constructor: A constructor is a special function which can help create and initialize an object within a class. Each class is restricted to only one constructor. Now that that’s done, let’s start making our block. Creating the Block const SHA256 = require("crypto-js/sha256"); class Block { constructor(index, timestamp, data, previousHash = '') { this.index = index; this.previousHash = previousHash; this.timestamp = timestamp; this.data = data; this.hash = this.calculateHash(); } calculateHash() { return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString(); } } Code Analysis Ok, so this right here is out block. So, in the first line of the code we called the crypto-js library because the sha256 hash function is not available in JavaScript. Next, we invoked a constructor inside the class to call for objects which will have certain values. The thing that probably catches your eye is the calculateHash() function. Let’s see what exactly is it doing. In a block, we take all the contents and hash them to get the hash of that particular block. We are using the JSON.stringify function to turn the data of the block into string to hash it. Ok, so we have the block ready and good to go. Now let’s connect the blocks together into a blockchain. Now that we have built the genesis block, let’s build the rest of the chain. Section 2: Adding The Blocks Firstly, we will need to know what the last block in the blockchain currently is. For that we use the getLatestBlock() function. getLatestBlock() { return this.chain[this.chain.length - 1]; } Now that we have determined the latest block, let’s see how we are going to add new blocks. addBlock(newBlock) { newBlock.previousHash = this.getLatestBlock().hash; newBlock.hash = newBlock.calculateHash(); this.chain.push(newBlock); } So, what is happening here? How are we adding the blocks? How are we checking if the given block is valid or not? Remember the contents of a block? A block has the hash of the previous block right? So, what we are going to do here is simple. Compare the previousHash value of the new block with the hash value of the latest block. Image Courtesy: Lauri Hartikka medium article If these two values match, then this means that the new block is legit and it gets added to the blockchain. Section 3: Validating the Chain Now, we need to check that nobody has been messing with our blockchain and that everything is stable. We are using the “for” loop to go from block 1 to the last block. Genesis block is block 0. for (let i = 1; i < this.chain.length; i++) { const currentBlock = this.chain[i]; const previousBlock = this.chain[i - 1]; In this part of the code we are defining two terms, current block and previous block. And now we are simply going to find the hash of these two values. if (currentBlock.hash !== currentBlock.calculateHash()) { return false; } if (currentBlock.previousHash !== previousBlock.hash) { return false; } } return true; } If the “previousHash” of the current block is not equal to the “Hash” of the previous block, then this function will return False, else it will return True. Using the blockchain Now, we are going to finally use the blockchain to create our BlockGeeksCoin. • let BlockGeeksCoin = new Blockchain(); • BlockGeeksCoin.addBlock(new Block(1, “20/07/2017”, { amount: 4 })); • BlockGeeksCoin.addBlock(new Block(2, “20/07/2017”, { amount: 8 })); And that’s it! So what happened here? We created a new cryptocurrency based on the blockchain and named it BlockGeeksCoin. By invoking this new object, I activated the constructor, which in turn created the Genesis block automatically. We simply added two more blocks to it and gave them some data. It is that simple. (Thank you savjee.be for the amazing and simple explanation.) Blockchain Coding: Conclusion In this article, we have only covered 4 languages for blockchain coding that are used in developing in and around the blockchain. In reality, there are many many more languages that you can potentially use (Java, Go). If you are a programmer, then the possibilities for you are truly endless. As the world becomes more and more decentralized and blockchain becomes more and more mainstream, the future for you is definitely limitless.