in

Blockchain : No-Nonsense Guide on How to build decentralized applications

Blockchain : No-Nonsense Guide on How to build decentralized applications


Every business person is curious to know more about how the latest blockchain technology can boost their business growth, at the same time many engineers are asking HOW DO WE BUILD BLOCKCHAIN BASED DECENTRALIZED APPLICATION?

Here a post that will help you understand the fundamentals behind decentralized applications and how to build them.

​Everybody who is with current trends must have heard about bitcoin or blockchain. So what is blockchain? The blockchain in simple terms is like a register in which all the transactions are recorded. In technical terms, it is a digital ledger which records a set of transactions. When I started learning about blockchain, my first question was why blockchain? which are a general question and I think in your mind also the same question must have arrived. So, after a lot of research, I found some blogs and white paper of Satoshi Nakamoto “[Bitcoin: A Peer-to-Peer Electronic Cash System](https://bitcoin.org/bitcoin.pdf)”. In that paper, he has explained technicality of bitcoin very well. For my question I have read many blogs, in every blog, I found a common term “[decentralization](https://medium.com/@VitalikButerin/the-meaning-of-decentralization-a0c92b76a274)”. So what is decentralization and why we need the decentralized system? Decentralization in simple term is no single authority who can take the decision. The need for decentralization was to remove all the potential issues like a single point of failure, data scalability which is in the centralized system.

After bitcoin gains popularity, researcher come up with idea of blockchain technology. There are many benefits of using blockchain technology like Transparency, Immutability, Fault tolerance, decentralization, etc. After the popularity of blockchain, many company have developed the platforms to develop the application using blockchain technology. The main platforms are Ethereum and IBM Hyperledger.

>**Setting Up Ethereum**

For creating a decentralized application using ethereum you all need to have a basic knowledge of ethereum. Ethereum uses solidity for the development of the smart contracts. So you must have knowledge of solidity. For detailed understanding of solidity take a look on [Solidity Documentation](https://solidity.readthedocs.io/en/v0.4.24/)

​

Now i am assuming you have knowledge of ethereum and solidity. Now you need to setup the private ethereum network. This post will explain, development using testnet (Testing network) that is [ganache](https://nethereum.readthedocs.io/en/latest/ethereum-and-clients/ganache-cli/). If you want to setup private ethereum network then follow this Post: [Create your own private ethereum blockchain](https://medium.com/mercuryprotocol/how-to-create-your-own-private-ethereum-blockchain-dad6af82fc9f)

​

>*Installation of testnet (****ganache****) :*
>
>*npm install ganache-cli*

[Ganache CLI Interface](https://i.redd.it/kc79y5droyj11.png)

>**Smart Contract development**

Now you have been with setups. so, let’s create a smart contract to store name in the blockchain. For testing of smart contract, we need to deploy the contract so we will use remix for this. The remix is a great platform for the creation and deployment of a smart contract.

**Smart contract for storing name in the blockchain:-**

pragma solidity ^0.4.21;
contract Store {
string name;

function store_detail(string _name) public {
name = _name;
}
}

In the first line, the solidity compiler version is mentioned. The next line is the name of the contract which is Store. There is only one function store_detail which accepts a string (name) as a parameter. So, now compile the code on the remix. For detail of how to compile code go to the link [https://remix.readthedocs.io/en/latest/](https://remix.readthedocs.io/en/latest/)

​

Now you have a smart contract. Next, you need to deploy the smart contract on testnet (ganache) so you need to go into :

>*remix -> Run -> Environment -> choose Web3 Provider*

Now the contract will be automatically deployed to ganache when you click deploy button in the remix.

**Note :** You can also deploy the smart contract on Geth private ethereum node by following the same procedure. you only need to start the RPC in your Geth node.

Now the next part is to link frontend with the blockchain.

​

>**Linking Front end**

For linking front end with your blockchain testnet, you need Web3. Web3 is a javascript framework. For more detail on web3, go to the link: [https://web3js.readthedocs.io/en/latest/](https://web3js.readthedocs.io/en/latest/)

Now you need to create an HTML page. In that page under script tag you need to import web3 like this:-

[Import Web3](https://i.redd.it/luamqeubpyj11.png)

​

Now you need to provide ABI of the smart contract in the code and the address of the contract like this:-

var StoreContract = web3.eth.contract( ABI of the contract from remix );
var SD = StoreContract.at( Contract Address );

Then you can call the functions created in the smart contract like store_detail.

SD.store_detail(“YOUR NAME”);

This function will store the data in the blockchain. You can launch the HTML page in the browser and can interact with blockchain.

**Note:** This is the basic tutorial to start with development using blockchain technology.

I hope the post was enjoyable and useful. If you think this is helpful for someone else, do not forget to share. Also, let me know your thoughts on this.




View the link

What is the Blockchain?



A block chain is a transaction database shared by all nodes participating in a system based on the Bitcoin protocol. A full copy of a currency’s block chain contains every transaction ever executed in the currency. With this information, one can find out how much value belonged to each address at any point in history.

Author: hv_ghost

Score: 5

Don’t forget to share the post if you love it !

Bitcoin : Roger Ver Weekly Show – What Happened At The Bangkok Miner Meeting? Bitcoin Cash Added to Yahoo, BitPay, NetCoins. BCH Stress Testing and More

Bitcoin : WeSellCrypto is back!