DAO stands for Decentralized Autonomous Organization an open-source Blockchain protocol governed by a set of rules, created by its members, which automatically execute certain actions without the need for intermediaries. DAO is a community-led entity with no central authority. It is fully autonomous and transparent.
In MultiToken DAO either you can vote with Token or NFT.
- Nappy Token (ERC20Token)
- NappyNFT (ERC721Token)
- TimeLock
- Governance
- Treasury
- 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.
- Voting power is depend on decimal of Token.
- Token Name: NappyNFT
- NFT Symbol: NPY
- NappyNFt will use to mint NFT and transfer to voter for use in voting.
- First owner will mint the NFT. There is no fixed supply to mint the NFT.
- This contract will also use for delegate the NFT. User will have to call delegate() function for voting power.
- Voting power of one NFT is one.
-
This contract will set as owner of the Treasury contract.
-
It will decide how many block's to wait to execute proposal.
- 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.
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 mumbai
-
Nappy Token
:0xb1E2d34eE670F4B91C8015547D4E1F1f89a61f92
-
NappyNFT
:0x0c85214E55324d86395A8148Fe4FB395f185Ae02
-
TimeLock
:0xf43d582A34BfD50395CB8A96150E54a89D507BE3
-
Governance
:0x4dDe5bc62a29DE1e7aE84902E8D0ddA7Fb0D03fE
-
Treasury
:0x7dfBd09387E7b903edb40db98515bAF8c3158722
-
After this we will call createProposal scripts.
npx hardhat run scripts/createProposal.js --network mumbai
-
After this function we will get proposal Id.
-
Proposal Id
:63443021524830328481685862710718740376614608430634741687791276264061360147468
-
Now we will check state of the DAO.
-
Before check the state we have to wait for to mine 20 Blocks to mine.
npx hardhat run scripts/checkState.js --network mumbai
-
It will give state
1
means our proposal isActive
. -
Now everyone will vote using castVote function.
-
Some will vote with NFT & some will vote with Tokens.
npx hardhat run scripts/voteOnProposal.js --network mumbai
- Now we will check state of the DAO.
npx hardhat run scripts/state.js --network mumbai
-
It will give state
4
means our proposal isSucceeded
. -
The voting is Succeeded.
-
Now we will call the
queue
function our proposal is pass.
npx hardhat run scripts/queueProposal.js --network mumbai
-
It will give state
5
means our proposal isSucceeded
. -
Now our proposal is in Queue.
-
Now we will Execute the proposal.
npx hardhat run scripts/executeProposal.js --network mumbai
-
It will give state
7
means our proposal isExecuted
. -
Our proposal is successfully executed.
- You have to send some ether or any ERC20Token or ERC721 to Treasury.
- This contract will store the ether. Anyone can send the ether to this contract.
- Only owner(timelock) can withdraw the funds.
- It transfer ownership to
TimeLock
Contract usingtransferOwnership
function.
create .env file in root directory.
API_URL = "https://polygonscan.com/myapikey"
PRIVATE_KEY = "YOUR-METAMASK-MNEMONICS"
POLYGON_SCAN_API_KEY = "YOUR-POLYGON_SCAN_API_KEY"
-Get Your API Key
-Get Your Matic Mumbai Faucet
Clone the project
git clone https://github.com/karangorania/multi-token-DAO
Go to the project directory
cd multi-token-DAO
Install dependencies
npm install
Compile
npx hardhat compile
Test
npx hardhat test
Deploy
node scripts/deploy.js
Deploy on Mumbai
npx hardhat run scripts/deploy.js --network mumbai
Verify Contract
npx hardhat verify --network mumbai <YOUR_CONTRACT_ADDRESS>
Help
npx hardhat help