Cardano Example Dapp
Shared Treasury - 3 of 4 signers - funded - Gift Wallets
Creates a workspace named 'DAO' with a 'Shared Treasury' address where at least 3 of 4 signer Gift wallets are required for spending and staking operations. A second address on the workspace is caller main address as 'Signer'. To manage the treasury set 'Shared Treasury' address as current. To sign as a member, set 'Signer' address instead. Customize Gift Wallet generation with proper password settings and distribute them to the signers. This example is not secure as wallet creator has total control over the generated wallets. Please use 'saveConfig' function to save this setup on GCFS to avoid losing funds and data
Try it online:
- Visit HTML+JS Dapp
- Visit HTML+React Dapp
- Visit Native HTML dapp
- Run Run in Wallet…Open in IDE…
Source code:
- dapp connection code: GCScript DSL
- frontend (using @gamechanger-finance/gc): HTML+JS dapp
- frontend (using @gamechanger-finance/gc): HTML+React dapp
- frontend (without official library): Native HTML dapp
Dapp code was autogenerated by Playground IDE in GameChanger Wallet
GCScript code (dapp connection):
{
"type": "script",
"title": "Shared Treasury - 3 of 4 signers - funded - Gift Wallets",
"description": "Creates a workspace named 'DAO' with a 'Shared Treasury' address where at least 3 of 4 signer Gift wallets are required for spending and staking operations. A second address on the workspace is caller main address as 'Signer'. To manage the treasury set 'Shared Treasury' address as current. To sign as a member, set 'Signer' address instead. Customize Gift Wallet generation with proper password settings and distribute them to the signers. This example is not secure as wallet creator has total control over the generated wallets. Please use 'saveConfig' function to save this setup on GCFS to avoid losing funds and data",
"exportAs": "Dao",
"return": {
"mode": "last"
},
"run": {
"wallets": {
"type": "walletGenerator",
"amount": 4,
"defaultNamePattern": "Member {index}",
"defaultDescriptionPattern": "Wallet for DAO Member #{index}",
"defaultKeyPattern": "Member_{index}",
"defaultHintPattern": "Your password is '{password}'",
"qr": true,
"download": true,
"extra": true
},
"walletSetup": {
"type": "loadConfig",
"updateId": "Dao",
"layers": [
{
"type": "Workspace",
"items": [
{
"namePattern": "dao",
"titlePattern": "DAO",
"descriptionPattern": "Wallet settings that creates a shared treasury of at least 3 of 4 signers for spending and staking operations"
}
]
},
{
"type": "Key",
"workspaceIds": [
"dao"
],
"items": [
{
"namePattern": "spend-member",
"kind": "spend",
"accountIndex": 0,
"addressIndex": 0
},
{
"namePattern": "stake-member",
"kind": "stake",
"accountIndex": 0,
"addressIndex": 0
}
]
},
{
"type": "NativeScript",
"workspaceIds": [
"dao"
],
"namePattern": "dao_{key}_script",
"items": {
"spend": {
"atLeast": 3,
"ofThese": {
"Member_0": {
"pubKeyHashHex": "{get('cache.wallets.Member_0.spendKeyHashHex')}"
},
"Member_1": {
"pubKeyHashHex": "{get('cache.wallets.Member_1.spendKeyHashHex')}"
},
"Member_2": {
"pubKeyHashHex": "{get('cache.wallets.Member_2.spendKeyHashHex')}"
},
"Member_3": {
"pubKeyHashHex": "{get('cache.wallets.Member_3.spendKeyHashHex')}"
}
}
},
"stake": {
"atLeast": 3,
"ofThese": {
"Member_0": {
"pubKeyHashHex": "{get('cache.wallets.Member_0.stakeKeyHashHex')}"
},
"Member_1": {
"pubKeyHashHex": "{get('cache.wallets.Member_1.stakeKeyHashHex')}"
},
"Member_2": {
"pubKeyHashHex": "{get('cache.wallets.Member_2.stakeKeyHashHex')}"
},
"Member_3": {
"pubKeyHashHex": "{get('cache.wallets.Member_3.stakeKeyHashHex')}"
}
}
}
}
},
{
"type": "Address",
"workspaceIds": [
"dao"
],
"items": [
{
"namePattern": "Signer",
"spendPubKeyName": "spend-member",
"stakePubKeyName": "stake-member"
},
{
"namePattern": "Shared Treasury",
"spendNativeScriptName": "dao_spend_script",
"stakeNativeScriptName": "dao_stake_script"
}
]
}
]
},
"setWorkspace": {
"type": "setCurrentWorkspace",
"workspaceId": "dao"
},
"workspaceAddresses": {
"type": "getAddresses",
"filter": {
"name": "Shared Treasury"
},
"keyPattern": "dao_address"
},
"assets": {
"type": "data",
"value": [
{
"policyId": "ada",
"assetName": "ada",
"quantity": "10000000"
}
]
},
"buildAirdrop": {
"type": "buildTx",
"title": "💝 DAO Airdrop",
"returnURLPattern": "https://github.com/GameChangerFinance/gamechanger.wallet/blob/main/examples/Shared%20Treasury%20-%203%20of%204%20signers%20-%20funded%20-%20Gift%20Wallets.md",
"tx": {
"outputs": [
{
"address": "{get('cache.workspaceAddresses.dao_address.address')}",
"assets": "{get('cache.assets')}"
}
],
"auxiliaryData": {
"674": {
"msg": [
"Welcome to The Future of Cardano!\n",
"Multisigs in the palm of your hand\n",
"By GameChanger Wallet\n"
]
}
}
}
},
"signAirdrop": {
"type": "signTxs",
"txs": [
"{get('cache.buildAirdrop.txHex')}"
],
"detailedPermissions": false
},
"submitAirdrop": {
"type": "submitTxs",
"txs": "{get('cache.signAirdrop')}"
},
"finally": {
"type": "macro",
"run": {
"signers": "{get('cache.wallets')}",
"sharedTreasuryAddress": "{get('cache.workspaceAddresses.dao_address.address')}",
"airdropTxHash": "{get('cache.buildAirdrop.txHash')}"
}
}
}
}
Run standalone QR dapp connection:
You can use Playground IDE in GameChanger Wallet in QR URL Transport mode to capture results
Resources
- How to connect?
- Docs and examples on Github
- GCScript documentation
- Playground IDE in GameChanger Wallet
- Tutorials on Youtube
- Support on Discord
- News on Twitter
- Website
License
MIT
