dao.sql 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos (
  130. -- Bulla identifier of the DAO
  131. bulla BLOB PRIMARY KEY NOT NULL,
  132. -- Unique name identifier of the DAO
  133. name TEXT UNIQUE NOT NULL,
  134. -- DAO parameters
  135. params BLOB NOT NULL,
  136. -- These values are NULL until the DAO is minted on chain and received
  137. -- Leaf position of the DAO in the Merkle tree of DAOs
  138. leaf_position BLOB,
  139. -- Block height of the transaction this DAO was deployed
  140. mint_height INTEGER,
  141. -- The transaction hash where the DAO was deployed
  142. tx_hash BLOB,
  143. -- The call index in the transaction where the DAO was deployed
  144. call_index INTEGER
  145. );
  146. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals (
  147. -- Bulla identifier of the proposal
  148. bulla BLOB PRIMARY KEY NOT NULL,
  149. -- Bulla identifier of the DAO this proposal is for
  150. dao_bulla BLOB NOT NULL,
  151. -- The on chain representation of the proposal
  152. proposal BLOB NOT NULL,
  153. -- Plaintext proposal call data the members share between them
  154. data BLOB,
  155. -- These values are NULL until the proposal is minted on chain and received
  156. -- Leaf position of the proposal in the Merkle tree of proposals
  157. leaf_position BLOB,
  158. -- Money merkle tree snapshot for reproducing the snapshot Merkle root
  159. money_snapshot_tree BLOB,
  160. -- Money nullifiers SMT snapshot for reproducing the snapshot Merkle root
  161. nullifiers_smt_snapshot BLOB,
  162. -- Block height of the transaction this proposal was deployed
  163. mint_height INTEGER,
  164. -- The transaction hash where the proposal was deployed
  165. tx_hash BLOB,
  166. -- The call index in the transaction where the proposal was deployed
  167. call_index INTEGER,
  168. -- Block height of the transaction this proposal was executed on chain
  169. exec_height INTEGER,
  170. -- The transaction hash where the proposal is executed on chain
  171. exec_tx_hash BLOB,
  172. FOREIGN KEY(dao_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_daos(bulla) ON DELETE CASCADE ON UPDATE CASCADE
  173. );
  174. CREATE TABLE IF NOT EXISTS Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_votes (
  175. -- Numeric identifier of the vote
  176. vote_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  177. -- Bulla identifier of the proposal this vote is for
  178. proposal_bulla BLOB NOT NULL,
  179. -- The vote
  180. vote_option INTEGER NOT NULL,
  181. -- Blinding factor for the yes vote
  182. yes_vote_blind BLOB NOT NULL,
  183. -- Value of all votes
  184. all_vote_value BLOB NOT NULL,
  185. -- Blinding facfor of all votes
  186. all_vote_blind BLOB NOT NULL,
  187. -- Block height of the transaction this vote was casted
  188. block_height INTEGER NOT NULL,
  189. -- Transaction hash where this vote was casted
  190. tx_hash BLOB NOT NULL,
  191. -- Call index in the transaction where this vote was casted
  192. call_index INTEGER NOT NULL,
  193. -- Vote input nullifiers
  194. nullifiers BLOB NOT NULL,
  195. FOREIGN KEY(proposal_bulla) REFERENCES Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj_dao_proposals(bulla) ON DELETE CASCADE ON UPDATE CASCADE
  196. );