Skip to content
Last update: July 13, 2022

Get the connection string

You need a connection string to interact with your Quorum Blockchain Service (QBS) network. The connection string is a combination of the DNS name of your transaction node and your API key. This allows tools such as MetaMask and Truffle to connect to your QBS instance, and use the Quorum JSON-RPC APIs to interact with the blockchain.

The transaction node exposes the connection string in the following format:

  • HTTP: https://<Transaction-Node-DNS>:3200/<API-Key>
  • WebSocket: wss://<Transaction-Node-DNS>:3300/<API-Key>
https://transaction-1.contoso.supplychainconsortium.onquorum.net:3200/H5xErimMMG32jtiRYbyEiWa2
wss://transaction-1.contoso.supplychainconsortium.onquorum.net:3300/H5xErimMMG32jtiRYbyEiWa2

Note

If you delete your QBS member and create a new one with the same name, the DNS hostname will be different from the deleted one.

These instructions provide you with the steps to retrieve the transaction node DNS and API key used to form the connection string.

1. Retrieve the transaction node DNS

You can use either a tool such as curl or the QBS management API website to retrieve the DNS addresses for your transaction nodes.

Retrieve the transaction node DNS using curl

This example calls the transactionNodes endpoint to get the transaction node details:

curl -X GET "https://management.onquorum.net/subscriptions/<YOUR SUBSCRIPTION ID>/resourceGroups/qbs-docs-demo-environment/providers/ConsenSys.Blockchain/blockchainMembers/contoso/transactionNodes" \
-H  "accept: text/plain" \
-H  "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhzGfiOiJuUzI1NiIsPng1dCI6Im5PbDNaRHJPRFhFSzFqS1d0WHNsSFJfS1hFZyIsINtpZCIGIm5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiI4Yzk4OTMwNy0yNDM5LTQwMmItODZlYi01OTAwYzYxMzJkZWUiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC84NTkyOTY1OS05YTMwLTQyZGUtOGY2MC1mYjZiZjA3YjI4ZWIvIiwiaWF0IjoxNjI5MjU4MDAyLCJuYmYiOjE2MjkyNTgwMDIsImV4cCI6MTYyOTI2MTkwMiwiYWNyIjoiMSIsImFpbyI6IkFTUUEyLzhUQUFBQUgzQVJTWG5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UUmk_Gd0tAZthvYzMdKRIle5X7kK72RfrqD6rgQMP0gG0dLcAq4DfaSncH4cQE7tn4sClX8qdBR7I90m_jgN5fz-YcfALilXo4er_cdjjCjzgwIgThQjgwBH-YqVg7L863xmg5bV6PcheGwrSx_Iko0-MRjlfKjPHr40CA45VCBDXmvXVoBnM4ovCw"
{
  "nextLink": null,
  "value": [
    {
      "id": "/subscriptions/<YOUR SUBSCRIPTION ID>/resourceGroups/qbs-docs-demo-environment/providers/Microsoft.Solutions/applications/contoso/transactionNodes/transaction-1",
      "location": "eastus",
      "name": "transaction-1",
      "type": "ConsenSys.Blockchain/blockchainMembers/transactionNodes",
      "properties": {
        "dns": "transaction-1.contoso.supplychainconsortium.onquorum.net",
        "firewallRules": [],
        "provisioningState": "Succeeded",
        "publicKey": null
      }
    }
  ]
}

dns is the DNS address of node transaction-1. In this example, transaction-1.contoso.supplychainconsortium.onquorum.net.

Retrieve the transaction node DNS using the QBS management API

Navigate to the QBS management API website and select Authorize to authorize running the APIs.

Authorize API

Once you authorize the API, select the GET request for Get details about a blockchain member under the BlockchainMembers section, and select Try it out.

Try it out

In the fields for the API request, fill out the following using your QBS member information, located in the Overview section of your QBS member in the Azure portal:

  • subscriptionID - Your subscription ID, in the Overview tab for your QBS member, under the Essentials section.

  • resourceGroupName - The resource group to which your QBS member is deployed. Note this is NOT the Managed Application resource group.

  • blockchainMemberName - The name of your QBS member, also known as the name of your Managed Application, located in the upper-left corner of the Overview tab.

Overview Page

Select Execute. The website shows the server response, which lists the blockchain member information:

Sample JSON result

  {
  "id": "/subscriptions/<YOUR SUBSCRIPTION ID>/resourceGroups/devtool-testing/providers/Microsoft.Solutions/applications/consensys",
  "location": "eastus",
  "name": "consensys",
  "sku": null,
  "tags": {},
  "type": "ConsenSys.Blockchain/blockchainMembers",
  "properties": {
    "consortium": "devtooltest",
    "consortiumMemberDisplayName": "consensys",
    "dns": "transaction-1.consensys.devtooltest.onquorum.net",
    "protocol": "Quorum",
    "provisioningState": "Succeeded",
    "publicKey": null,
    "rootContactAddress": null,
    "firewallRules": [],
    "validatorNodesSku": {
      "capacity": 1
    }
  }
}

dns is the transaction node RPC endpoint needed to connect to MetaMask or Truffle. In this example, transaction-1.consensys.devtooltest.onquorum.net.

2. Retrieve the transaction node API key

As in the previous step, you can use either curl or the QBS management API website to retrieve the API keys for your transaction node.

Retrieve the transaction node API key using curl

This example calls the listApiKeys endpoint to get the API key for the specified transaction node:

curl -X GET "https://management.onquorum.net/subscriptions/<YOUR SUBSCRIPTION ID>/resourceGroups/qbs-docs-demo-environment/providers/ConsenSys.Blockchain/blockchainMembers/contoso/transactionNodes/transaction-1/listApiKeys" \
-H  "accept: text/plain" \
-H  "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyIsImtpZCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiI4Yzk4OTMwNy0yNDM5LTQwMmItODZlYi01OTAwYzYxRoskZrWUiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC84NTkyOTY1OS05YTMwLTQyZGUtOGY2MC1mYjZiZjA3YjI4ZWIvIiwiaWF0IjoxNjI5MjY0MjcxLCJuYmYiOjE2MjkyNjQyNzEsImV4cCI6MTYyOTI2ODE3MSwiYWNyIjoiMSIsImFpbyI6IkFTUUEyLzhUQUFBQXZDc1RuSXFicjAxTC9zdDV0ZVN5cHhCeXI1b05NUlJPVm5rb1c4N3Z1MlU9IiwiYW1yIjpbInB3ZCJdLCJhcHBpZCI6IjhjOTg5MzA3LTI0MzktNDAyYi04NmViLTU5MDBjNjEzMmRlZSIsImFwcGlkYWNyIjoiMCIsImZhbWlseV9uYW1lIjoiVGVzdCIsImlwYWRkciI6IjEwMy45NS4xMTUuNTAiLCJuYW1lIjoiQnlyb24iLCJvaWQiOiIxMjg2MWNlYi0zZmM4LTRiZjUtOGJhZC1mM2UwNTUyMTk3NDUiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJCeXJvblRlc3RAcW9kbWVtYmVyMS5vbm1pY3Jvc29mdC5jb20iLCJyaCI6IjAuQVVFQVdaYVNoVENhM2tLUFlQdHI4SHNvNndlVG1JdzVKQ3RBaHV0WkFNWVRMZTVCQUVFLiIsInNjcCI6IlVzZXIuUmVhZCIsInNpZCI6IjlhZTBiYzgzLTNmZTgtNDhmNS05MDAyLWU0NjVlNDlhODdiNyIsInN1YiI6IjduaTJxNlpSTTVwXzd1QU93RVpoZzVDempuNXVZajhVeHlBblUycTJqUDQiLCJ0aWQiOiI4NTkyOTY1OS05YTMwLTQyZGUtOGY2MC1mYjZiZjA3YjI4ZWIiLCJ1bmlxdWVfbmFtZSI6IkJ5cm9uVGVzdEBxb2RtZW1iZXIxLm9ubWljcm9zb2Z0LmNvbSIsInVwbiI6IkJ5cm9uVGVzdEBxb2RtZW1iZXIxLm9ubWljcm9zb2Z0LmNvbSIsInV0aSI6InZIRWRCcFAxODBPOVdxTDB5M01RQVEiLCJ2ZXIiOiIxLjAifQ.n2W7rfd6Cxri337-XGhUd-aAK8cR7nJE-a2rJCxxcQB6YNiSuwGMgSYliiTmGEhKaH-_b06QmMXIR51wuZlu4Dn8oUq6ol95OiINn3DxbPJe8Xic63373AZB0baUubel9rqhnu5KYFZTbmtwbhufujRzFXrRWsnc44gh9TWo5FBZWvoK9_P5sTsFP3Q9MF6OL2PydZSDjs5Y7TjkjOYUTnX2T0kYXKBTSXuMM9bhnPrsnRgwDJEEH4hx9YzQA1RORZVLxGkCPfF3D-fsloJD82CIeHy-FxJoB-YqSFb754PVakZT_Iaq9Tfwd2jb8Z1WW4ASz5RlVxLa1uSh90wVGg"
{
  "keys": [
    {
      "keyName": "key1",
      "value": "H5xErimMMG32jtiRYbyEiWa2"
    },
    {
      "keyName": "key2",
      "value": "G1fe2CHb6E3YKjAvHDUsrvHW"
    }
  ]
}

Retrieve the transaction node API key using the QBS management API

Navigate to the QBS management API website.

Select the GET request for List the API keys for the transaction node.

Select Try it out.

Get API Keys

Example JSON result

{
  "keys": [
    {
      "keyName": "key1",
      "value": "lPwtD4B6tebfkCWpbYC9IkLH"
    },
    {
      "keyName": "key2",
      "value": "gT5F-lUKA_yw21XHPQP5VrAn"
    }
  ]
}

The value result for either Key1 or Key2 can be used to access your transaction node.

Using the examples above, you can combine the RPC endpoint information with the chosen key to access your node:

https://transaction-1.consensys.devtooltest.onquorum.net:3200/lPwtD4B6tebfkCWpbYC9IkLH
wss://transaction-1.consensys.devtooltest.onquorum.net:3300/lPwtD4B6tebfkCWpbYC9IkLH

Example Quorum JSON-RPC API call

The following example uses curl to call eth_blockNumber to return the number for the most recent block on the blockchain:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":51}' https://transaction-1.contoso.supplychainconsortium.onquorum.net:3200/H5xErimMMG32jtiRYbyEiWa2
{
  "jsonrpc" : "2.0",
  "id" : 51,
  "result" : "0x2377"
}

Watch the video

If you are a visual learner, the following video walks you through the steps in this article.

Back to top