dao.sql 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 transaction hash: 07148...52f96
  91. -- Proposal call index: 0
  92. -- Creation block window: 0
  93. -- Duration: 30 (Block windows)
  94. --
  95. -- Invoked contracts:
  96. -- Contract: Fd8kf...z7iXj
  97. -- Function: 4
  98. -- Data:
  99. -- Recipient: DQeQR...q31Fz
  100. -- Amount: 690000000 (6.9)
  101. -- Token: GY8xX...xY8Qu
  102. -- Spend hook: 6iW9n...2GLuT
  103. -- User data: 0x35431...e3678
  104. -- Blind: 13EHb...xR6ng
  105. --
  106. -- Contract: BZHKG...4yf4o
  107. -- Function: 3
  108. -- Data: -
  109. --
  110. -- Votes:
  111. -- ...
  112. -- Total tokens votes: X + Y
  113. -- Total tokens Yes votes: X (60%)
  114. -- Total tokens No votes: Y
  115. -- Voting status: Ongoing
  116. -- Current proposal outcome: Rejected
  117. --
  118. -- $ drk dao vote f6cae...1f6cf 1 > dao_vote_tx
  119. -- $ drk broadcast < dao_vote_tx
  120. --
  121. -- # DAO::exec()
  122. --
  123. -- Once there are enough yes votes to satisfy the quorum and approval ratio,
  124. -- then any DAO member can execute the proposal.
  125. --
  126. -- $ drk dao exec f6cae...1f6cf > dao_exec_tx
  127. -- $ drk broadcast < dao_exec_tx
  128. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos (
  129. -- Bulla identifier of the DAO
  130. bulla BLOB PRIMARY KEY NOT NULL,
  131. -- Unique name identifier of the DAO
  132. name TEXT UNIQUE NOT NULL,
  133. -- DAO parameters
  134. params BLOB NOT NULL,
  135. -- These values are NULL until the DAO is minted on chain and received
  136. -- Leaf position of the DAO in the Merkle tree of DAOs
  137. leaf_position BLOB,
  138. -- The transaction hash where the DAO was deployed
  139. tx_hash BLOB,
  140. -- The call index in the transaction where the DAO was deployed
  141. call_index INTEGER
  142. );
  143. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals (
  144. -- Bulla identifier of the proposal
  145. bulla BLOB PRIMARY KEY NOT NULL,
  146. -- Bulla identifier of the DAO this proposal is for
  147. dao_bulla BLOB NOT NULL,
  148. -- The on chain representation of the proposal
  149. proposal BLOB NOT NULL,
  150. -- Plaintext proposal call data the members share between them
  151. data BLOB,
  152. -- These values are NULL until the proposal is minted on chain and received
  153. -- Leaf position of the proposal in the Merkle tree of proposals
  154. leaf_position BLOB,
  155. -- Money merkle tree snapshot for reproducing the snapshot Merkle root
  156. money_snapshot_tree BLOB,
  157. -- Money nullifiers SMT snapshot for reproducing the snapshot Merkle root
  158. nullifiers_smt_snapshot BLOB,
  159. -- The transaction hash where the proposal was deployed
  160. tx_hash BLOB,
  161. -- The call index in the transaction where the proposal was deployed
  162. call_index INTEGER,
  163. -- This value is NULL until the proposal is executed on chain and received
  164. exec_tx_hash BLOB,
  165. FOREIGN KEY(dao_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos(bulla) ON DELETE CASCADE ON UPDATE CASCADE
  166. );
  167. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_votes (
  168. -- Numeric identifier of the vote
  169. vote_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  170. -- Bulla identifier of the proposal this vote is for
  171. proposal_bulla BLOB NOT NULL,
  172. -- The vote
  173. vote_option INTEGER NOT NULL,
  174. -- Blinding factor for the yes vote
  175. yes_vote_blind BLOB NOT NULL,
  176. -- Value of all votes
  177. all_vote_value BLOB NOT NULL,
  178. -- Blinding facfor of all votes
  179. all_vote_blind BLOB NOT NULL,
  180. -- Transaction hash where this vote was casted
  181. tx_hash BLOB NOT NULL,
  182. -- Call index in the transaction where this vote was casted
  183. call_index INTEGER NOT NULL,
  184. -- Vote input nullifiers
  185. nullifiers BLOB NOT NULL,
  186. FOREIGN KEY(proposal_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals(bulla) ON DELETE CASCADE ON UPDATE CASCADE
  187. );