Knowledge Base Home

Submit a transaction with Kaleido Connect

Let’s use the simple Webhooks interface provided by Kaleido Connect to deploy a contract against a Kaleido permissioned chain.

Only available for nodes created after upgrading to Release Version 0.1.10 or later

Set up the connection

  • Generate an Application Credential in the Kaleido console
    • Make sure to leave the console open with the credentials displayed until you have copied them
  • Open your favorite REST client, such as Postman
  • Set the Authorization type to Basic Auth in the REST client
  • Set the Username to the username from your application credential
  • Set the Password to the password from your application credential
  • Back in the Kaleido console, go to your node details
    • You will need the WEBHOOKS URL and the Ethereum Address in the USER ACCOUNTS row
  • Back in the REST client, Set the Method to POST
  • Set the URL to the WEBHOOKS URL of your node, for example https://u0d7zazjno-u0aopxc5lf-connect.us-east-2.kaleido.io
  • Set the Body type to Raw

Submit a simple request to deploy a contract

  • Define the body as follows – replacing the placeholder 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX with your USER ACCOUNTS address. Note that this snippet uses YAML format for the sake of readability, however JSON syntax is also supported:
headers:
  type: DeployContract
from: '0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
params:
  - 12345
gas: 1000000
solidity: |-
  pragma solidity ^0.4.17;

  contract simplestorage {
    uint public storedData;

    function simplestorage(uint initVal) public {
        storedData = initVal;
    }

    function set(uint x) public {
        storedData = x;
    }

    function get() public constant returns (uint retVal) {
        return storedData;
    }
  }

  • Submit the request

You should see a response similar to the following:

{"sent":true,"id":"10b24e3b-6160-46f2-7ea9-518d276fe50a"}

Get the reply

  • Change the Method to GET
  • Add /replies to the URL, for example https://u0d7zazjno-u0aopxc5lf-connect.us-east-2.kaleido.io/replies
  • Submit the request

If you see [] as the response, you need to retry this step as the request has not yet been processed by the Ethereum node. Depending on the consensus algorithm being used by your chain, it could take up to 20 seconds for the reply to be received

  • You should see a response similar to the following – if so you have just committed a transaction into a block on your chain:
[
  {
      "_id": "10b24e3b-6160-46f2-7ea9-518d276fe50a",
      "blockHash": "0x98f25e4f0d5c5578eb211ee763799d2a62dcc14cc8127188106019768c365f70",
      "blockNumber": "17127",
      "blockNumberHex": "0x42e7",
      "contractAddress": "0xYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",
      "cumulativeGasUsed": "134221",
      "cumulativeGasUsedHex": "0x20c4d",
      "from": "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "gasUsed": "134221",
      "gasUsedHex": "0x20c4d",
      "headers": {
          "id": "6d7a4dfc-e735-4a10-719a-05feac8669b2",
          "requestId": "10b24e3b-6160-46f2-7ea9-518d276fe50a",
          "requestOffset": "u0d7zazjno-u0aopxc5lf-requests:0:5",
          "timeElapsed": 9.350811604,
          "timeReceived": "2018-07-27T18:25:36Z",
          "type": "TransactionSuccess"
      },
      "receivedAt": 1532715946473,
      "status": "1",
      "statusHex": "0x1",
      "to": null,
      "transactionHash": "0xc7b755b2253c75b453bb2e3b92741d16503097dad50d7e5e586c19c32d0c6c6e",
      "transactionIndex": "0",
      "transactionIndexHex": "0x0"
  }
]

Submit a transaction to the newly deployed contract

  • Set the Method back to POST
  • Set the URL back to the base / URL, for example https://u0d7zazjno-u0aopxc5lf-connect.us-east-2.kaleido.io/
  • Set the body as follows:
    • Replacing 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX with your USER ACCOUNTS address
    • Replacing 0xYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY with the contractAddress you received in the response payload after deploying the contract
headers:
  type: SendTransaction
from: 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
to: 0xYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
params:
  - value: 4276993775
    type: uint256
gas: 1000000
methodName: set

You will continue to see the old reply until the transaction has been processed Depending on the consensus algorithm being used by your chain, it could take up to 20 seconds for the reply to be processed

Use the Block Explorer to see your transactions on the chain

See Using the Block Explorer to learn more about the features of the Kaleido Block Explorer.

Prev Connect to your node with Kaleido Connect Next Kaleido Kards