In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the concept of Ethernet Square Dao". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the concept of Ethernet Square Dao".
Decentralized Autonomous Organization, abbreviated as DAO, is an important concept in Etay Square. Generally translated as decentralized autonomous organizations.
"No one knows you are a refrigerator on the blockchain."-- Richard Brown
So far, all the contracts we have listed are owned and executed by other accounts held by humans. But there is no discrimination against robots or humans in the etherland ecosystem, and contracts can create arbitrary behavior like any other account. Contracts can have tokens, crowdfunding, and even voting members of other contracts.
In this section, we will build a decentralized democratic organization that exists only on the blockchain, but it can do what any simple account can do. The organization has a central manager who decides who is a member and the voting rules, but as we have seen, this can also be changed.
The way this special democracy works is that it has an owner Owner who works like an administrator, CEO or president. Owners can add (or delete) voting members to the organization. Any member may make a proposal which is sent to the Ethernet or executes certain contracts in the form of a Tai Fong transaction, and other members may vote for or against the proposal. Once a predetermined amount of time and a certain number of members vote, the proposal can be implemented: the contract counts, and if there is a sufficient number of votes, it will execute the given transaction.
Block chain assembly
All the codes are attached at the end of the article.
Pragma solidity > = 0.4.22 uint) public memberId; Member [] public members; event ProposalAdded (uint proposalID, address recipient, uint amount, string description); event Voted (uint proposalID, bool position, address voter, string justification); event ProposalTallied (uint proposalID, int result, uint quorum, bool active); event MembershipChanged (address member, bool isMember); event ChangeOfRules (uint newMinimumQuorum, uint newDebatingPeriodInMinutes, int newMajorityMargin); struct Proposal {address recipient; uint amount; string description Uint minExecutionDate; bool executed; bool proposalPassed; uint numberOfVotes; int currentResult; bytes32 proposalHash; Vote [] votes; mapping (address = > bool) voted;}. How to deploy
Open the wallet (if you are just testing, go to menu Development > Web > testnet), go to the contracts tab Contracts, then click deploy contract deploy contract, and paste the above code on solidity code box. On the contract selector, select Congress, and you will see the setting variable.
The minimum quorum for a proposal is the minimum number of votes required before the proposal is implemented.
The time of argument is the shortest time (in minutes) that needs to pass before execution.
If the margin of the majority of the votes exceeds 50% plus the deposit, the proposal will be passed. Leave it at 0 for a simple majority, and set it to the number of members-1 requires absolute consensus.
You can change these parameters later. First of all, you can choose 5 minutes to debate and leave the remaining parameters to 0. A little lower on the page, you will see the cost estimate for deploying the contract in Ethernet. If you want to save, you can try to lower the price, but this may mean that you have to wait longer to create a contract. Click deploy Deploy, type the password, and wait.
After a few seconds, you will be taken to the dashboard dashboard, scroll down, and you will be able to see the deal being created. In less than a minute, you will see the deal succeed and a new unique icon will be created. Click the name of the contract to view it (you can find it at any time on the contracts tab Contracts).
Share with others
If you want to share your DAO with others, they need the contract address and interface file, which is a small text string that serves as the instructions for the contract. Click the copy address copy address to get the former and display the interface show interface to show the latter.
On another computer, go to the contracts tab Contracts and click Monitor contract watch contract. Add the correct address and interface, and then click OK.
Interact with the contract
In reading the Read from contract from the contract, you can see all the functions in the contract that can be performed for free, because they only read information from the block chain. For example, you can view the current owner of the contract here, owner (which should be the account where the contract was uploaded).
In the write contract Write to contract, you have a list of all the functions that will try to do some calculations to save the data to the blockchain, so it will cost an ether. Select New Proposal, which displays all the options for that feature.
Before interacting with the contract, you need to add new members to vote. On the Select function selector, select Add Member. Add the address of the person you want to be a member (to delete a member, select the Remove Member function). In execute from, make sure you have the same account as the owner, as this is only what the primary administrator can do. Click execute execute and wait a few seconds for the next block to change.
There is no member list, but you can check to see if anyone is a member by putting its address in the Members function of the Read from contract column.
In addition, if you want the contract to have your own money, you need to deposit some ether (or other tokens), otherwise you will have a very boring organization. Press transfer Ether & Tokens in the upper right corner.
Add a simple proposal: send an Ethernet
Now let's add the first proposal to the contract. On the function selector, select New Proposal.
For "beneficiary", add the address of the person you want to send Ethernet and enter the number you want to send in the box marked "Wei Amount". Wei is the smallest unit of ether, equal to 10 ^-18 ether, and must always be given as an integer. For example, if you want to send 1 Ethernet, enter 1000000000000000000 (that is, 18 zeros). Finally, add some text that describes why you want to do this. Leave "Transaction bytecode" blank for the moment. Click execute execute and type the password. In a few seconds, numProposals will increase to 1, and the first proposal number 0 will appear on the left column. As you add more proposals, just put the proposal number in the proposals field to see any of the proposals, and you can read all the proposals.
The voting proposal is also very simple. Select Vote on the function selector. Type the proposal number in the first box, and if you agree, check the Yes box (or leave it blank to vote for it). Click execute to send your vote.
After voting time, you can choose executeProposal. If the proposal is just sending an ether, you can also leave the transactionBytecode field blank. Notice the screen that appears after clicking execute but before entering the password.
If there is a warning on the estimated fee consumption that is, the estimated cost field, it means that for some reason, the called function will not execute and will terminate abruptly. This may mean a lot of things, but in the context of this contract, this warning is displayed as long as you try to execute the contract after the deadline, or the bytecode data that the user tries to send is different from the original proposal. For security reasons, if any of these things happen, the execution of the contract will be abruptly terminated and the user who tries to trade illegally will lose all the etheric fees he sent to pay for the transaction.
If the transaction is executed, you should be able to see the result in a few seconds: the execution will become true, and the correct amount of Ethernet should be subtracted from the balance of the contract and the recipient's address.
Add a complex proposal: own another token
You can use this democratic way to execute any transaction on Ethernet Square, as long as you can find the bytecode generated by the transaction. Fortunately, you can do this with your wallet!
In this example, we will use a token to indicate that the contract can hold more than the ether and can be traded in any other etheric-based asset. First, create a token that belongs to your regular account. On the contracts page, click transfer Ethernet and tokens to transfer some of them to the new congress contract (for simplicity, do not send more than half of the coins to your DAO). After that, we will simulate what you are going to do. So if you want to advise DAO to send 500mg gold tokens to individuals as payment, please follow the steps you follow to perform the transaction from an account you have, and then click send but when the confirmation screen pops up, do not enter the password.
Instead, click the SHOW RAW DATA link to display the raw data and copy the code displayed on the RAW DATA field and save it to a text file or notepad. Cancel the deal. You also need the address of the contract you are going to invoke for the operation, in this case a token contract. You can find it on the Contracts tab: save it somewhere.
Now go back to the congress contract and create a new proposal with the following parameters:
As the beneficiary, please fill in your token address (please note if it is the same icon).
Leave the etheric currency empty.
In the job description, just write down the description of what you want to complete.
On Transaction Bytecode, paste the bytecode you saved from the data field in the previous step.
In a few seconds, you should be able to see the details of the proposal. You will notice that the transaction bytecode is not displayed there, but there is only one transaction hash transaction hash. Unlike other fields, the bytecode can be very verbose, so it is very expensive to store on the block chain, so the person who makes the call later will provide the bytecode instead of archiving it.
But, of course, this creates a security loophole: if there is no actual code, how to vote? What prevents users from executing different code after the proposal is voted on? This is the opportunity to use the talents of the trading hash. Scroll through the list of read read from contract features from the contract and you will see a proposal check feature where anyone can place all the function parameters and check whether they match the voted. This also ensures that the proposal will not be executed unless the hash of the bytecode exactly matches the hash on the provided code.
Anyone can easily check the proposal by following the same steps to get the correct bytecode and then adding the proposal number and other parameters to the ability to read the proposal code Check proposal code at the bottom of the read from contract from the contract.
The rest of the voting process remains the same: all members can vote and someone can execute the bid after the deadline. The only difference is that this time you must provide the same bytecode you submitted earlier. Pay attention to any warnings on the confirmation window: if it says it won't execute your code, check that the deadline has passed, that there are enough votes, and that your transaction bytecode has been checked out.
Make it better.
Here are some of the shortcomings of the current DAO, which we leave as an exercise for the reader:
Can you make the membership list public and indexed?
Can you allow members to change their votes (after the vote but before the results come out)?
Currently, voting information is only visible in the log. Can you create a feature that displays all votes?
=
Share some interactive online programming tutorials related to block chains such as ethernet, EOS, Bitcoin, etc.:
The java ethernet development tutorial is mainly for java and android programmers to conduct a detailed web3j explanation of blockchain ethernet development.
Python ethernet, mainly for python engineers to use web3.py for block chain ethernet development of the detailed explanation.
Php Ethernet Square, mainly introduces the use of php for intelligent contract development interaction, account creation, transaction, transfer, token development, filter and transaction and so on.
Introduction to Ethernet Square tutorial, mainly introduces the intelligent contract and dapp application development, suitable for entry.
Yi Tai Fang development advanced tutorial, mainly introduces the use of node.js, mongodb, block chain, ipfs to achieve decentralized e-commerce DApp practice, suitable for advanced.
C # Ethernet Square, mainly explains how to use C # to develop .net-based Ethernet Square applications, including account management, status and transactions, intelligent contract development and interaction, filters and transactions, etc.
EOS course, this course helps you quickly get started with the development of EOS block chain decentralized applications, covering core knowledge points such as EOS tool chain, accounts and wallets, issuing tokens, smart contract development and deployment, using code and intelligent contract interaction, and finally using all knowledge points to complete the development of a note DApp.
Java Bitcoin Development course, for beginners, covers the core concepts of Bitcoin, such as blockchain storage, decentralized consensus mechanisms, keys and scripts, transactions and UTXO, etc., as well as how to integrate Bitcoin support functions into Java code, such as creating addresses, managing wallets, constructing naked transactions, etc., is a rare bitcoin development course for Java engineers.
Php Bitcoin Development course, for beginners, covers the core concepts of Bitcoin, such as blockchain storage, decentralized consensus mechanisms, keys and scripts, transactions and UTXO, etc., as well as how to integrate Bitcoin support functions into Php code, such as creating addresses, managing wallets, constructing naked transactions, etc., is a rare bitcoin development course for Php engineers.
Tendermint block chain development detailed understanding, this course is suitable for engineers who want to use tendermint for block chain development, the course content includes the core concepts of tendermint application development model, such as ABCI interface, Merkel tree, multi-version state library, etc., as well as rich practical code such as token issuance, it is the best choice for go language engineers to get started with block chain development.
Huizhi.com original translation, reprint please indicate the source. This is the original ethernet square DAO block chain conference
Attached code:
Pragma solidity > = 0.4.22 uint) public memberId; Member [] public members; event ProposalAdded (uint proposalID, address recipient, uint amount, string description); event Voted (uint proposalID, bool position, address voter, string justification); event ProposalTallied (uint proposalID, int result, uint quorum, bool active); event MembershipChanged (address member, bool isMember); event ChangeOfRules (uint newMinimumQuorum, uint newDebatingPeriodInMinutes, int newMajorityMargin); struct Proposal {address recipient; uint amount; string description Uint minExecutionDate; bool executed; bool proposalPassed; uint numberOfVotes; int currentResult; bytes32 proposalHash; Vote [] votes; mapping (address = > bool) voted;} struct Member {address member; string name; uint memberSince;} struct Vote {bool inSupport; address voter; string justification } / / Modifier that allows only shareholders to vote and create new proposals modifier onlyMembers {require (memberID [msg.sender]! = 0); _;} / * Constructor * / constructor (uint minimumQuorumForProposals, uint minutesForDebate, int marginOfVotesForMajority) payable public {changeVotingRules (minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority) / / It's necessary to add an empty first member addMember (address (0), ""); / / and let's add the founder, to save a step later addMember (owner, 'founder') } / * * Add member * * Make `targetMember` a member named `memberName` * * @ param targetMember ethereum address to be added * @ param memberName public name for that member * / function addMember (address targetMember, string memory memberName) onlyOwner public {uint id = memberId [targetMember]; if (id = = 0) {memberId [targetMember] = members.length; id = members.length++ } members [id] = Member ({member: targetMember, memberSince: now, name: memberName}); emit MembershipChanged (targetMember, true);} / * * Remove member * * @ notice Remove membership from `targetMember` * * @ param targetMember ethereum address to be removed * / function removeMember (address targetMember) onlyOwner public {require (memberID [targetMember]! = 0); for (uint I = memberId [targetMember]) I
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.