
# Cardano Example Dapp

## **DRep parsing and certificate building**

Parses different DRep IDs following legacy and CIP129 formats and builds the corresponding vote delegation certificates in bulk


## Try it online: 

-  Visit [HTML+JS Dapp](https://gamechangerfinance.github.io/gamechanger.wallet/examples/DRep%20parsing%20and%20certificate%20building.html)
-  Visit [HTML+React Dapp](https://gamechangerfinance.github.io/gamechanger.wallet/examples/DRep%20parsing%20and%20certificate%20building_react.html)
-  Visit [Native HTML dapp](https://gamechangerfinance.github.io/gamechanger.wallet/examples/DRep%20parsing%20and%20certificate%20building_nolib.html)
-  Run [Standalone URL dapp connection](https://wallet.gamechanger.finance/api/2/run/1-H4sIAAAAAAAAA-WWy27bMBBFf0XgxgkQGNaDstRdEC8SdBO0QDdBUDAi9TJFyXzIlgz_e0nLUew0TSt5VXhnk_fMjO6MKG6BbCoCvgAR8ayS4AbITFKzsPhGKqtCXGQssRDDVkS4zOIsQpJYLyqjWG9oPSYdmpVMU48aIMLCWRwTTpi09mEeFsKKS0rLtQlGSYKiZh_z7uHRdkK9xwskxX5pH1pYMiVWVHJORFUyk8qqS50YE0ObZMf1CCtjGqRLXQ_ZVCWXt0IXg5FEeoUTqbgubguKEptHo0hIsLsBiCda9gQwJ5Xd1DXxIPRYvmkUcwSswtV8VgcBhjmd81nqelWermEMZbF2RS65kpV5fg3_7Cyw-QbjMKyV6waND8NVnASsqEiBm5SKAimc1F7htbidF7BuA9VK_xBhGIrDykmLV3Re0zB1IlFs2jRGbjCL4DJNm3Ctwo3rr6FbRXEUNDPKGc3z9Uq67BVtJGFqiWTL68hBwbJBtM39uRJeIaAfxH7eBFWwUi5V69k8yXFBEe9hJ3dWYRXRAMLQDwkKI8FTLJEvKENFJJNW1WrF2JL6sRKrJm9cHzzrhqh9N8xwEWx-vZ_BrjFgmxB5NTF_Jtc7cOCeenmBIl6-Lu_FC13WA4vLqx6czibXmt3dDKPsUZQzinJHUd4oCnbUsxl-rJsoxJH9WnanuHlrbw97bzIT50j6e7LbN12XL0JRSqYH_FAs-Hn80n7U-c9avAXLjOl5AT_0SbDoDwK9XamXr6S5RyK9J5t-cE4qMIVNhUQ6RHLQdkPVpf5n9nsv73BzKh2Vdkx38z2dTc1ep_6s0F5-Ivp7kT13IjLcbven-fhPrbSHWWmPtNK-ACudYVY6I610LsBKd5iV7kgr3Quw0htmpTfSSu8CrITDrIQjrYQfWmkuGAM_9Udy0MHvEp7cHcy97uT6MxC3z8Od83D3PNw7D4eT7g642_0CFoUDC_4NAAA)

## Source code:

- dapp connection code: [GCScript DSL](DRep%20parsing%20and%20certificate%20building.gcscript)
- frontend (using @gamechanger-finance/gc): [HTML+JS dapp](DRep%20parsing%20and%20certificate%20building.html)
- frontend (using @gamechanger-finance/gc): [HTML+React dapp](DRep%20parsing%20and%20certificate%20building_react.html)
- frontend (without official library): [Native HTML dapp](DRep%20parsing%20and%20certificate%20building_nolib.html)

Dapp code was autogenerated by [Playground IDE in GameChanger Wallet ](https://wallet.gamechanger.finance/playground)

## GCScript code (dapp connection):
```json
{
  "type": "script",
  "title": "DRep parsing and certificate building",
  "description": "Parses different DRep IDs following legacy and CIP129 formats and builds the corresponding vote delegation certificates in bulk",
  "exportAs": "data",
  "return": {
    "mode": "last"
  },
  "args": [
    "drep1yvve4554njxyun2s5p9q70v88d5jl7r0h34pjhw5f5tmw3sjtrutp",
    "drep_script1rxdd99vu338y659qfg8nmpemdyhlsmaudgv4m4zdz7m5vz8uzt6",
    "drep1rxdd99vu338y659qfg8nmpemdyhlsmaudgv4m4zdz7m5vd9p2hm",
    "drep17vl9h2csmxzhfa380c5khhy9wu9x36w53pcfc8y0lrnljjwqt3n",
    "drep1ytenukatzrvc2a8kyalzj67us4ms568f6jy8p8qu3luw07gjdmlar",
    "drep1y2j2q9pcl855969ea9csrhdta6slnamctgzuvuqnnkl6fusqyjy36"
  ],
  "run": {
    "parsed": {
      "type": "script",
      "args": "{get('args')}",
      "run": [
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.0'))}"
        },
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.1'))}"
        },
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.2'))}"
        },
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.3'))}"
        },
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.4'))}"
        },
        {
          "type": "macro",
          "run": "{getDrepInfo(get('args.5'))}"
        }
      ]
    },
    "address": {
      "type": "getCurrentAddress"
    },
    "addressInfo": {
      "type": "macro",
      "run": "{getAddressInfo(get('cache.address'))}"
    },
    "_certificates": {
      "type": "script",
      "run": [
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.0.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.0.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.0.scriptHashHex')}"
            }
          }
        },
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.1.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.1.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.1.scriptHashHex')}"
            }
          }
        },
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.2.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.2.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.2.scriptHashHex')}"
            }
          }
        },
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.3.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.3.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.3.scriptHashHex')}"
            }
          }
        },
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.4.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.4.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.4.scriptHashHex')}"
            }
          }
        },
        {
          "type": "macro",
          "run": {
            "kind": "VoteDelegation",
            "pubKeyHashHex": "{get('cache.addressInfo.stakingKeyHash')}",
            "scriptHashHex": "{get('cache.addressInfo.stakingScriptHash')}",
            "vote": {
              "kind": "{get('cache.parsed.5.kind')}",
              "pubKeyHashHex": "{get('cache.parsed.5.pubKeyHashHex')}",
              "scriptHashHex": "{get('cache.parsed.5.scriptHashHex')}"
            }
          }
        }
      ]
    },
    "certificates": {
      "type": "script",
      "run": [
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.0')}"
        },
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.1')}"
        },
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.2')}"
        },
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.3')}"
        },
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.4')}"
        },
        {
          "type": "certificate",
          "cert": "{get('cache._certificates.5')}"
        }
      ]
    }
  }
}
```

## Run standalone QR dapp connection: 

You can use [Playground IDE in GameChanger Wallet ](https://wallet.gamechanger.finance/playground) 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](DRep%20parsing%20and%20certificate%20building.png)](https://gamechangerfinance.github.io/gamechanger.wallet/examples/DRep%20parsing%20and%20certificate%20building.png)

## Resources
- [How to connect?](https://www.npmjs.com/package/@gamechanger-finance/gc)
- [Docs and examples on Github](https://github.com/GameChangerFinance/gamechanger.wallet/)
- [GCScript documentation](https://wallet.gamechanger.finance/doc/api/v2)
- [Playground IDE in GameChanger Wallet ](https://wallet.gamechanger.finance/playground)
- [Tutorials on Youtube](https://www.youtube.com/@gamechanger.finance)
- [Support on Discord](https://discord.gg/vpbfyRaDKG)
- [News on Twitter](https://twitter.com/GameChangerOk)
- [Website](https://gamechanger.finance)

## License
MIT 
    
