Cardano Example Dapp
Kobayashi Maru Multi Signing Demo
Demo that tries to sign 3 transactions with unobtainable foreign keys and internal spending and staking private keys
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):
{
"title": "Kobayashi Maru Multi Signing Demo",
"description": "Demo that tries to sign 3 transactions with unobtainable foreign keys and internal spending and staking private keys",
"type": "script",
"require": {
"not": {
"walletTypeIn": [
"burner",
"gift"
]
}
},
"returnURLPattern": "http://localhost:3000/demo/api/dapp",
"exportAs": "MultiSig",
"run": {
"dependencies": {
"type": "script",
"return": {
"mode": "some",
"keys": [
"mainSpendKeyHash",
"mainStakeKeyHash",
"currentSpendKeyHash",
"currentStakeKeyHash",
"internalMintingPolicy",
"externalMintingPolicy",
"externalMintingKeyHash"
]
},
"run": {
"mainAddress": {
"type": "getMainAddress"
},
"currentAddress": {
"type": "getCurrentAddress"
},
"mainAddressInfo": {
"type": "macro",
"run": "{getAddressInfo(get('cache.dependencies.mainAddress'))}"
},
"currentAddressInfo": {
"type": "macro",
"run": "{getAddressInfo(get('cache.dependencies.currentAddress'))}"
},
"mainRewardAddress": {
"type": "macro",
"run": "{get('cache.dependencies.mainAddressInfo.rewardAddress')}"
},
"currentRewardAddress": {
"type": "macro",
"run": "{get('cache.dependencies.currentAddressInfo.rewardAddress')}"
},
"mainSpendKeyHash": {
"type": "macro",
"run": "{get('cache.dependencies.mainAddressInfo.paymentKeyHash')}"
},
"mainStakeKeyHash": {
"type": "macro",
"run": "{get('cache.dependencies.mainAddressInfo.stakingKeyHash')}"
},
"currentSpendKeyHash": {
"type": "macro",
"run": "{get('cache.dependencies.currentAddressInfo.paymentKeyHash')}"
},
"currentStakeKeyHash": {
"type": "macro",
"run": "{get('cache.dependencies.currentAddressInfo.stakingKeyHash')}"
},
"internalMintingPolicy": {
"type": "nativeScript",
"script": {
"all": [
{
"any": [
{
"pubKeyHashHex": "{get('cache.dependencies.currentSpendKeyHash')}"
},
{
"pubKeyHashHex": "{get('cache.dependencies.currentStakeKeyHash')}"
},
{
"scriptHex": "8200581ca8f97104c6b8cc5d197fe136d813e92d8ce417bfa2df44b43331f5fc"
}
]
},
{
"atLeast": 1,
"ofThese": [
{
"pubKeyHashHex": "{get('cache.dependencies.mainSpendKeyHash')}"
},
{
"pubKeyHashHex": "{get('cache.dependencies.mainStakeKeyHash')}"
},
{
"scriptHex": "8200581ca8f97104c6b8cc5d197fe136d813e92d8ce417bfa2df44b43331f5fc"
}
]
}
]
}
},
"externalMintingKeyHash": {
"type": "data",
"value": "a8f97104c6b8cc5d197fe136d813e92d8ce417bfa2df44b43331f5fc"
},
"externalMintingPolicy": {
"type": "data",
"value": {
"scriptHex": "8200581ca8f97104c6b8cc5d197fe136d813e92d8ce417bfa2df44b43331f5fc",
"scriptHashHex": "dfd9b9d7cd005ac4cff664fbf53d5ecaa91b0141e9290f4dadc92cb4",
"scriptRefHex": "d818582282008200581ca8f97104c6b8cc5d197fe136d813e92d8ce417bfa2df44b43331f5fc"
}
}
}
},
"build": {
"type": "script",
"run": {
"withAllKeys": {
"type": "buildTx",
"tx": {
"outputs": {
"toExternalWallet": {
"address": "addr1q9faamq9k6557gve35amtdqph99h9q2txhz07chaxg6uwwgd6j6v0fc04n5ehg292yxvs292vesrqqmxqfnp7yuwn7yqczuqwr",
"assets": [
{
"assetName": "IOwnThisKeys",
"policyId": "{get('cache.dependencies.internalMintingPolicy.scriptHashHex')}",
"quantity": "2"
},
{
"assetName": "IDoNotOwnThisKeys",
"policyId": "{get('cache.dependencies.externalMintingPolicy.scriptHashHex')}",
"quantity": "2"
}
]
}
},
"mints": [
{
"policyId": "{get('cache.dependencies.internalMintingPolicy.scriptHashHex')}",
"assets": [
{
"assetName": "IOwnThisKeys",
"quantity": "10"
}
]
},
{
"policyId": "{get('cache.dependencies.externalMintingPolicy.scriptHashHex')}",
"assets": [
{
"assetName": "IDoNotOwnThisKeys",
"quantity": "10"
}
]
}
],
"witnesses": {
"nativeScripts": {
"internalMintingPolicyScript": "{get('cache.dependencies.internalMintingPolicy.scriptHex')}",
"externalMintingPolicyScript": "{get('cache.dependencies.externalMintingPolicy.scriptHex')}"
}
},
"optionalSigners": {
"externalMintingKeyHash": "{get('cache.dependencies.externalMintingKeyHash')}",
"mainSpendKeyHash": "{get('cache.dependencies.mainSpendKeyHash')}",
"mainStakeKeyHash": "{get('cache.dependencies.mainStakeKeyHash')}",
"currentSpendKeyHash": "{get('cache.dependencies.currentSpendKeyHash')}",
"currentStakeKeyHash": "{get('cache.dependencies.currentStakeKeyHash')}"
}
}
},
"withSpendingKeys": {
"type": "buildTx",
"tx": {
"requiredSigners": {
"mainSpendKeyHash": "{get('cache.dependencies.mainSpendKeyHash')}",
"currentSpendKeyHash": "{get('cache.dependencies.currentSpendKeyHash')}"
}
}
},
"withStakingKeys": {
"type": "buildTx",
"tx": {
"requiredSigners": {
"mainStakeKeyHash": "{get('cache.dependencies.mainStakeKeyHash')}",
"currentStakeKeyHash": "{get('cache.dependencies.currentStakeKeyHash')}"
}
}
}
}
},
"sign": {
"type": "signTxs",
"namePattern": "InternalMultiSig-{key}",
"extras": true,
"txs": "{\n getArray(\n get('cache.build.withAllKeys.txHex'),\n get('cache.build.withSpendingKeys.txHex'),\n get('cache.build.withStakingKeys.txHex'),\n )\n\n }",
"detailedPermissions": false
},
"submit": {
"type": "submitTxs",
"mode": "later",
"namePattern": "MultiSig-{key}",
"txs": "{get('cache.sign.txList')}"
}
}
}
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
