Cardano Example Dapp
Runtime Assertions
This example demonstrates how custom runtime assertions can be implemented. Modify the arguments to trigger errors. Explore the Console in Live Debugger for extra information
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": "Runtime Assertions",
"description": "This example demonstrates how custom runtime assertions can be implemented. Modify the arguments to trigger errors. Explore the Console in Live Debugger for extra information",
"type": "script",
"exportAs": "AssertionsDemo",
"returnURLPattern": "http://localhost:3000/demo/api/dapp",
"args": {
"name": "john doe",
"age": 25,
"banked": false,
"balance": "25"
},
"run": {
"A": {
"type": "script",
"args": "{get('args')}",
"run": {
"B": {
"type": "script",
"args": "{get('args')}",
"run": {
"C": {
"type": "script",
"args": "{get('args')}",
"run": {
"asserts": {
"type": "macro",
"run": {
"name-must-be-string": "{ assert( isType('string',get('args.name')) ,'\"name\" must be a string' , get('args') ) }",
"balance-must-be-string": "{ assert( isType('string',get('args.balance')) ,'\"balance\" must be a string (bignum)' , get('args') ) }",
"age-must-be-number": "{ assert( isType('number',get('args.age')) ,'\"age\" must be a number' , get('args') ) }",
"banked-must-be-boolean": "{ assert( isType('boolean',get('args.banked')) ,'\"banked\" must be a boolean' , get('args') ) }",
"name-must-not-be-empty": "{ assert( not(isEmptyString(get('args.name'))) ,'\"name\" must not be empty' , get('args') ) }",
"balance-must-be-greater-than-age": "{ assert( cmpBigNum('gt',get('args.balance') ,get('args.age')) ,'\"balance\" must be greater than \"age\"' , get('args') ) }"
}
}
}
}
}
}
}
}
}
}
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
