In this guide, we describe how to integrate Clause with the Kaleido platform so that you can store key contract events on your consortia’s tamper-proof blockchain so that they are securely distributed to all your members. 

Kaleido is a Blockchain Software-as-a-Service platform that lets you quickly provision and manage an Ethereum network.

Step 1: Set up Kaleido

If you've already provisioned a network on Kaleido, skip to step 2.

Visit the Kaleido Dashboard to create an account and then follow the user interface instructions to build your consortium and provision nodes. Step-by-step instructions are also provided in the Create your network section of the Kaleido docs.

Step 2: Deploy the Audit Log sample to your network

Go to https://kaleido-io.github.io/kaleido-samples-gallery/ and set up the Kaleido connection information.

  • The Consortia ID can be found in the address bar of the Consortia page, for example, https://console.kaleido.io/consortia/zzabcd1234
  • Create App Credentials from the Environment page. Click New App Credentials 
  • The Node RPC Endpoint can be found in the Node details page.

Once you've saved your connection information in the Kaleido Samples Gallery, click Audit Log in the header, to deploy the Audit Log smart contract to your network.

Step 3: Create your contract on Clause

If you're new to Clause, follow the getting started guide. Otherwise, you should add a Smart Clause® to your contract that emits an obligation, for example, 'Full Payment Upon Signature' or 'Fragile Goods'. The obligations that a Smart Clause emits are listed in the smart clause details window.

Configure your Smart Clause's Action to use a Custom Action. 

1. Select HTTP as the target for your custom action.

2. Set the transform to:

{
  "$class": "io.clause.outbound.physical.Http",
  "method": "POST",
  "url": "KALEIDO_CONNECT_WEBHOOK_URL",
  "headers": {
    "authorization": "Basic KALEIDO_CREDENTIALS_BASE64"
  },
  "body": {
    "headers": {
      "type": "SendTransaction"
    },
    "from": "KALEIDO_SOURCE_ADDRESS",
    "to": "KALEIDO_AUDIT_LOG_ADDRESS",
    "params": [
      {
        "value": "KALEIDO_SOURCE_ADDRESS",
        "type": "address"
      },
      {
        "value": event.description,
        "type": "string"
      }
    ],
    "gas": 1000000,
    "methodName": "push"
  }
}

Where the following values are replaced with values from Kaleido. Further details are available from the Kaleido Connect page, available at the bottom of the Node details page in Kaleido.

  • KALEIDO_CONNECT_WEBHOOK_URL - For example, https://xxxxxxxxxx-xxxxxxxxxx-connect.us-east-2.kaleido.io . This is available from the node details page in the Kaleido console.
  • KALEIDO_CREDENTIALS_BASE64 - A base64 encoding of your username and password. Available when you create App Credentials in Kaleido. Hint: Follow this guide to safely create a base64 encoding of your username and password. Use the format, user:password as the input. 
  • KALEIDO_AUDIT_LOG_ADDRESS - The smart contract address from the audit log UI. For example,  0xAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  • KALEIDO_SOURCE_ADDRESS -  The value of CONESNSUS_IDENTITY or USER_ACCOUNTS for a node in your network. Available from the node details page. For example,  0xBBBBBBBBBBBBBBBBBBBBBBBBBBB

Also, note that payload sent to Kaleido under params should match a field from your Smart Clause's emitted event. In this sample, we use  event.description that is provided by all Payment Obligations.

Step 4. Sign your contract

Remember that Clause Actions are only processed when your contract is running. Contracts are running once all signatures have been received.

Once your contract is Running, you should trigger your Smart Clause. The correct way to do this depends on which clause that you chose. For example: 

  • Full Payment upon Signature is triggered automatically when the seller signs the contract.
  • Fragile Goods is triggered by calling the Clause API

Validate that your Smart Clause has emitted an obligation in the Timeline.

Then finally, switch to the Kaleido Audit Log UI to view the obligation record on the Ethereum blockchain.