Cardano Example Dapp
Helios One-Shot Mint
Parameterizes and compiles an Helios Smart Contract on the fly on user wallet, a One-Shot Mint validator pattern. The UTXO required for the one-shot mint is produced on a first transaction, but a previously-generated one can be provided to avoid this first step.
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": "Helios One-Shot Mint",
"description": "Parameterizes and compiles an Helios Smart Contract on the fly on user wallet, a One-Shot Mint validator pattern. The UTXO required for the one-shot mint is produced on a first transaction, but a previously-generated one can be provided to avoid this first step.",
"type": "script",
"args": {
"asset-name": "KeepCalmAndUseGC",
"quantity": "1"
},
"exportAs": "OneShotMinter",
"return": {
"mode": "last"
},
"run": {
"generateUTXOs": {
"type": "script",
"isolateCache": true,
"return": {
"mode": "last"
},
"run": {
"build": {
"type": "buildTx",
"title": "UTXO Generator",
"tx": {}
},
"sign": {
"detailedPermissions": false,
"type": "signTxs",
"txs": [
"{get('cache.build.txHex')}"
]
},
"submit": {
"type": "submitTxs",
"txs": "{get('cache.sign')}"
},
"utxo": {
"type": "macro",
"run": {
"txHash": "{get('cache.build.txHash')}",
"outputs": "{get('cache.build.indexMap.output')}"
}
}
}
},
"data": {
"type": "macro",
"run": {
"assetNameHex": "{strToHex(get('args.asset-name'))}",
"utxo": {
"txHash": "{get('cache.generateUTXOs.txHash')}",
"txOutIdx": "{get('cache.generateUTXOs.outputs.output:0')}"
}
}
},
"parameterizingSourceCode": {
"type": "macro",
"run": [
"{set('tempSourceCode',base64ToStr('bWludGluZyB1dHhvX25mdAoKY29uc3QgYXNzZXRfbmFtZTogQnl0ZUFycmF5ID0gI0FTU0VUTkFNRV9IRVgKY29uc3Qgb3V0cHV0X2lkOiBUeE91dHB1dElkID0gVHhPdXRwdXRJZDo6bmV3KFR4SWQ6Om5ldygjVFhIQVNIKSwgVFhPVVRJRFgpCgpmdW5jIG1haW4oXywgY3R4OiBTY3JpcHRDb250ZXh0KSAtPiBCb29sIHsKICAgIHR4OiBUeCA9IGN0eC50eDsKCiAgICBuZnRfYXNzZXRjbGFzczogQXNzZXRDbGFzcyA9IEFzc2V0Q2xhc3M6Om5ldygKICAgICAgICBjdHguZ2V0X2N1cnJlbnRfbWludGluZ19wb2xpY3lfaGFzaCgpLAogICAgICAgIGFzc2V0X25hbWUKICAgICk7CgogICAgdmFsdWVfbWludGVkOiBWYWx1ZSA9IHR4Lm1pbnRlZDsKCiAgICB2YWx1ZV9taW50ZWQgPT0gVmFsdWU6Om5ldyhuZnRfYXNzZXRjbGFzcywgMSkgJiYKICAgIHR4LmlucHV0cwogICAgICAgIC5hbnkoKGlucHV0OiBUeElucHV0KSAtPiBCb29sIHtpbnB1dC5vdXRwdXRfaWQgPT0gb3V0cHV0X2lkfSkKfQo='))}",
"{set('tempSourceCode',replaceAll(get('global.tempSourceCode'),'ASSETNAME_HEX',get('cache.data.assetNameHex')))}",
"{set('tempSourceCode',replaceAll(get('global.tempSourceCode'),'TXHASH' ,get('cache.data.utxo.txHash')))}",
"{set('tempSourceCode',replaceAll(get('global.tempSourceCode'),'TXOUTIDX' ,get('cache.data.utxo.txOutIdx')))}"
]
},
"validator": {
"type": "plutusScript",
"script": {
"simplify": false,
"heliosCode": "{get('global.tempSourceCode')}",
"version": "0.15.2"
}
},
"build": {
"type": "buildTx",
"title": "Helios One-Shot Mint",
"tx": {
"mints": [
{
"policyId": "{get('cache.validator.scriptHashHex')}",
"assets": [
{
"assetNameHex": "{get('cache.data.assetNameHex')}",
"quantity": "{get('args.quantity')}"
}
]
}
],
"inputs": [
{
"txHash": "{get('cache.data.utxo.txHash')}",
"index": "{get('cache.data.utxo.txOutIdx')}"
}
],
"witnesses": {
"plutus": {
"scripts": [
{
"scriptHex": "{get('cache.validator.scriptHex')}",
"lang": "{get('cache.validator.lang')}"
}
]
}
},
"options": {
"collateralCoinSelection": "LASLAD"
}
}
},
"sign": {
"detailedPermissions": false,
"type": "signTxs",
"txs": [
"{get('cache.build.txHex')}"
]
},
"submit": {
"type": "submitTxs",
"txs": "{get('cache.sign')}"
},
"finally": {
"type": "macro",
"run": {
"policyId": "{get('cache.validator.scriptHashHex')}",
"assetNameHex": "{get('cache.data.assetNameHex')}",
"utxo": "{get('cache.data.utxo')}",
"quantity": "{get('args.quantity')}",
"smartContract": "{get('cache.validator.scriptHex')}",
"txHash": "{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
