What are the basics of Developing a Blockchain Applications (DAPPs)?



          The BlockChain is fully distributed peer to peer software network which makes use of cryptography to securely host applications data and easily transfer digital instruments of value that represents the real world money. Cryptography is an art of communication via coded messages. The Bitcoin and Ethereum are used to conjure one secure computing environment of thousands of similar machines running with no single authority and no single user. The term Ethereum refers to 3 different things. Those are,
1. The Ethereum Protocol
2. The Ethereum Network
3. Creating Decentralized Applications

Decentralized Applications:
DAPP is an application that runs on the blockchain. The blockchain enables apps to run without having a central location like web URL. Whenever we go to a web URL  or mobile app, it is going to interact with core functionality at a central point. All of the functionality will reside on servers or virtual servers and all of the data will be stored within that environment. Because of the centralized location, it is vulnerable to a distributed denial of service attack.  Every time you use centralized location, you're surrendering trust, paying fees, and giving up the data to whoever is operating that central location. When you look at the DAPP, everything is hosted through the Ethereum network. Because of that, you can access DAPP from any node that can access the blockchain. This opens up the huge global network of the Ethereum network.
        Decentralized applications are basically formed with the base of a blockchain. The blockchain is a fully distributed network that uses cryptography to host the applications. Decentralized applications like Ethereum which include blockchain as a data structure. Decentralized applications are those that every node is connected to the other node and every node work independently and does not rely on any other node. Applications which spread along multiple servers instead of focusing on a single. For ex, Bitcoin is the decentralized application which uses the data structure of the blockchain. The nodes of decentralized applications are distributed to which it becomes difficult to protect and prevent all of this centralized network from making any invalid or unauthorized changes to the application. Each and every decentralized application should generate tokens on the basis of a cryptographic algorithm which acts as a proof of value. DAPP(Decentralized Application)s are internet application whose backend comprises of the centralized architecture. It is the architecture that no single node has complete control or data that includes different data structures and modules which comprises of protocol for creating the web application.

An advantage of DAPP:
1. DApps are fault tolerant. The nodes and peers of the application are distributed by default and hence there is a meager chance of failure.
2. It prevents violation of net censorship and ownership as there is no authority can pressurize to append any changes.
3. DApps are IP independent. It can't access via particular IP address or domain. So, any official authority can not track any individual and shut them in particular case of emergency.
     Distributed applications are beneficial when application data and the volume of traffic increases at that rate. Centralized applications create an issue with the performance of the product in website and applications downtime. DApps overcomes the challenge to receive or achieve high availability of data. The basic examples of distributed applications are Facebook, Dropbox, and Slack.
The concept of Mist Browser: In the world of cryptocurrency software, there are essential types of nodes which are called wallets and footnotes. Wallets are software applications for desktop or mobile devices that hold the key to the EVM(EthereumVirtualMachine). It holds the money for all transactions like a debit card, or credit card or cash will be kept inside the wallet. Wallets also hold the keys. Keys correspond to an account by long account address. In Ethereum account, it does not store your name, your personal information. Anyone can create Ethereum account by connecting to the network with the help of client and that Ethereum client is mist browser. You can generate many clients the way you need it. Here, the cryptocurrency transaction is the settlement of particular trade.
    Mist is the client side module which manages all the necessary transactions. It is compatible with Windows, Linux, Mac and you can check out at Github for latest releases. It includes some plugins to support the transaction that can take place. Once the installation successful in your system, you can see the wallets and can create the contract. This contract is associated with Ethereum wallet.

Ethereum Virtual Machine: EVM is a single global 256bit computer in which all the transactions are local on each node of the network and executed relative synchronously. It is composed of lots of smaller computer. A giant computer has a node or wallet application can access makes it move
arbitrarily large amounts of value. A virtual machine is an emulation of a computer system by another computer system. It is based on the same computer architecture as the target of their emulation. This can be created as software or hardware or both. In the Ethereum context, the smart contracts are the agreements between accounts to render a transfer of ether when certain conditions are met and the assets in smart contracts are moved automatically. There are the various set of blocks and the first set of a block is called the genesis block which is also called as a canonical block. The transactions in the EVM is cryptographically signed data pocket storing a message which tells them EVM to transfer ether, create a new contract, trigger existing one or perform some calculation.

Introduction to Solidity: Solidity is the contract oriented, a high-level language for implementing smart contracts. It is influenced by python, C++, javascript and is designed to target Ethereum virtual machine. You can install a compiler for Mac, Windows, Linux or try it on the web with Remix. Take a look at the website State of the DApps to know others have built with Ethereum and solidity. Ethereum is the platform to build DAPPs and solidity is the language, Solidity supports types, inheritance, and libraries and aim at the EVM.


 Solidity Basics:  The first thing you need to do is go to Remix and feel free to erase everything and start programming with import solidity and the way you do that is keyword pragma, which means that we are going to load only once with the version number. Once you have imported the solidity file, then you can import any other file. Then,What you do is set up the contract. In the contract, you need to put the variables, functions, and code inside the contract.
    Contracts in solidity are similar to classes in the object-oriented language. It can contain state variables, functions, events, structype, and enum types. First, declare the state variables and the word state means that the current status of that variable. Also, you have functions and modifiers. Modifiers are conditions to the functions or conditions before we run the function. The last thing in the contract is an event. The events are basically the javascript events or any kind of programming language events.

Creating Simple Contracts Using Solidity: We can use remix to work on this example and leverage the compiler to run the contract afterward. First, we will create few variables and create an address which is the owner variable. We need an address because most of the contract comes with an address. Then, we will introduce a new constructor. Here, we are building the instance of the variable. The global variables that are available in messages, and then the properties that were coming from the messenger. The message will come with value, that we will pass it to money. Deceased will set false initially and pass the owner variable to the message sender. And, Set an array of address that we use and we call this as array wallets. Use the mapping to pass the integer to addresses inside of the inheritance.
    Now, you need to set the conditions of the contract with modifiers. Modifiers are conditionals to run the functions. So, put as many modifiers as we want as long as they are conditions to validate things that you want before you run the contract. Finally, go ahead do the functions that will actually run your contracts. This function will be public and will need one owner. Here, we are adding to wallets with push function. We are setting up the contract here, and then we are using inheritance and we create an array that holds the wallet with the inheritance.

        Finally, Test our sample contract to make sure that compiles and have a green compilation. Then, go to the run tab and make sure javascript VM is selected. the gas option is the cost to run the smart contract on Ethereum. For the test scenario, set the value of the contract. Now, We have the contract inheritance and we can deploy the contract and check the console to see that we have successfully created the contract and the contract on the righten side. In the deployed contracts tab, you can see the inheritance, deploy and setup. We need to set up the amount for each inheritor. Grab the contract address in the console and put in the setup such as address (comma contract of) 100 and click the setup. So, when you click this. it is going to set deceased true and then pay the money to the people in the wallet. This is how the smart contract work inside solidity.

Comments