Dapps development
What is DAPP?
DAPP is the abbreviation of Decentralized Application, that is, decentralized application, also known as distributed application. It is considered to have started the era of blockchain 3.0.
DAPP is a variety of distributed applications derived from the underlying blockchain platform, and is a form of service provision in the blockchain world. DAPP is to the blockchain, and some similar APPs are to IOS and Android.
(2) The relationship between DAPP, smart contracts and blockchain
So are DAPPs and smart contracts the same thing? What is the relationship with the blockchain? It is relatively simple and clear to express through a schematic diagram.It can be considered that DAPP is a distributed application running on smart contracts based on P2P peer-to-peer network, and blockchain provides trusted data records for it.
(3) About smart contracts
Smart contracts are a concept first proposed by Nick Szabo in 1996 before the Bitcoin era. His definition of a smart contract is as follows:
“A smart contract is a set of digitally defined agreements, including agreements on which contract parties can enforce those agreements. The basic idea of a smart contract is that various contractual terms can be embedded into the hardware and software we use In this way, attackers need a lot of cost to attack.”
The construction and execution of smart contracts based on blockchain is divided into the following steps: 1. Multiple users participate in the formulation of a smart contract; 2. The contract is diffused through the P2P network and stored in the blockchain; 3. The smart contract constructed by the blockchain The contract is automatically executed.
(4) Features of DAPP
At present, there is no unified view on the characteristics of DAPP, but they are basically the same, and they are summarized as follows.
1. DApp operates decentralized through network nodes. It can run on the user’s personal device, such as: mobile phone, personal computer. It belongs to the user forever and can be freely transferred to anyone.
2. DApps run on a peer-to-peer network. It does not depend on the central server, DApps Development Services does not need a special communication server to transmit messages, and does not need a central database to record data. The data is stored in the user’s personal space, which may be a mobile phone or a personal cloud disk.
3. The DApp data is encrypted and stored on the blockchain. It can rely on the blockchain to conduct property rights transactions and sales, and carry transaction methods without intermediaries.
4. DApp participant information is securely stored. It can protect digital assets and ensure that property rights will not be leaked or destroyed.
5. DApps must be open source and autonomous. It can be freely packaged and generated by the user, and the signature marks the ownership. Its distribution is not restricted by any institution. Various ideas and innovations can be freely expressed and realized.
(5) The difference between DAPP and APP
From the perspective of customer experience, APP has four major problems compared to DAPP, one is to intercept user data, the other is to monopolize the ecological platform, the third is to retain user rights, and the fourth is to restrict product standards and stifle innovation.
From a technical point of view, there are two main differences between DAPP and APP. One is that the APP is installed and run on Android or Apple systems; the DAPP is developed on the blockchain public chain and combined with smart contracts; the other is that the APP information is stored on the data service platform , which can be directly modified by the operator; DAPP data is encrypted and stored in the blockchain, which is difficult to tamper with.
(6) Classification of DAPP
DAPPs can be classified according to the objects of decentralization . For a centralized server, it includes three aspects: computing, storage capacity, and the data generated, and a certain “relationship” is generated by the previous correlation of the data. Therefore, in general, decentralization includes the following categories, one is decentralization based on computing power (such as POW mechanism), the other is decentralization based on storage capacity (such as IPFS), and the third is data-based decentralization (such as STEEMIT); the fourth is relationship-based decentralization (such as decentralized ID).
According to the method of decentralization , it can be roughly divided into two types of DAPPs, namely, intermediary automation DAPP and intermediary competitive DAPP. Among them, the intermediary automation DAPP is decentralized through intermediary automation. For example, through the transfer of property rights through the blockchain, the centralized program controlled by the state is transformed into an intermediary that requires any intermediary, and the original intermediary becomes an automated program; while the intermediary competitive DAPP is through competition Decentralization, Build decentralized apps not completely getting rid of intermediaries, but letting participants choose who they trust, that is to say decentralization through competition.
According to the different forms of network services , DAPP can be divided into four categories, including (1) media players, which require a CPU native code virtual machine to remove the player intermediary; (2) Web service (website) intermediaries use user data to do evil, which requires similar The latest Lambda server (dataless web service) to solve; (3) The operator intermediaries do evil and need to decentralize the P2P network, and indeed this does not necessarily require a blockchain; (4) Consensus-based user-mode smart contracts, only This requires blockchain. This classification is represented by Chen Rong, the founder of Elastos.
Analysis of Ethereum and other public chain DAPP applications
The following is a brief analysis of Ethereum and other public chains based on the white paper and related information.
(1) Ethereum DAPP
The Ethereum protocol was originally conceived as an upgraded cryptocurrency offering advanced features such as on-chain contracts, withdrawal limits and financial contracts, gambling markets, etc. through a highly general language. The Ethereum protocol will not directly “support” any application, but the existence of a Turing-complete programming language means that theoretically any contract can be created for any transaction type and application. What’s more interesting about Ethereum however is that the Ethereum protocol goes further than mere currency, with protocols built around decentralized storage, decentralized computing and decentralized prediction markets and dozens of similar concepts and decentralization applications, have the potential to fundamentally improve the efficiency of the computing industry, DApps Development Solutions and provide strong support for other P2P protocols by adding an economic layer for the first time. Eventually, there will also be a large number of applications that have nothing to do with money.
The notion of arbitrary state transitions implemented by the Ethereum protocol provides a platform with unique potential; unlike closed protocols designed for a single purpose such as data storage, gambling or finance, Ethereum is open by design, and We believe it is well suited as a base layer for the extremely large number of financial and non-financial protocols that will emerge in the years to come.
According to the Ethereum white paper, in general, there are three applications on top of Ethereum.
The first category is financial applications, which provide users with a more powerful way to manage and participate in contracts with their money. Including sub-currency, financial derivatives, hedging contracts, savings wallets, wills, and even some kind of full-scale employment contracts.
The second category is semi-financial applications, where there is money but also a heavy non-monetary aspect, a perfect example is self-enforcing bounties for solving computational problems.
Finally there are fully non-financial applications like online voting and decentralized governance.
1. Token system
There are many applications for the on-chain token system, from “sub-currency representing assets such as USD or gold” to “company shares”, individual tokens representing “smart assets”, secure unforgeable “coupons”, even with traditional value A completely unconnected token system for “point reward”.
Implementing a token system in Ethereum is surprisingly easy. The key point is to understand that all currency or token systems are fundamentally a database with the following operations: subtract X units from A and add X units to B, provided that (1) A is in There were at least X units prior to the transaction and (2) the transaction was approved by A. Implementing a token system is to implement such a logic into a contract.
2. Financial derivatives and stable currency
Financial derivatives are the most common application of “smart contracts” and one of the easiest to implement in code. The main challenge in implementing financial contracts is that most of them need to reference an external price publisher; for example, a very in-demand application is a smart contract for hedging the price of ether (or other cryptocurrencies) against the US dollar , but the contract needs to know the price of ether relative to the dollar. The easiest way to do this is through a “data-providing contract” maintained by a specific institution (such as Nasdaq), which is designed so that the institution can update the contract as needed, and provides an interface that enables other contracts to send a message to the contract to get a reply with price information.
3. Identity and reputation systems
The basic contract in Ethereum that provides a name registration system
The contract is very simple; it is a database in the Ethereum network that can be added but not modified or removed. Anyone can register a name as a value and never change it. A more complex name registration contract would contain “function clauses” that allow other contracts to query, and a mechanism for the “owner” of a name (i.e. the first registrant) to modify data or transfer ownership. You can even add reputation and trust web capabilities on top of it.
4. Decentralized storage
Ethereum contracts allow the development of a decentralized storage ecosystem, where users can reduce the cost of file storage by renting out their own hard drives or unused network space for a small profit. The fundamental building block of such a facility is what we call a “decentralized Dropbox contract”.
The contract works as follows.
First, someone divides the data that needs to be uploaded into chunks, encrypts each chunk for privacy, and builds a Merkle tree from that. Then create a contract with the following rules, every N blocks, the contract will draw a random index from the Merkle tree (using the hash of the previous block that can be accessed by the contract code to provide randomness), and give the first An entity X ether to back a proof of ownership of a block at a specific index in the tree with a similar simplified verification payment (SPV). When a user wants to re-download his file, he can restore the file using a micropayment channel protocol (e.g. paying 1 sabo per 32kbytes); the most cost-efficient method is for the payer not to publish the transaction until the end, but instead Replace the original transaction with a slightly more cost-effective transaction with the same nonce after every 32k bytes.
An important feature of this protocol is that, although it appears that one person trusts many random nodes who are not prepared to lose the file, he can divide the file into many small pieces by secret sharing, and then monitor the contract to know that each small piece has been returned. Saved by a node. If a contract is still paying, Dapps developer that provides evidence that someone is still keeping the file.
5. Savings wallet
Suppose Alice wants to keep her funds safe, but she is worried about losing or being hacked by her private key. She puts the ether into a contract with Bob, which is a bank, as follows:
Alice alone can withdraw up to 1% of her funds per day.
Bob alone can withdraw up to 1% of his funds per day, but Alice can create a transaction with her private key to cancel Bob’s withdrawal permission.
Together Alice and Bob can withdraw funds at will.
Generally speaking, 1% per day is enough for Alice, if Alice wants to withdraw more, she can contact Bob for help. If Alice’s private key is stolen, she can immediately find Bob to transfer her funds to a new contract. If she loses her private key, Bob can slowly withdraw the money. If Bob behaves maliciously, she can turn off his withdrawal permission.
6. Crop Insurance
One can easily create a financial derivatives contract with weather conditions rather than any price index as data input. If an Iowa farmer buys a financial derivative that pays inversely based on rainfall in Iowa, then if there is a drought, the farmer will automatically receive the payout funds and if there is sufficient rainfall he will Very happy because his crop will be good.