Wednesday, April 22, 2026
The BLOCKCHAIN Page
No Result
View All Result
  • Home
  • Cryptocurrency
  • Blockchain
  • Bitcoin
  • Market & Analysis
  • Altcoins
  • DeFi
  • Ethereum
  • Dogecoin
  • XRP
  • Regulations
  • NFTs
The BLOCKCHAIN Page
No Result
View All Result
Home Ethereum

Ethereum in practice part 2: how to build a better democracy in under a 100 lines of code

by admin
January 14, 2024
in Ethereum
0
Dodging a bullet: Ethereum State Problems
0
SHARES
65
VIEWS
Share on FacebookShare on Twitter


It is a second publish on a sequence on use the present Ethereum instruments to construct good contracts while not having programming expertise. Download the latest version of the Ethereum Wallet, read the first part and let’s have enjoyable!

Creating a token is fun, however what’s the worth of a token that would not do something new? We are actually going to create a brand new contract that makes use of the tokens we simply created. The contract shall be a Democratic group that lives on the blockchain and that anybody holding a share token will be capable to vote on proposals.

So let’s return to “Contracts” after which “Deploy Contract” and paste the DAO source code on the “Solidity Supply” subject. Select the contract “Democracy” on the Picker after which choose these parameters:

  • On the quantity subject you possibly can add any ether quantity you need your DAO to start out with. Since you possibly can ship ether to it at any time sooner or later, if that is the primary time you’ve got been doing this then preserve the quantity at 0 and ship the cash later.
  • On the sharesAddress subject, paste the deal with of the token contract you simply created. Take note of the icon and coloration of the little circle that seems by the aspect of the deal with. If it doesn’t match precisely the one for the contract you created beforehand, then there’s an error.
  • On minimumSharesForVoting choose what’s the minimal quorum of shareholders that must vote on a difficulty earlier than it passes. Right here you need to put the integer variety of the minimal token potential, so in the event you created a token with 2 decimal locations, placing 500 right here will imply that to ensure that a proposal to be executed then the variety of votes have to be greater than 5% of the full shares of the corporate.
  • minutesForDebating: that is the minimal time a proposal have to be mentioned and voted on earlier than the outcomes might be tallied up. Put a small quantity like 10 minutes in order for you simply to create one thing for testing, however put one thing like 20,000 if you wish to retailer massive quantities of ether, so all proposals should keep there for no less than two weeks.

 

Your contract ought to be wanting one thing like this:

Ethereum Wallet Screenshot 2015-12-03 at 3.50.36 PM 16

 

After a number of seconds you may be redirected to a the dashboard the place you may see your new contract being created:

Ethereum Wallet Screenshot 2015-12-03 at 3.50.36 PM 13

You may also see the hyperlink to the brand new contract on the “Contracts” tab. If it is not there (for instance: if you’re including a contract that you just did not create) then you definitely’ll have so as to add it manually. So as to add that you will want the contract’s deal with and it is JSON interface, a string of textual content that explains to the pockets work together with the code. You may choose any identify you need and press OK.

Ethereum Wallet Screen Shot 2015-12-03 at 9.57.34 AM

Click on your new contract field and you will see a contract web page. If you have not already deposited some ether on that contract, click on on deposit and put some small quantity of ether so you possibly can take a look at how this specific democracy works. If the contract already has some funds, click on the “present contract information” button.

On the “learn from contract” you possibly can see all of the capabilities you possibly can execute without spending a dime on the contract, as they’re simply studying data from the blockchain. Right here you possibly can see, as an example, that the “sharesTokenAddress” is certainly the proper deal with or that there are at present 0 proposals on the contract. Let’s change that.

On the “Write to contract” you have got a listing of all of the capabilities that may try to do some computation that saves knowledge to the blockchain, and subsequently will price ether. Choose “newProposal” and it’ll present all of the choices choices for that perform.

Ethereum Wallet Screen Shot 2015-12-01 at 6.10.32 PM

 

For “beneficiary” add the deal with of somebody you need to ship ether to, then put what number of ethers you need on the “etherAmount” (have to be an integer) and eventually some textual content describing the explanation you need to do that. Depart transactionByteCode clean for now. Click on execute and kind your password. After a number of seconds the numProposals will enhance to 1 and the primary proposal, quantity 0, will seem on the left column. As you add extra proposals, you possibly can see any of them by merely placing the proposal quantity on the “proposals” subject and you may learn all about it.

Voting on a proposal can also be quite simple. Select “vote” on the perform picker. Kind the proposal Quantity on the primary field and examine the “Sure” field in the event you agree with it (or depart it clean to vote in opposition to it). Click on “execute” to ship your vote.

 

Screen Shot 2015-12-01 at 6.18.22 PM

When the minimal voting time has handed, you possibly can choose “executeProposal”. If the proposal was merely sending ether, then you too can depart the “transactionBytecode” subject clean. After urgent “execute” however earlier than typing your password, take note of the display screen that seems. If there’s a warning on the “estimated price consumption” subject, then because of this for some purpose the perform known as won’t execute and shall be abruptly terminated. It might imply many issues, however within the context of this contract this warning will present up everytime you attempt to execute a contract earlier than its deadline has handed, or if the person is attempting to ship a special bytecode knowledge than the unique proposal had. For safety causes if any of these items occurs, the contract execution is abruptly terminated and the person that tried the unlawful transaction will lose the all of the ether he despatched to pay transaction charges.


Ethereum Wallet Screen Shot 2015-12-01 at 6.21.30 PM

If all the things went properly it’s best to be capable to see the outcomes of the vote in a number of seconds. The “openToVote” parameter on the primary field will flip to false whereas the proposalPassed will replicate if the proposal has been accepted or not. You also needs to be capable to see that the Ether stability of the contract will go down and the equal ether shall be despatched to the beneficiary of the ether you wished to ship.

Now take a second to let that in: you simply created a corporation that solely exists on the blockchain, that obeys votes based mostly on fully digital tokens, however but it could possibly transfer actual worth round and create a really actual impression on the world. Additionally discover that the group shouldn’t be below your management anymore: it’s going to execute solely the precise code you used to create it, endlessly. You may’t bribe it, you possibly can’t earmark it and the identical guidelines apply both you might be shifting 0.01 or 1,000,000 ethers.

Can it get any higher than this? Truly, it could possibly. On our next post we will explore how you can use “transactionBytecode” to allow the DAO to execute any kind of ethereum transaction, even proudly owning or creating different contracts. We’ll additionally modify the token code to permit the DAO to regulate the quantity of a token that exists on circulation and ship it ahead.



Source link

Tags: buildCodedemocracyEthereumLinesPartpractice
admin

admin

Recommended

Five Things to Know about Ethereum Dencun Upgrade, ETH Price Rally to Continue?

Vitalik Buterin Proposes Plan to Strengthen Ethereum Staking Decentralization

2 years ago
Kyber Network Knowledge: Powering Liquidity in DeFi

Kyber Network Knowledge: Powering Liquidity in DeFi

2 years ago

Popular News

  • Protocol-Owned Liquidity: A Sustainable Path for DeFi

    Protocol-Owned Liquidity: A Sustainable Path for DeFi

    0 shares
    Share 0 Tweet 0
  • Cryptocurrency for College: Exploring DeFi Scholarship Models

    0 shares
    Share 0 Tweet 0
  • What are rebase tokens, and how do they work?

    0 shares
    Share 0 Tweet 0
  • What is Velodrome Finance (VELO): why it’s a next-gen AMM

    0 shares
    Share 0 Tweet 0
  • $10 XRP Price Envisioned By Fund Manager As Ripple Mounts Trillion-Dollar Payment Markets ⋆ ZyCrypto

    0 shares
    Share 0 Tweet 0

Latest

Ripple Unveils Multi-Phase Plan To Make The XRP Ledger Quantum-Ready By 2028

Ripple Unveils Multi-Phase Plan To Make The XRP Ledger Quantum-Ready By 2028

April 21, 2026
I got an early look at ChatGPT Images 2.0, and it’s impressive – with one exception

I got an early look at ChatGPT Images 2.0, and it’s impressive – with one exception

April 21, 2026

Categories

  • Altcoins
  • Bitcoin
  • Blockchain
  • Cryptocurrency
  • DeFi
  • Dogecoin
  • Ethereum
  • Market & Analysis
  • NFTs & Metaverse
  • Regulations
  • XRP

Follow us

Recommended

  • Ripple Unveils Multi-Phase Plan To Make The XRP Ledger Quantum-Ready By 2028
  • I got an early look at ChatGPT Images 2.0, and it’s impressive – with one exception
  • Own a Sony TV? 3 quick settings I’d change to meaningfully improve the picture quality
  • XRP Expansion onto Solana Draws Fresh Market Attention
  • I speed-tested Surfshark’s new ‘heavenly’ Dausos VPN protocol – how it compares to WireGuard
  • About us
  • Privacy Policy
  • Terms & Conditions

© 2023 TheBlockchainPage | All Rights Reserved

No Result
View All Result
  • Home
  • Cryptocurrency
  • Blockchain
  • Bitcoin
  • Market & Analysis
  • Altcoins
  • DeFi
  • Ethereum
  • Dogecoin
  • XRP
  • Regulations
  • NFTs

© 2023 TheBlockchainPage | All Rights Reserved