Create a staking DAO.
- A deadline is established for members of the DAO to stake ETH.
- A threshold ETH amount is set.
- If the threshold ETH amount is not collected by the deadline, members will be allowed to withdraw funds that they put in.
- If the threshold value of ETH is reached by the deadline, staking will be considered complete and the full balance of ETH is sent to a multi-sig safe.
- The staking process is considered completed once the "execute" method on the "Staker" contract is called. This method can only be called after the deadline has passed. Please note that the time deadline is only used to allow/disallow calling the execute method. Prior to calling the execute method, users can still stake ETH even if the deadline has passed. After calling the execute method, staking will be complete.
- The multi-sig safe is created after the staking is completed. The safe is initialized with the balance staked and the staking accounts. The required number of signatures is set to the number of owners minus one.
- Members will be allowed to propose transactions to send ETH to an address.
- If the required number of signatures is achieved the ETH is transferred.
clone the final project repository:
git clone https://github.com/DeveloperMarwan/blockchain-developer-bootcamp-final-project.git
cd blockchain-developer-bootcamp-final-project
git checkout maininstall and start the Hardhat chain: (Please note that the chain runs on locahost port 8545 and with chain id: 1337. Your MetaMask Network settings should match those values)
yarn install
yarn chain
- Create the .env file in the /packages/react-app folder. You can use the .sample.env file as a starting point.
- Enter your INFURA ID in line 3 and uncomment it. Please leave line 1 commented out.
- in a second terminal window, start the frontend:
cd blockchain-developer-bootcamp-final-project
yarn startin a third terminal window, deploy the contract: (this will deploy to the local hardhat network). The Staker contract is setup so that you can pass in the threshold ETH amount (in WEI) and the staking period length (in Seconds). Currently, the deployment is set to pass 1 ETH and 60 seconds as the parameter values. You can change those values by editing the /packages/hardhat/deploy/00_deploy_your_contract.js file (line #11).
cd blockchain-developer-bootcamp-final-project
yarn deployto run the tests:
cd blockchain-developer-bootcamp-final-project
yarn test
- Create the .env file in the /packages/hardhat folder. You can use the example.env file as a starting point.
- Enter the relevant information for the target test network .env
- Update the /packages/hardhat/hardhat-config.js and change the defaultNetwork to the name of the target network.
- Run the command: yarn deploy in a terminal window.
- Update the .env file in the /packages/react-app folder by entering your INFURA ID in line 1 and uncommenting it.
- Make sure that REACT_APP_PROVIDER is pointing to the same test network that was used to deploy the contract(s).
https://developermarwan-bootcamp.surge.sh/
developermarwan.eth
packages
┣ hardhat
┃ ┣ contracts
┃ ┃ ┣ MultiSigSafe.sol
┃ ┃ ┗ Staker.sol
┃ ┣ deploy
┃ ┃ ┗ 00_deploy_your_contract.js
┃ ┣ scripts
┃ ┃ ┣ deploy.js
┃ ┃ ┣ publish.js
┃ ┃ ┗ watch.js
┃ ┣ test
┃ ┃ ┣ testMultiSigSafe.js
┃ ┃ ┗ testStaker.js
┃ ┣ .eslintrc.js
┃ ┣ example.env
┃ ┣ hardhat.config.js
┃ ┗ package.json
┣ react-app
┃ ┣ public
┃ ┃ ┣ dark-theme.css
┃ ┃ ┣ favicon.ico
┃ ┃ ┣ index.html
┃ ┃ ┣ light-theme.css
┃ ┃ ┣ logo192.png
┃ ┃ ┣ logo512.png
┃ ┃ ┣ manifest.json
┃ ┃ ┣ robots.txt
┃ ┃ ┗ scaffold-eth.png
┃ ┣ scripts
┃ ┃ ┣ create_contracts.js
┃ ┃ ┣ ipfs.js
┃ ┃ ┣ s3.js
┃ ┃ ┗ watch.js
┃ ┣ src
┃ ┃ ┣ components
┃ ┃ ┃ ┣ Contract
┃ ┃ ┃ ┃ ┣ DisplayVariable.jsx
┃ ┃ ┃ ┃ ┣ FunctionForm.jsx
┃ ┃ ┃ ┃ ┣ index.jsx
┃ ┃ ┃ ┃ ┗ utils.js
┃ ┃ ┃ ┣ Account.jsx
┃ ┃ ┃ ┣ Address.jsx
┃ ┃ ┃ ┣ AddressInput.jsx
┃ ┃ ┃ ┣ Balance.jsx
┃ ┃ ┃ ┣ Blockie.jsx
┃ ┃ ┃ ┣ BytesStringInput.jsx
┃ ┃ ┃ ┣ EtherInput.jsx
┃ ┃ ┃ ┣ Events.jsx
┃ ┃ ┃ ┣ Faucet.jsx
┃ ┃ ┃ ┣ GasGauge.jsx
┃ ┃ ┃ ┣ Header.jsx
┃ ┃ ┃ ┣ L2Bridge.jsx
┃ ┃ ┃ ┣ Provider.jsx
┃ ┃ ┃ ┣ Ramp.jsx
┃ ┃ ┃ ┣ Swap.jsx
┃ ┃ ┃ ┣ ThemeSwitch.jsx
┃ ┃ ┃ ┣ Timeline.jsx
┃ ┃ ┃ ┣ TokenBalance.jsx
┃ ┃ ┃ ┣ Wallet.jsx
┃ ┃ ┃ ┗ index.js
┃ ┃ ┣ contracts
┃ ┃ ┃ ┗ external_contracts.js
┃ ┃ ┣ helpers
┃ ┃ ┃ ┣ Transactor.js
┃ ┃ ┃ ┣ index.js
┃ ┃ ┃ ┗ loadAppContracts.js
┃ ┃ ┣ hooks
┃ ┃ ┃ ┣ Debounce.js
┃ ┃ ┃ ┣ EventListener.js
┃ ┃ ┃ ┣ ExternalContractLoader.js
┃ ┃ ┃ ┣ GasPrice.js
┃ ┃ ┃ ┣ LocalStorage.js
┃ ┃ ┃ ┣ TokenList.js
┃ ┃ ┃ ┣ index.js
┃ ┃ ┃ ┗ useContractConfig.js
┃ ┃ ┣ themes
┃ ┃ ┃ ┣ dark-theme.less
┃ ┃ ┃ ┗ light-theme.less
┃ ┃ ┣ views
┃ ┃ ┃ ┣ ExampleUI.jsx
┃ ┃ ┃ ┣ Hints.jsx
┃ ┃ ┃ ┣ Subgraph.jsx
┃ ┃ ┃ ┗ index.js
┃ ┃ ┣ App.css
┃ ┃ ┣ App.jsx
┃ ┃ ┣ App.test.js
┃ ┃ ┣ constants.js
┃ ┃ ┣ ethereumLogo.png
┃ ┃ ┣ index.css
┃ ┃ ┣ index.jsx
┃ ┃ ┗ setupTests.js
┃ ┣ .eslintignore
┃ ┣ .eslintrc.js
┃ ┣ .prettierrc
┃ ┣ .sample.env
┃ ┣ gulpfile.js
┃ ┣ package-lock.json
┃ ┗ package.json