Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use eTaifang block chain to build decentralized application DApps

2025-04-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to use etherfang block chain to build decentralized application DApps", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use etherfang block chain to build decentralized application DApps" article.

What are we going to build?

The project we are building is called The Neverending Story (TNS). The complete project can be found at storydao.bitfalls.com. Its complete code is on GitHub.

The Nendingnding Story is a Web application with input fields (which can be text and images) where users with MetaMask installed can send a piece of text or image based on certain conditions. (the image appears only once every 50 paragraphs, and can only be one URL. )

The full story is presented next to the input field. The more items there are in the story, the higher the cost of submitting them. There is a fee to be paid for submitting items, which can be used by whitelisted people with at least one TNS token.

Type of operation:

Submit entry: the sender is required to have at least 1 TNS token and be on the whitelist (see below). Cost 0.0001 ether * number of entries in current chapter. (see the Section section below). This can be only one image for every 50 text entries, and can only be one URL. Otherwise, it's words. There is no code, only plain text. In either case, the text field size is limited to 256 characters.

Transfer of ownership (owner only): ownership can be transferred to a new address.

Cost reduction (owner only): owners can submit lower fees without requiring a vote (see the fees "Free" section below).

Purchase TNS tokens: send ethernet to DAO for automatic return of a certain percentage of TNS tokens. If there are not enough TNS tokens in DAO, they must be obtained from the exchange.

Check token balance: a read-only operation to check how many TNS tokens are in DAO.

Whitelist: this function is automatically called when the ether is sent to the address of DAO. It records senders in a whitelist array for future reference, and people who get a lot of TNS cannot distribute them to various accounts.

Closing chapter: triggers the closing process of allocating etheric dividends and resetting input fees.

Withdrawal: called when a stakeholder wants to withdraw the dividend.

Owner withdrawal (owner only): called by the owner to withdraw fee income.

Stakeholders (holders of TNS tokens) will be able to vote on the proposal, and any proposal that achieves more "Yes" than "No" will be approved. The number of votes does not matter; the proportion is important. Depending on the type of proposal, the proposal needs to be open for voting within a specific period of time.

Proposal type:

Delete entry: after confirming by voting, the target entry will be deleted. Voting time: 48 hours.

Emergency delete entry (owner only): can only be triggered by the owner. Once confirmed by a vote, the target entry will be deleted. Voting time: 12 hours.

Emergency deletion of an image (owner only): applies only to image entries. Can only be triggered by the owner. Once confirmed by a vote, the target entry will be deleted. Voting time: 4 hours.

We can add other types of proposals later using the same method.

All proposals need to be clearly listed in the user interface so that people know they need to vote. Voters only need one TNS token to vote, but the more tokens they have, the more worthy their vote will be.

Important: the user's token is locked during the vote. This prevents TNS predators from overwhelming every active vote. Voters must distribute the right to vote on ballots that are important to them.

Chapters chapter

After 1000 entries or three weeks, any user can call the end of the chapter. DAO will then distribute the collected etheric coins to all TNS holders in proportion to their balance. Holders do not need to be whitelisted in DAO to receive ether dividends. They only need to keep TNS tokens at the time of distribution.

Distribution is a pull mechanism: holders need to call the undo function of DAO to obtain their ether. It will not be called automatically. The exit window is 72 hours. 50 per cent of the unclaimed gas goes to the owner and 50 per cent goes to the dividend of the next chapter.

Free fee

1% of each submitted entry fee will be transferred to the current owner. The rest is pooled and distributed to all TNS holders at the end of each chapter, proportional to their TNS holdings.

Owners' fees are divided into separate balances, and they can opt out on a regular basis.

To be on the whitelist, the user must send 0.01ethernet to DAO. All future tokens will be purchased at much lower prices. Ethernet admission fee is to prevent Sybil attacks. If the number sent by the user exceeds 0.01the first time it is sent, it will turn to the whitelist and the rest will be used to calculate the number of TNS received by the user. All tokens will be sent back to the user at one time.

In short, think of the project as a crowdsourced choice of your own adventure story, including crowd planning and community review. A story-DAO (story-DAO).

Bootstrapping:PoA Private Block chain

We will use two bootstraps: the first one will focus on running our own real etheric block chain locally. It will use PoA as a consensus mechanism and work like any true ethernet testnet.

Download and install Virtualbox.

Download and install Vagrant. If you don't know what a virtual machine is, please refer to this post.

Download Geth from here. Be sure to scroll down the download page and download "Geth&Tools", not just "Geth". If you are using macOS, you can also use Homebrew and install it using brew install ethereum.

Mist can be downloaded here. Be sure to download "Mist" instead of "Ethereum Wallet". Mist is the "browser" of Etay Square, which can open all kinds of DApps. Ethersquare wallet "Ethereum Wallet" can do the same thing, but locked in wallet mode, so you can't use it to open other applications. This is to prevent non-technical users from accessing malicious DApp.

If you are curious, please learn more about Mist and Geth here.

We need VirtualBox and Vagrant because we will use this method to start our node and run two virtual machines to simulate the two computers running the Ethernet Fong node.

Next, follow the instructions in this post to set up the PoA private block chain.

You will eventually get two running nodes. Everyone will dig up their own address. Write down these addresses. Mine is:

Node 1:0x4b61dc81fe382068e459444e8beed1aab9940e3b Node 2:0x97e01610f1c4f4367c326ed1e9c41896b4378458

Bootstrapping:Ganache CLI

The second bootstrapper we can use, which is particularly useful for testing our contract, is Ganache CLI, formerly known as Testrpc.

Ganache is a local block chain simulation based on JavaScript. Every time we run the test or restart the application, it reruns the blockchain from scratch. This helps us to quickly test marginal situations, but it is not suitable for long-term testing of long-term contracts.

First, install Ganache using npm install-g ganache-cli.

Then, just run ganache-cli. You should see output similar to this:

$ganache-cliGanache CLI v6.1.0 (ganache-core: 2.1.0) (node:40584) ExperimentalWarning: The fs.promises API is experimentalAvailable Accounts= (0) 0xa0b7139a36ecda5ffda66b9cf97cb9de36e63f2f (1) 0x1f5546797a0ff7efe42ecafaeebd5c932f1a0143 (2) 0x0eacbad38a642db2204574ad01b2b51c82ff7080 (3) 0x77f40a8add69b0e0806c0c506208e5783b89076d (4) 0x1ea41547984ecb949c2b2df311bffe0fdeae4632 (5) 0xa1ad154fd5fd11ebe5410c992e5e97b461c516a2 (6) 0x34da52fd90c015a41bcc383ba3d804f7cebbc84e (7) 0xddd5232788c1f1192d6ac5e82e74ca80945e119e (8) 0x7ebc838124a676eac57f9b6275cd29b1a1c63d4d (9) 0x6feed7913319ffb1b01f767960dd843ea7f96181Private Keys= (0) 62727ad35a288eb34f268cffb1ce620ef3ee80910138aed0e81f24d912fd8a49 (1) a6c76b382c655dcc66dd92428e3e0a0f14b7458162ad8e5cbbbcc64d3362d28c (2) eef05f81fd995329c80d8875d5cb62b81f8f28c39951665b4b15688dc48b4c47 (3) 5ae06fc34da5d47a64a814ee088f7c6f0d1cae3c63d7ad2d6b71b8128bce1764 (4) 8cc43f28054f90243dea496263bd9a45f33db44ea3956ab8d0e8704e15d0787e (5) dcf37436237105ea2f5b1be608b6aa1fe6fb7ca80b8b23ce01ff96930a2a3045 (6) f896b6f0ee11ea272c1567ec1950f7ff610df79193cbb7b668ae0ea11f6ec825 (7) 877b5868dca9a2f5c7d9546647171c9825f1b02922442f18dd4e90d108b9e54d (8) 7f1f3515d71d348a78ae85a755e02df49be4e0b374447b822abe5a6481fe0c58 (9) 20d50b28c8b051406edc6aa61becc3443e430d7d68925a108958f8abecd55ed3HD Wallet=Mnemonic: Soda tower talk dynamic swim tattoo edit cook pair bid glance beautyBase HD Path: M-account_index 44-pound, 60-pound, 60-pound, 0-pound, 0 / {account_index} Listening on localhost:8545.

What Ganache does here is start the private blockchain, with little mining time and no nodes. It will execute the transaction as soon as it enters. It also generates 10 addresses that are preloaded with a large number of virtual ethernets and generates private keys to import them into various tools, such as MetaMask,MyEtherWallet or the previously downloaded Mist.

We will use a mix of this method and the above method according to our needs, so be sure to set up both methods at the same time.

Note: it is also advisable to use the Ganache UI tool and use the visual interface to manage the Ganache blockchain.

The above is the content of this article on "how to use the ethernet block chain to build a decentralized application DApps". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report