Emerald DAO

Summary

Emerald DAO is a simple Bitcoin Cash DAO template which acts as a fixed-term deposit savings vault with optional crowdfunded rewards scheme. Each depositor interacting with the DAO will be creating a time-locked safebox UTXO and a matching keycard NFT UTXO. Upon expiry of the time-lock, user will have the option to burn the keycard NFT UTXO to open the safebox and access the deposited BCH + holding reward, or he may keep the keycard NFT indefinitely as a collectible.

Technical Description

The DAO template consists of 3 contracts labeled "blueprint", "vault", and "safebox". The "blueprint" contract will be placed on a pure index-0 BCH UTXO which will be consumed to create the genesis transaction. The genesis transaction will create exactly one NFT with "minting" capability and lock it with the "vault" contract, which is a recursive covenant. Users will interact with the "vault" contract to create pairs of immutable NFTs:

  • Immutable NFT, sent to the "safebox" contract, which will store the user's BCH deposit;
  • Immutable "keycard" NFT, sent to the user's funding address, which may later (upon expiry of time-lock) be burned to unlock the matching "safebox" contract.

We illustrate the DAO's operation with the figure below.

It demonstrates a few contract-building patterns:

  • "pre-genesis covenant" - requires correct setup of token genesis and creates the main covenant, it is also used to reveal preimages of child contracts.
  • deposits are serial - by respending the main covenant, which keeps track of the number of minted NFTs
  • state sharding - the main covenant emits NFT receipts with one-time covenants to hold user deposits, the NFTs are coded to match with a P2PKH "keycard" NFT
  • NFT-owned UTXO (safebox contract requires a matching P2PKH NFT to be spent in same TX)
  • async/parallel withdrawals - user deposits are each in their own UTXO, so everyone can redeem whenever (after the timelock expires) with no contention with other users

Source Code

Version 2.1.0

The 3 contracts are written in CashScript:

BitAuthIDE template testing all spending paths of the compiled bytecode is available here.

Deployments

Version 2.1.0 - Bitcoin Cash May 2023 Upgrade Day Celebration Instance

DAO Genesis TX was mined as the 1st TX in the 1st upgraded block (792773), with an OP_RETURN message: "Happy Bitcoin Cash May 2023 Upgrade Day!".

Main parameters:

  • Maximum number of safebox NFTs: 2000
  • Initial rewards pool: 2.14556600 (+0.00102277 bonus / NFT)
  • Minting possible until: June 15th 2023
  • Safeboxes unlock at: May 15th 2024

Community sites:

Tests

Version 2.1.0 - Chipnet

DAO instance contracts:

  • Blueprint contract address: https://chipnet.imaginary.cash/address/bchtest:prqd82cxtdfgss8x0ffe7h6qwyg9c9vjtcjgdjvszy (sha256 of static "tail" part of redeem script bytecode: c2ac9207655ecca85dcdc3c0fae33233a719afcf40a92a41e02911bce41ede1c)
  • Vault contract address: https://chipnet.imaginary.cash/address/bchtest:pzdh0j90jl7f4xpjmr5x5676czug7lsc4cwtqk736l (sha256 of static "tail" part of redeem script bytecode: f1e36e373a10be68444155b0bd4ef81f8d1973693534c129cb19f451a9a94fe7)
  • Safebox contract address: https://chipnet.imaginary.cash/address/bchtest:pz4s5whwpzrxrqa065n8jva8pzdv44hx9qepr7u0st (sha256 of static "tail" part of redeem script bytecode: 09b65c077a62fe065580ee949ab77a695ff82806915fc1b3237f0c34e96f7f26)

DAO configuration (from configured BitauthIDE template):

    "dao_config_data": {
      "data": {
        "bytecode": {
          "dao_config_dust_limit": "800",
          "dao_config_fee_allowance": "1600",
          "dao_config_safebox_nominal_value": "1000000",
          "dao_config_rewards_minimum_increment": "1000000",
          "dao_config_executor_fee": "1000000",
          "dao_config_max_safeboxes": "2000",
          "dao_config_vault_close_time": "1684430000",
          "dao_config_safebox_open_time": "1684431000",
          "dao_config_rewards_remainder_beneficiary": "0x76a914586f33d3cd763ec12ea1829ad834c6e3d345131b88ac"
        }
      },
      "description": "DAO configuration data, required to build Vault and Safebox locking bytecodes.",
      "name": ""
    },
    "dao_genesis_blueprint_data": {
      "data": {
        "bytecode": {
          "genesis_executor_fee": "500000",
          "genesis_bcmr_output_bytecode": "0x76a914e11bc0b45edb8c7caca8b63f4d02eca619dbc23088ac",
          "genesis_message": "'Happy Bitcoin Cash May 2023 upgrade day!'",
          "genesis_designer_pubkey": "designer_key.public_key"
        }
      },
      "description": "DAO genesis blueprint data, required to build Blueprint locking bytecode.",
      "extends": "dao_config_data",
      "name": ""
    },

DAO "Vault" transactions:

  • Genesis transaction: https://chipnet.imaginary.cash/tx/0df6cfd62fdc314fd40c07425296372069e1b96606439e3096925615449dea68
  • Mint No. 1 - locking up exactly the nominal amount + bonus: https://chipnet.imaginary.cash/tx/093bf4536a89fb8d340d4cc0099e9bd1431d42d6d9722cfd635a8a498f40c763
  • Mint No. 2 - same: https://chipnet.imaginary.cash/tx/6afeb2a173e8e8b612653307c2a263415aa31df08f29866a0fb350a987f956cf
  • Mint No. 3 - user adds his own extra to the safebox: https://chipnet.imaginary.cash/tx/dc6ca48ee3e3a43b0d84ae51b2eeb8b25abcaa7ca37b943fde1c62ff7e1344fa
  • Mint No. 4 - user gives up the bonus (vault amount not changed) and locks up exactly the nominal amount: https://chipnet.imaginary.cash/tx/dc6ca48ee3e3a43b0d84ae51b2eeb8b25abcaa7ca37b943fde1c62ff7e1344fa
  • Mint No. 5 - user locks exactly the nominal amount, while adding a little to DAO's reward pool: https://chipnet.imaginary.cash/tx/dc6ca48ee3e3a43b0d84ae51b2eeb8b25abcaa7ca37b943fde1c62ff7e1344fa

User P2PKH transactions:

  • User transfers No. 2 (p2pkh): https://chipnet.imaginary.cash/tx/716f5ccd31fdd67390dd78b3c04d4d3d180a67c36df772ab16ed263b2847753d

DAO "Safebox" transactions:

  • Withdraw No. 2 - user burns his No. 2 keycard NFT with the matching "safebox" NFT to withdraw from the DAO: https://chipnet.imaginary.cash/tx/f8c34d51bbaf8109de3d543986a71032fa4f88b6329aca7f731d34c79bd77410

License

MIT No Attribution.

Disclaimer

THE DAO CONTRACT, THE DAO INSTANCE(S), AND RELATED SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.