Token Swaps

Token Factory

Token Exchanges with Atomic Swaps

Tokens can be securely exchanged through the usage of Hashed Time Lock Contracts (HTLCs) that serve as digital escrow services. These contracts abstract the need for a third party settlement broker and offer “atomicity” for the proposed bi-lateral exchange. The security of these escrow smart contracts allow for any token owner to propose and execute token exchanges with other parties in the consortium with the peace of mine that under no circumstances would they lose their token due to malicious intent from their exchange counterparty. This content will explore the constructs of an HTLC and walk through the Kaleido Swap Service.

Deploying the Service

The swap service is deployable in the same manner as any other service: via the administrative API or through an environment dashboard within the Kaleido console.

Via the console

  • To provision the service via the Kaleido console, navigate to the appropriate environment and click the + ADD dropdown in the top portion right of the screen and click Add Services.
  • Find the Kaleido Token Swaps service and click ADD.
  • Optionally provide a name for your service.
  • The service is ready for use when a green dot appears next to it.

Via the API

To provision the service via the API follow the same procedure as other member services with a service type of tokenswap, a membership ID and an optional name in the body of the call. Note that this example call assumes that the $APIURL, $HDR_AUTH and $HDR_CT environment variables have been properly set. To see the example syntax for these variables refer to the Understanding the Kaleido API documentation. An example token swap creation call would resemble the following:

curl -X POST -H "$HDR_AUTH" -H "$HDR_CT" "$APIURL/consortia/{consortia_id}/environments/{environment_id}/services" -d '{"name":"ExampleSwapService", "service":"tokenswap", "membership_id":"{membership_id}"}' | jq