A smart contract that functions as a simple decentralized autonomous organization. This is in development (i.e. not extensively tested for deploying on the Ethereum mainnet). It has been tested using Remix.
-
Open Remix and deploy the vending machine solidity contract first and then the simpleDAO contract. You can import this repo into the Remix IDE directly or simply copy and paste the code.
-
Solidity is a statically typed programming language and you must compile the code before deploying the smart contract.
-
Copy and paste the address of the vending machine into the simpleDAO constructor.
-
Specify how long members will be allowed to vote (seconds)
-
Add in name of proposals: ["buy_cupcakes", "no_cupcakes"]
-
Only the chairperson can give the right to vote in the DAO to other addresses.
-
If the majority of the DAO members who voted selected "buy_cupcakes", then the DAO will send 1 ether to the digital vending machine and in return the DAO will recieve one cupcake.
How to run tests:
npm i
npx hardhat test test/SimpleDAO.test.ts
This code is essentially a conglomeration of functions of a few solidity code examples from the documentation that I liked.