Cardano Example Dapp
Multi Stake Delegation
Funds 3 addresses of a 'demos' workspace and delegates their stake keys to 3 pools in one transaction. Run it before 'Multi Stake Withdrawal
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": "Multi Stake Delegation",
"description": "Funds 3 addresses of a 'demos' workspace and delegates their stake keys to 3 pools in one transaction. Run it before 'Multi Stake Withdrawal",
"require": {
"not": {
"walletTypeIn": [
"extension"
]
}
},
"exportAs": "MultiDelegationDemo",
"return": {
"mode": "last"
},
"args": {
"pool-a": "bd24b3372791f401cc029455c44ea77f3c8750ce3b804a354af0ff16",
"pool-a-ticker": "PEACE",
"pool-b": "8fa4537044c02b232430dca78f51ca74c22d1ed7fb990be8b65d2794",
"pool-b-ticker": "WHITE",
"pool-c": "d71613e6097382e4d522fb17cff10b6c8bbe8575521ae174ba506c70",
"pool-c-ticker": "DRMZ",
"quantity": "10000000"
},
"run": {
"guards": {
"type": "macro",
"run": "{assert(and(eq(get('args.pool-a'),truncate(get('args.pool-a'),56,0,'')),eq(get('args.pool-b'),truncate(get('args.pool-b'),56,0,'')),eq(get('args.pool-c'),truncate(get('args.pool-c'),56,0,''))),'invalid args')}"
},
"walletSetup": {
"type": "loadConfig",
"updateId": "{uuid()}",
"layers": [
{
"type": "Workspace",
"items": [
{
"namePattern": "demos",
"titlePattern": "Demos",
"descriptionPattern": "Example workspace"
}
]
},
{
"type": "Key",
"workspaceIds": [
"demos"
],
"items": [
{
"namePattern": "SpendKey-0",
"kind": "spend",
"accountIndex": 5,
"addressIndex": 92
},
{
"namePattern": "StakeKey-A",
"kind": "stake",
"accountIndex": 34,
"addressIndex": 423
},
{
"namePattern": "StakeKey-B",
"kind": "stake",
"accountIndex": 632,
"addressIndex": 7434
},
{
"namePattern": "StakeKey-C",
"kind": "stake",
"accountIndex": 26,
"addressIndex": 754
}
]
},
{
"type": "Address",
"workspaceIds": [
"demos"
],
"items": [
{
"namePattern": "Address-0A",
"spendPubKeyName": "SpendKey-0",
"stakePubKeyName": "StakeKey-A"
},
{
"namePattern": "Address-0B",
"spendPubKeyName": "SpendKey-0",
"stakePubKeyName": "StakeKey-B"
},
{
"namePattern": "Address-0C",
"spendPubKeyName": "SpendKey-0",
"stakePubKeyName": "StakeKey-C"
},
{
"namePattern": "RewardAddress-A",
"stakePubKeyName": "StakeKey-A"
},
{
"namePattern": "RewardAddress-B",
"stakePubKeyName": "StakeKey-B"
},
{
"namePattern": "RewardAddress-C",
"stakePubKeyName": "StakeKey-C"
}
]
}
]
},
"setWorkspace": {
"type": "setCurrentWorkspace",
"workspaceId": "demos"
},
"keys": {
"type": "getPublicKeys",
"keyPattern": "{artifactName}"
},
"addresses": {
"type": "getAddresses",
"keyPattern": "{artifactName}"
},
"regA": {
"type": "certificate",
"cert": {
"kind": "StakeRegistration",
"pubKeyHashHex": "{get('cache.keys.StakeKey-A.pubKeyHashHex')}"
}
},
"regB": {
"type": "certificate",
"cert": {
"kind": "StakeRegistration",
"pubKeyHashHex": "{get('cache.keys.StakeKey-B.pubKeyHashHex')}"
}
},
"regC": {
"type": "certificate",
"cert": {
"kind": "StakeRegistration",
"pubKeyHashHex": "{get('cache.keys.StakeKey-C.pubKeyHashHex')}"
}
},
"delA": {
"type": "certificate",
"cert": {
"kind": "StakeDelegation",
"pubKeyHashHex": "{get('cache.keys.StakeKey-A.pubKeyHashHex')}",
"poolKeyHashHex": "{get('args.pool-a')}"
}
},
"delB": {
"type": "certificate",
"cert": {
"kind": "StakeDelegation",
"pubKeyHashHex": "{get('cache.keys.StakeKey-B.pubKeyHashHex')}",
"poolKeyHashHex": "{get('args.pool-b')}"
}
},
"delC": {
"type": "certificate",
"cert": {
"kind": "StakeDelegation",
"pubKeyHashHex": "{get('cache.keys.StakeKey-C.pubKeyHashHex')}",
"poolKeyHashHex": "{get('args.pool-c')}"
}
},
"build": {
"type": "buildTx",
"title": "{join('','🚀 Delegate to ',get('args.pool-a-ticker'),',',get('args.pool-b-ticker'),' and ',get('args.pool-c-ticker'))}",
"tx": {
"outputs": [
{
"address": "{get('cache.addresses.Address-0A.address')}",
"assets": [
{
"policyId": "ada",
"assetName": "ada",
"quantity": "{get('args.quantity')}"
}
]
},
{
"address": "{get('cache.addresses.Address-0B.address')}",
"assets": [
{
"policyId": "ada",
"assetName": "ada",
"quantity": "{get('args.quantity')}"
}
]
},
{
"address": "{get('cache.addresses.Address-0C.address')}",
"assets": [
{
"policyId": "ada",
"assetName": "ada",
"quantity": "{get('args.quantity')}"
}
]
}
],
"certificates": [
{
"certHex": "{get('cache.regA')}"
},
{
"certHex": "{get('cache.regB')}"
},
{
"certHex": "{get('cache.regC')}"
},
{
"certHex": "{get('cache.delA')}"
},
{
"certHex": "{get('cache.delB')}"
},
{
"certHex": "{get('cache.delC')}"
}
],
"options": {
"autoClean": {
"certReRegistrations": true
}
}
}
},
"sign": {
"type": "signTxs",
"detailedPermissions": false,
"txs": [
"{get('cache.build.txHex')}"
]
},
"submit": {
"type": "submitTxs",
"txs": "{get('cache.sign')}"
},
"finally": {
"type": "macro",
"run": "{get('cache.build.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
