Cardano Example Dapp
CIP-8 Data Signing and Encrypting Demo
Demo that signs data with main and current addresses and their associated reward ones, verifies the signatures and encrypt and decrypt the data using the signatures. Run 'Wallet Setup Demo' or create some Workspaces first and switch current addresses to test it out
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": "CIP-8 Data Signing and Encrypting Demo",
"description": "Demo that signs data with main and current addresses and their associated reward ones, verifies the signatures and encrypt and decrypt the data using the signatures. Run 'Wallet Setup Demo' or create some Workspaces first and switch current addresses to test it out",
"require": {
"not": {
"walletTypeIn": [
"burner",
"gift"
]
}
},
"type": "script",
"returnURLPattern": "http://localhost:3000/demo/api/dapp",
"run": {
"dependencies": {
"type": "script",
"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')}"
},
"data": {
"type": "data",
"value": "🚀 Hello World of CIP-8 data signing!"
},
"dataHex": {
"type": "macro",
"run": "{strToHex(get('cache.dependencies.data'))}"
}
}
},
"data": {
"type": "script",
"exportAs": "InputData",
"run": {
"data": {
"type": "macro",
"run": "{get('cache.dependencies.data')}"
},
"dataHex": {
"type": "macro",
"run": "{get('cache.dependencies.dataHex')}"
}
}
},
"usingMainAddress": {
"type": "script",
"exportAs": "UsingMainAddress",
"run": {
"address": {
"type": "macro",
"run": "{get('cache.dependencies.mainAddress')}"
},
"sign": {
"type": "signDataWithAddress",
"address": "{get('cache.usingMainAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}"
},
"verify": {
"type": "verifySignatureWithAddress",
"address": "{get('cache.usingMainAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}",
"dataSignature": "{get('cache.usingMainAddress.sign')}"
},
"encryptedHex": {
"type": "encrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to encrypt this message",
"weak": true,
"default": "{get('cache.usingMainAddress.sign.signature')}"
},
"messageHex": "{get('cache.dependencies.dataHex')}"
},
"decryptedHex": {
"type": "decrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to decrypt this message",
"weak": true,
"default": "{get('cache.usingMainAddress.sign.signature')}"
},
"encryptedMessageHex": "{get('cache.usingMainAddress.encryptedHex')}"
}
}
},
"usingMainRewardAddress": {
"type": "script",
"exportAs": "UsingMainRewardAddress",
"run": {
"address": {
"type": "macro",
"run": "{get('cache.dependencies.mainRewardAddress')}"
},
"sign": {
"type": "signDataWithAddress",
"address": "{get('cache.usingMainRewardAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}"
},
"verify": {
"type": "verifySignatureWithAddress",
"address": "{get('cache.usingMainRewardAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}",
"dataSignature": "{get('cache.usingMainRewardAddress.sign')}"
},
"encryptedHex": {
"type": "encrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to encrypt this message",
"weak": true,
"default": "{get('cache.usingMainRewardAddress.sign.signature')}"
},
"messageHex": "{get('cache.dependencies.dataHex')}"
},
"decryptedHex": {
"type": "decrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to encrypt this message",
"weak": true,
"default": "{get('cache.usingMainRewardAddress.sign.signature')}"
},
"encryptedMessageHex": "{get('cache.usingMainRewardAddress.encryptedHex')}"
}
}
},
"usingCurrentAddress": {
"type": "script",
"exportAs": "UsingCurrentAddress",
"run": {
"address": {
"type": "macro",
"run": "{get('cache.dependencies.currentAddress')}"
},
"sign": {
"type": "signDataWithAddress",
"address": "{get('cache.usingCurrentAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}"
},
"verify": {
"type": "verifySignatureWithAddress",
"address": "{get('cache.usingCurrentAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}",
"dataSignature": "{get('cache.usingCurrentAddress.sign')}"
},
"encryptedHex": {
"type": "encrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to encrypt this message",
"weak": true,
"default": "{get('cache.usingCurrentAddress.sign.signature')}"
},
"messageHex": "{get('cache.dependencies.dataHex')}"
},
"decryptedHex": {
"type": "decrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to decrypt this message",
"weak": true,
"default": "{get('cache.usingCurrentAddress.sign.signature')}"
},
"encryptedMessageHex": "{get('cache.usingCurrentAddress.encryptedHex')}"
}
}
},
"usingCurrentRewardAddress": {
"type": "script",
"exportAs": "UsingCurrentRewardAddress",
"run": {
"address": {
"type": "macro",
"run": "{get('cache.dependencies.currentRewardAddress')}"
},
"sign": {
"type": "signDataWithAddress",
"address": "{get('cache.usingCurrentRewardAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}"
},
"verify": {
"type": "verifySignatureWithAddress",
"address": "{get('cache.usingCurrentRewardAddress.address')}",
"dataHex": "{get('cache.dependencies.dataHex')}",
"dataSignature": "{get('cache.usingCurrentRewardAddress.sign')}"
},
"encryptedHex": {
"type": "encrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to encrypt this message",
"weak": true,
"default": "{get('cache.usingCurrentRewardAddress.sign.signature')}"
},
"messageHex": "{get('cache.dependencies.dataHex')}"
},
"decryptedHex": {
"type": "decrypt",
"requirePassword": {
"kind": "modal",
"description": "A password is required to decrypt this message",
"weak": true,
"default": "{get('cache.usingCurrentRewardAddress.sign.signature')}"
},
"encryptedMessageHex": "{get('cache.usingCurrentRewardAddress.encryptedHex')}"
}
}
}
}
}
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
