If you notice the diagram on the right, every client (browser) communicates with its own instance of the application. There is no central server to which all clients connect to. This means, in an ideal decentralized world, every person who wants to interact with a dapp (Decentralized Application) will need a full copy of the blockchain running on their computer/phone etc. That means, before you can use an application, you have to download the entire blockchain and then start using the application.
We don't live in an ideal world and it is unreasonable to expect everyone to run a blockchain server to use these apps. But the idea behind decentralization is to not rely on a single/centralized server. So, the community has come up with solutions (hosted blockchain servers, metamask etc.) where you don't have to spend lot of your hard disk and RAM downloading and running a full copy of the blockchain but also not compromise on the decentralized aspect. We will evaluate those options in the future lessons.
Now, what exactly is in the Ethereum blockchain? The blockchain has 2 main components:Database: Every transaction in the network is stored in the blockchain. When you deploy your application, it is considered as a transaction. If you have for example a Voting application that allows anyone to vote for candidates, a vote for a candidate would be considered a transaction. All these transactions are public and any one can see this and verify. This data can never be tampered with. To make sure all the nodes in the network have same copy of the data and to insure no invalid data gets written to this database, Ethereum uses an algorithm called Proof of Work to secure the network. (http://ethereum.stackexchange.com/questions/14/what-proof-of-work-function-does-ethereum-use)
Code: The database aspect of blockchain just stores the transactions. But where is all the logic to vote for candidate, retrieve the total votes etc. In Ethereum world, you write the logic/application code (called contract) in a language called Solidity. You then use the solidity compiler to compile it to Ethereum Byte Code and then deploy that byte code to the blockchain (There are few other languages you could use to write contracts but solidity is by far the most popular and relatively easier option). So, not only does Ethereum blockchain store the transactions, it also stores and executes the contract code.
So basically, the blockchain stores your data, stores the code and also runs the code in the EVM (Ethereum Virtual Machine). You will learn more about ByteCode and EVM in the future sections.
To build web based Dapps, Ethereum comes with a handy javascript library called web3.js which connects to your blockchain node. So you can just include this library in your famous js framework like reactjs, angularjs etc and start building
How can this code enforce the agreement? If you remember, once a contract is deployed to the blockchain, it can neither be stopped nor modified. That is how the agreement is enforced. Let's take a look at a simple example to understand this better.
Let's say we want to build a Crowdsale application. There is a creator who wants to raise $10,000 to create a product and there are potential customers who are interested in this product and are willing to pre-pay for it. The agreement is, each customer will contribute anywhere between $10 - $10,000 and if the goal is met, the money is sent to the creator. If not, money is sent back to the contributors. This is an ideal use case to use smart contract to enforce the agreement between the creator and supporters. It is trivial to implement this logic in a centralized application as well. The advantages of implementing this in a smart contract areThe money sent by all the contributors is in the smart contract. Neither the contributor nor the creator can take that money.
The code can be implemented so that the money is sent to the creator as soon as the goal is reached.The code can be implemented so anyone can trigger a refund to all the customers if the goal is not reached within a certain time frame.
This code can not be tampered once it is deployed on to the blockchain.
Just like in the real world, each country has it's own currency like USD, INR, RNB, GBP, EUR etc, each blockchain has it's own currency. In the case of Ethereum blockchain, the native currency is called Ether. There are exchanges where you can convert Ether to any other fiat currency like USD or EUR. You can see the current price of Ether here
In the real world, currencies have various denominations. For example, a US Dollar is equal to 100 cents and it has various denominations such as pennies (1 cent), nickel (5 cents), dime (10 cents), quarter (25 cents). Depending on your country and currency, you probably have various denominations as well.
Ether also has various denominations as shown on the right. The only two you should really remember are Ether and Wei. Wei is the lowest denomination and this is the denomination you use in your smart contracts.
Ether also has various denominations as shown on the right. The only two you should really remember are Ether and Wei. Wei is the lowest denomination and this is the denomination you use in your smart contracts.
Comments
Post a Comment