dao.sql
1 -- # DAO::mint() 2 -- 3 -- First one person will create the DAO 4 -- 5 -- $ drk dao create_dao \ 6 -- PROPOSER_LIMIT \ 7 -- QUORUM \ 8 -- EARLY_EXEC_QUORUM \ 9 -- APPROVAL_RATIO \ 10 -- GOV_TOKEN_ID > dao.toml 11 -- 12 -- dat.toml contains: 13 -- 14 -- * DAO parameters as listed above 15 -- * Secret keys for the DAO 16 -- * Bulla blind 17 -- 18 -- We can view the data like so: 19 -- 20 -- $ drk dao view < dao.toml 21 -- 22 -- Now everyone inside the DAO exchanges dao.toml out of band, 23 -- will import it into their wallets. 24 -- 25 -- $ drk dao import DAO_NAME < dao.toml 26 -- Imported DAO ccb8XXX8af6 27 -- 28 -- Where ccb8XXX8af6 is the DAO's name. 29 -- 30 -- Next someone that holds all the keys will mint it on chain 31 -- 32 -- $ drk dao mint DAO_NAME > dao_mint_tx 33 -- $ drk broadcast < dao_mint_tx 34 -- 35 -- And then the others will receive confirmation that the DAO they imported 36 -- into their wallet has also been accepted on chain. 37 -- 38 -- # Minting and Receiving Coin 39 -- 40 -- Assume that the governance tokens have been created and distributed 41 -- appropriately among DAO members. We will skip that part here. 42 -- 43 -- Now the DAO can receive coins into its treasury. These coins simply 44 -- have both the coin's spend_hook and user_data fields set correctly 45 -- otherwise they are rejected as invalid/malformed. 46 -- 47 -- # DAO::propose() 48 -- 49 -- Create a transfer proposal for the DAO 50 -- 51 -- $ drk dao propose-transfer \ 52 -- DAO_NAME \ 53 -- DURATION \ 54 -- AMOUNT \ 55 -- SENDCOIN_TOKEN_ID \ 56 -- RECV_PUBKEY 57 -- 58 -- If we don't have enough tokens to meet the proposer_limit threshold 59 -- or don't hold the proposer key, then this call will simply fail with 60 -- an error message. Nothing will be added to the database or sent to the 61 -- network. 62 -- 63 -- Once a proposal has been generated, it can be exported and shared 64 -- to other participants. 65 -- 66 -- $ drk dao proposal PROPOSAL_BULLA --export > dao_transfer_proposal.dat 67 -- $ drk dao proposal-import < dao_transfer_proposal.dat 68 -- 69 -- We can now mint the proposal on-chain 70 -- 71 -- $ drk dao proposal PROPOSAL_BULLA --mint-proposal > dao_proposal_tx 72 -- $ drk broadcast < dao_proposal_tx 73 -- 74 -- # DAO::vote() 75 -- 76 -- You have received a proposal which is active. You can now vote on it. 77 -- You will see other votes only if you hold the DAO votes view key. 78 -- 79 -- $ drk dao proposals DAO_NAME 80 -- 0. f6cae63ced53d02b372206a8d3ed5ac03fde18da306a520285fd56e8d031f6cf 81 -- 1. 1372622f4a38be6eb1c90fa67864474c6603d9f8d4228106e20e2d0d04f2395e 82 -- 2. 88b18cbc38dbd3af8d25237af3903e985f70ea06d1e25966bf98e3f08e23c992 83 -- 84 -- $ drk dao show_proposal f6cae...1f6cf 85 -- Proposal parameters 86 -- =================== 87 -- Bulla: f6cae...1f6cf 88 -- DAO Bulla: 2Wmyc...zQeke 89 -- Proposal leaf position: Position(1) 90 -- Proposal mint height: 100 91 -- Proposal transaction hash: 07148...52f96 92 -- Proposal call index: 0 93 -- Creation block window: 0 94 -- Duration: 30 (Block windows) 95 -- 96 -- Invoked contracts: 97 -- Contract: Fd8kf...z7iXj 98 -- Function: 4 99 -- Data: 100 -- Recipient: DQeQR...q31Fz 101 -- Amount: 690000000 (6.9) 102 -- Token: GY8xX...xY8Qu 103 -- Spend hook: 6iW9n...2GLuT 104 -- User data: 0x35431...e3678 105 -- Blind: 13EHb...xR6ng 106 -- 107 -- Contract: BZHKG...4yf4o 108 -- Function: 3 109 -- Data: - 110 -- 111 -- Votes: 112 -- ... 113 -- Total tokens votes: X + Y 114 -- Total tokens Yes votes: X (60%) 115 -- Total tokens No votes: Y 116 -- Voting status: Ongoing 117 -- Current proposal outcome: Rejected 118 -- 119 -- $ drk dao vote f6cae...1f6cf 1 > dao_vote_tx 120 -- $ drk broadcast < dao_vote_tx 121 -- 122 -- # DAO::exec() 123 -- 124 -- Once there are enough yes votes to satisfy the quorum and approval ratio, 125 -- then any DAO member can execute the proposal. 126 -- 127 -- $ drk dao exec f6cae...1f6cf > dao_exec_tx 128 -- $ drk broadcast < dao_exec_tx 129 130 CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos ( 131 -- Bulla identifier of the DAO 132 bulla BLOB PRIMARY KEY NOT NULL, 133 -- Unique name identifier of the DAO 134 name TEXT UNIQUE NOT NULL, 135 -- DAO parameters 136 params BLOB NOT NULL, 137 -- These values are NULL until the DAO is minted on chain and received 138 -- Leaf position of the DAO in the Merkle tree of DAOs 139 leaf_position BLOB, 140 -- Block height of the transaction this DAO was deployed 141 mint_height INTEGER, 142 -- The transaction hash where the DAO was deployed 143 tx_hash BLOB, 144 -- The call index in the transaction where the DAO was deployed 145 call_index INTEGER 146 ); 147 148 CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals ( 149 -- Bulla identifier of the proposal 150 bulla BLOB PRIMARY KEY NOT NULL, 151 -- Bulla identifier of the DAO this proposal is for 152 dao_bulla BLOB NOT NULL, 153 -- The on chain representation of the proposal 154 proposal BLOB NOT NULL, 155 -- Plaintext proposal call data the members share between them 156 data BLOB, 157 -- These values are NULL until the proposal is minted on chain and received 158 -- Leaf position of the proposal in the Merkle tree of proposals 159 leaf_position BLOB, 160 -- Money merkle tree snapshot for reproducing the snapshot Merkle root 161 money_snapshot_tree BLOB, 162 -- Money nullifiers SMT snapshot for reproducing the snapshot Merkle root 163 nullifiers_smt_snapshot BLOB, 164 -- Block height of the transaction this proposal was deployed 165 mint_height INTEGER, 166 -- The transaction hash where the proposal was deployed 167 tx_hash BLOB, 168 -- The call index in the transaction where the proposal was deployed 169 call_index INTEGER, 170 -- Block height of the transaction this proposal was executed on chain 171 exec_height INTEGER, 172 -- The transaction hash where the proposal is executed on chain 173 exec_tx_hash BLOB, 174 175 FOREIGN KEY(dao_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos(bulla) ON DELETE CASCADE ON UPDATE CASCADE 176 ); 177 178 CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_votes ( 179 -- Numeric identifier of the vote 180 vote_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 181 -- Bulla identifier of the proposal this vote is for 182 proposal_bulla BLOB NOT NULL, 183 -- The vote 184 vote_option INTEGER NOT NULL, 185 -- Blinding factor for the yes vote 186 yes_vote_blind BLOB NOT NULL, 187 -- Value of all votes 188 all_vote_value BLOB NOT NULL, 189 -- Blinding facfor of all votes 190 all_vote_blind BLOB NOT NULL, 191 -- Block height of the transaction this vote was casted 192 block_height INTEGER NOT NULL, 193 -- Transaction hash where this vote was casted 194 tx_hash BLOB NOT NULL, 195 -- Call index in the transaction where this vote was casted 196 call_index INTEGER NOT NULL, 197 -- Vote input nullifiers 198 nullifiers BLOB NOT NULL, 199 200 FOREIGN KEY(proposal_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals(bulla) ON DELETE CASCADE ON UPDATE CASCADE 201 );