Coder Social home page Coder Social logo

dao-smart-contract's Introduction

DAO-Smart-Contract

DAO Smart Contract for donation were you can propose the then propose pass and everyone will be given token to vote. If it success then the address we have provide ether will deposit.

-There are four Contract.

  • Nappy Token
  • TimeLock
  • Governance
  • Locker

Nappy Token

  • Token Name: Nappy Token
  • Token Symbol: NPY
  • Nappy Token will use to mint token and transfer to voter for use in voting.
  • First owner will mint the token. There is no fixed supply to mint the token.
  • This contract will also use for delegate the tokens. User will have to call delegate() function for voting power.

TimeLock

  • This contract will set as owner of the Locker contract.

  • It will decide how many block's to wait to execute proposal.

Governance

  • This contract will create the proposal and vote for the same.
  • In this contact user can create the proposal, vote, cancel.
  • There are several stages for proposal.

Stages

Sr No Stages
0 Pending
1 Active
2 Cancelled
3 Defeated
4 Succeeded
5 Queued
6 Expired
7 Executed
  • First of all we will deploy the contract. We will get contract address of all deploy contract.
  npx hardhat run scripts/deploy.js --network ropsten
  • Nappy Token : 0xb1E2d34eE670F4B91C8015547D4E1F1f89a61f92

  • TimeLock : 0x8fC26556DfCD22cCEa0478feb67B29Aa0363D1B4

  • Governance : 0x032BA118F762c78dD254064F42C1B9dd9205731A

  • Locker : 0xF6BFeFAdD008FBF7F5F3b54E3ec5d1403967ac8f

  • After this we will call proposal contract.

  npx hardhat run scripts/proposal.js --network ropsten
  • After this function we will get proposal Id.

  • Proposal Id : 6710164757546047754297806568396090581956979312861437213151479767075350705109

  • Now we will check state of the DAO.

  • Before check the state we have to wait for to mine 20 Blocks.

  npx hardhat run scripts/state.js --network ropsten
  • It will give state 1 means our proposal is Active.

  • Now everyone will vote using castVote function.

  npx hardhat run scripts/voting.js --network ropsten
  • Now we will check state of the DAO.
  npx hardhat run scripts/state.js --network ropsten
  • It will give state 4 means our proposal is Succeeded.

  • The voting is Succeeded.

  • Now we will call the queue function our proposal is pass.

  npx hardhat run scripts/state.js --network ropsten
  • It will give state 5 means our proposal is Queued.

  • Now our proposal is in Queue.

  • Now we will Execute the proposal.

  npx hardhat run scripts/execute.js --network ropsten
  • It will give state 7 means our proposal is Executed.

  • Our proposal is successfully executed.

Get item

Locker

  • This contract will store the ether. Anyone can send the ether to this contract.
  • Only owner can withdraw the funds.
  • It transfer ownership to TimeLock Contract using transferOwnership function.

Important Step

create .env file in root directory.
    API_URL = "https://eth-ropsten.alchemyapi.io/v2/your-api-key"
    PRIVATE_KEY = "YOUR-METAMASK-PRIVATE_KEY"
    ETHERSCAN_API_KEY = "YOUR-ETHERSCAN_API_KEY"

-Get Your API Key

-Get Your Ropsten Faucet

NPM Packages

Tech Stack

Run Locally

Clone the project

  git clone https://github.com/karangorania/dao-smart-contract

Go to the project directory

  cd dao-smart-contract

Install dependencies

  npm install

Compile

  npx hardhat compile

Test

  npx hardhat test

Deploy

  node scripts/deploy.js

Deploy on Rinkeby

  npx hardhat run scripts/deploy.js --network ropsten

Verify Contract

npx hardhat verify --network rinkeby <YOUR_CONTRACT_ADDRESS>

Help

  npx hardhat help

Check on Ropsten Explorer

Deploy Contract

Transaction

Proposal ID

dao-smart-contract's People

Contributors

karangoraniya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.