Hola guys! Last week’s article was about consensus in blockchains. This article is purely intended on breaking down the mythological problems such as Double spending and Anti Money Laundering in blockchains. Also, this article provides limited information on Ethereum and truffle, a popular framework that can be used as a development environment for Decentralized Applications (D-apps).
Double Spending problem
I am pretty sure you would have heard about this term if you are surfing about blockchains or you are associated to the Fin-Tech industry in some manner. In the context of digital cash, double spending refers to the flaw of spending the digital cash (a virtual token usually) for more than once. In simple terms, it is the scenario of buying two different commodities using the same virtual money. This not only is a fraudulent of just duplicating the money but it also helps in laundering the unaccounted money (black money) as there is a duplication of the resource ultimately leading to the process of anti-money laundering that is later addressed in this issue.
In a centralized accounting ledger, a third party is usually involved to check whether the virtual token is actually spent. In a decentralized system, it is actually difficult to solve the double spending problem. Since blockchains have a consensus algorithms such as PoW and PoS they ensure the harmony in a decentralized ledger. Assume a user trying to spend the virtual money twice, it would automatically account for two different transactions referring to the same hash with slightly different timestamps. When the miners or stakeholders try to verify or validate the transaction it is the actual point where the fraudulent is identified and the transaction with lowest affirmation is marked obsolete.
Anti Money Laundering
Anti Money Laundering popularly known as AML is an extension to the Double Spending problem. As the Double spending problem induces the legalized accounting of virtual cash for more than one time, they can launder the unaccounted money into white cash (accounted money). For example, X holds accounted money of 10 bitcoins and unaccounted money of 10 bitcoins. If X spends the same 10 bitcoins for buying two commodities priced at 10 bitcoins, then the unaccounted money that X had also can be plunged into X’s account and therefore the unaccounted money can be laundered illegally. This money laundering can happen as simple as in the aforementioned scenario, or can also happen at multiple levels of transactions (a complex scenario) where the common motive is to hide the origins of the virtual money. Since blockchains consensus algorithm directly eliminates the double spend problem it also inherently checks for the Anti Money laundering if it happens as explained in the simple scenario. AML makes up to 2 to 5% of the global GDP - $2 trillion. Also, AI powered blockchain solutions can help in diagnosing the pattern among those fraudulent transactions and it can prevent a very complex scenario for laundering the unaccounted money.
Ethereum is Open Source permission-less decentralized ledger project by the ethereum foundation. Solidity is the programming language for Ethereum. Ethereum can be used to build blockchain powered D-apps with any compatible UI frameworks or libraries (React, Angular etc.,) so it looks like a web app but with decentralized ledger as a database instead of the conventional databases. One good example for Ethereum based wallet in google chrome is Metamask that is available as a simple chrome extension. This wallet facilitates the transaction between the payer and the payee. But for the transaction to happen, it consumes a certain amount of gas or fuel called the Ether. One can interpret this ether as the virtual coin in a bitcoin environment. The metamask wallet facilitates the connection with different remote and even local URL’s too that can be utilized for the development of smart contracts over Ethereum.
Truffle is a Ethereum based framework meaning that D-apps with Ethereum back-end can be developed, tested and pipelined using this framework. Solidity programming can be used to write smart contracts in this framework. Ganache is a tool that provides a personalized blockchain environment, meaning that it provides private keys and 100 ethers balance associated with each private key account. It associates each account with a unique address, index and a private key.
This Ganache workspace provides a list of blocks that can be connected with the aforementioned Metamask wallet through the localhost ports(usually 8545 port for development purposes). I will illustrate the detailed procedure on the next issue. The smart contracts that are written in the Solidity (.sol files) can be deployed through the truffle framework in the same development port along with the appropriate front end. The truffle frameworks provides a unique console to interact with the smart contracts and a testing environment with which the developer can perform a smoke test on the smart contracts. Additionally Truffle comes with a collection of front-end libraries called the drizzle that makes the front-end of the D-apps easier and readable. In the next article, step-by-step development of a D-app will be illustrated with all the aforementioned frameworks and tools.