Blockchain circle

One stop hot information platform

About us:

Blockchain circle provides the latest information about blockchain, digital currency, digital wallet, exchange, metauniverse, bitcoin, Ethereum, contract, financial management and so on, and always pays attention to the latest market...

Introduction blockchain technology tutorial for Ethereum to develop DAPP applications,Introduction to blockchain application development

Time : 01/08/2022 Author : tmad78 Click : + -
        The reason why we choose voting as our first blockchain application is because of collective decision-making & mdash& mdash; Especially the voting mechanism & mdash& mdash; It is a core value proposition of Ethereum. Another reason is that voting is the basic component of many complex decentralized applications, so we chose voting application as the first project to learn the development of blockchain applications. If you are familiar with relational databases, you should know that a data table can contain many rows of data records. For example, the following data table contains 6 transaction records:. In essence, the blockchain is first of all a distributed database, which maintains a growing list of records.
        Now, let's batch store the data, such as 100 rows per batch, and connect the storage batches. Is it like a chain?. In a traditional relational database, you can easily update a data record. However, in the blockchain, once data is written, it cannot be updated again & mdash& mdash; Therefore, the blockchain has been growing. This first benefits from the hash function & mdash& mdash; If you haven't touched the hash function, you can consider it as a digital fingerprint calculation function: input content of arbitrary length and output a fixed length code stream (fingerprint).
        An important characteristic of hash function is that any small change of input will lead to the change of output. The hash value can be used as the fingerprint of the content. Since each block in the blockchain stores the hash value of the previous block content, if the content of any block is tampered with, the hash value of all blocks after the tampered block will also change, so we can easily detect whether each block in the blockchain has been tampered with. Once completely decentralized, there will be a large number of blockchain copies (i.e., full nodes) on the network, and many things will become more complex than the previous centralized application environment, such as:. By comparing with the classic C / S architecture, we will gradually understand the core ideas of decentralized applications and master how to build decentralized applications on Ethereum.
        The best way to understand the decentralized application architecture is to compare it with the familiar client / server architecture. If you are a web developer, you should be familiar with the following figure, which is a typical client / Server Architecture:. The user interacts with the web application (server) through the client. Typical clients include browsers, command-line tools (curl, WGet, etc.), or API access code. Note that in this architecture, there is always one (or a group) centralized web server, and all clients need to interact with this (Group) server.
        When a client sends a request to the server, the server processes the request, interacts with the database / cache, reads / writes / updates the database, and then returns a response to the client. You should have noticed that each client (browser) interacts with its own node application instance instead of requesting services from a centralized server. In an ideal decentralized environment, everyone who wants to interact with DAPP needs to run a complete blockchain node on their computer or mobile phone & mdash& mdash; In short, everyone runs a full node. This means that users have to download the whole blockchain before they can actually use a decentralized application.
        However, we do not live in a utopia. It is unrealistic to expect each user to run a full node first and then use your application. But the core idea behind decentralization is not to rely on centralized servers. Therefore, some solutions have emerged in the blockchain community, such as infra, which provides public blockchain nodes, and the browser plug-in metamask. Through these solutions, you do not need to spend a lot of hard disk, memory and time to download and run a complete blockchain node, and you can also take advantage of the advantages of decentralization. We will evaluate these solutions in future courses.
        In each Ethereum full node, complete blockchain data is saved. Ethereum not only saves the transaction data on the chain, but also saves the compiled contract code on the chain. Every transaction in Ethereum is stored on the blockchain. When you deploy a contract, a deployment is a transaction. When you vote for a candidate, one vote is another deal. All these transactions are public, and everyone can see and verify them. This data can never be tampered with. In order to ensure that all nodes in the network have the same data copy, and no invalid data is written into the database, Ethereum currently uses the proof of work (POW) algorithm to ensure network security, that is, consensus is achieved through mining by miners & mdash& mdash; Synchronize data to all nodes.
        Workload proof is not the only algorithm to reach consensus, and mining is not the only choice for blockchain. Now, we only need to understand that consensus means that the data of each node is consistent, and POW is only one of many algorithms used to establish consensus. This algorithm needs mining by miners to achieve trusted transactions in an untrusted environment. Consensus is the end and POW is the means. At the database level, the role of the blockchain is to store transaction data. So where is the logic for voting candidates or retrieving voting results? In the world of Ethereum, you can use solidity language to write business logic / application code (that is, contract), then compile the contract code into Ethereum bytecode, and deploy the bytecode to the blockchain:.
        The Ethereum blockchain not only stores data and code, but also contains a virtual machine (EVM: Ethereum virtual machine) in each node to execute contract code & mdash& mdash; It sounds like a computer operating system. In fact, this is the core point that distinguishes Ethereum from bitcoin: the existence of virtual machines has brought the blockchain into the 2.0 era and made it a friendly platform for application developers for the first time. In order to facilitate the construction of Web-based dapps, Ethereum also provides a very convenient JavaScript library web3.js, which encapsulates the API protocol of Ethereum nodes, so that developers can easily connect to blockchain nodes without writing cumbersome RPC Protocol packages.
        Therefore, we can directly introduce this library into common JS frameworks (such as reactjs, angularjs, etc.) to build decentralized applications:.
Previous:79 "Qingdao experiences" are the first in China! The third anniversary of Qingdao's free trade presented a brilliant "answer"
Next:No more

Related articles:

© 2005-2032 | Blockchain Circle & & All Rights Reserved    Sitemap1 Sitemap2 If there is infringement, please contact us at: