Skip to main content

Cardano Example Dapp

Smart Handles - Swap ADA to MIN on Minswap​

Interact with a Smart Handles instance for swapping ADA to MIN, with a routing fee of 1 ADA (preprod). Uses the Minswap V2 instance of Anastasia Labs Smart Handles. https://github.com/Anastasia-Labs/smart-handles

Try it online:​

Source code:​

Dapp code was autogenerated by Playground IDE in GameChanger Wallet

GCScript code (dapp connection):​

{
"type": "script",
"title": "Smart Handles - Swap ADA to MIN on Minswap",
"description": "Interact with a Smart Handles instance for swapping ADA to MIN, with a routing fee of 1 ADA (preprod). Uses the Minswap V2 instance of Anastasia Labs Smart Handles. https://github.com/Anastasia-Labs/smart-handles",
"require": {
"networkTag": "preprod"
},
"args": {
"amount": "50000000"
},
"return": {
"mode": "last"
},
"exportAs": "SmartHandlesDemo",
"run": {
"dependencies": {
"type": "script",
"run": {
"userAddress": {
"type": "getCurrentAddress"
},
"addressInfo": {
"type": "macro",
"run": "{getAddressInfo(get('cache.dependencies.userAddress'))}"
},
"datum": {
"type": "plutusData",
"data": {
"fromJSON": {
"schema": 1,
"obj": {
"constructor": 0,
"fields": [
{
"constructor": 0,
"fields": [
{
"constructor": 0,
"fields": [
{
"bytes": "{get('cache.dependencies.addressInfo.paymentKeyHash')}"
}
]
},
{
"constructor": 0,
"fields": [
{
"constructor": 0,
"fields": [
{
"constructor": 0,
"fields": [
{
"bytes": "{get('cache.dependencies.addressInfo.stakingKeyHash')}"
}
]
}
]
}
]
}
]
}
]
}
}
}
}
}
},
"build_swap_request_tx": {
"type": "buildTx",
"title": "Send 50 ADA",
"description": "Swap request to MIN",
"name": "Unsigned Swap Request Transaction",
"tx": {
"outputs": [
{
"address": "addr_test1wqx2p02tnmnpk7dt88kaemx3qz62r4xqy2p47756879k3xgpval35",
"assets": [
{
"policyId": "ada",
"assetName": "ada",
"quantity": "{get('args.amount')}"
}
],
"datum": {
"datumHex": "{get('cache.dependencies.datum.dataHex')}"
}
}
]
}
},
"sign_swap_request_tx": {
"type": "signTxs",
"namePattern": "Signed Swap Request Transaction",
"detailedPermissions": false,
"txs": [
"{get('cache.build_swap_request_tx.txHex')}"
]
},
"submit_swap_request_tx": {
"type": "submitTxs",
"namePattern": "Submitted Demo Transaction",
"txs": "{get('cache.sign_swap_request_tx')}"
},
"export_results": {
"type": "macro",
"run": {
"txHash": "{get('cache.build_swap_request_tx.txHash')}",
"address": "{get('cache.dependencies.userAddress')}",
"datumHex": "{get('cache.dependencies.datum.dataHex')}",
"amount": "{get('args.amount')}"
}
}
}
}

Run standalone QR dapp connection:​

You can use Playground IDE in GameChanger Wallet in QR URL Transport mode to capture results

This GCScript/URL is too large! make it shorter uploading parts to GCFS. Unable to generate QR code

Resources​

License​

MIT