Skip to main content

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>
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 eyJ0e...ovCw"

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.

note

In this example, we retrieve the API keys for the transaction node. You can also use the API keys for the QBS member to access your transaction node. See API Keys in Data Security for more information.

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 eyJ0...0wVGg"

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": "H5xE...iWa2"
},
{
"keyName": "key2",
"value": "G1fe...rvHW"
}
]
}

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

Important

If your API keys are lost or compromised, you can generate new API keys for 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

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

Watch the video

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