Quick tutorial

This tutorial will walk you through creating a consortium network through the Chainstack API.

Overview

To get from zero to a running consortium network through the Chainstack API, do the following:

  1. Get your API key.
  2. Export your API variables.
  3. Create a project.
  4. Create a network.
  5. Add a node to the network.
  6. Get the node access and credentials.

Step-by-step

Get your API key

See Create an API key.

Export your API variables

To save time when interacting with the API, export your API variables:

export APIURL="https://api.chainstack.com/v1"
export APIKEY="YOUR_CHAINSTACK_API_KEY"
export HDR_AUTH="Authorization: Bearer $APIKEY"
export HDR_CT="Content-Type: application/json"

Create a project

curl -X POST "$APIURL/projects/" --header "$HDR_AUTH" --header "$HDR_CT" --data '{"name":"YOUR_PROJECT_NAME","description":"YOUR_PROJECT_DESCRIPTION"}'

See also API reference: Create Project.

Create a network

You create a network with one peer node and service nodes.

The service nodes are created automatically with no input from you.

You must provide the node details for your peer node.

curl -X POST "$APIURL/networks/" --header "$HDR_AUTH" --header "$HDR_CT" --data '{"name":"NETWORK_NAME","project":"PROJECT_ID","protocol":"PROTOCOL","configuration":{"consensus":"CONSENSUS"},"nodes":[{"name":"NODE_NAME","type":"NODE_TYPE","role":"NODE_ROLE","provider":"CLOUD_PROVIDER","region":"LOCATION","configuration":{}}]}'

where

  • NETWORK_NAME β€” any name you want to give to your network.
  • PROJECT_ID β€” the ID of the project where the network will be deployed. You can get project IDs by running curl -X GET "$APIURL/projects/" --header "$HDR_AUTH".
  • PROTOCOL β€” the protocol of the network you want to deploy:
    • corda β€” Corda
    • fabric β€” Hyperledger Fabric
    • quorum β€” Quorum
    • multichain β€” MultiChain
  • CONSENSUS β€” the consensus of the protocol you want to deploy:
  • NODE_NAME β€” any name you want to give to your first peer node deployed as part of the network.
  • NODE_TYPE β€” dedicated is the only available option for consortium networks.
  • NODE_ROLE β€” use the peer value for the role since you are providing node details for your peer node.
  • CLOUD_PROVIDER β€” choose the cloud provider for your node:
    • aws β€” Amazon Web Services
    • azure β€” Microsoft Azure
    • gcloud β€” Google Cloud Platform
  • LOCATION β€” choose the location for your network:
    • ap-southeast-1 β€” Singapore. Available only for Amazon Web Services (aws).
    • us-east-1 β€” the United States, Northern Virginia. Available only for Amazon Web Services (aws).
    • us-west-2 β€” the United States, Oregon. Available only for Amazon Web Services (aws).
    • uksouth β€” the United Kingdom, London. Available only for Microsoft Azure (azure).
    • asia-southeast1 β€” Singapore. Available only for Google Cloud Platform (gcloud).

Example to create a Corda network on Google Cloud Platform in Singapore:

curl -X POST "$APIURL/networks/" --header "$HDR_AUTH" --header "$HDR_CT" --data '{"name":"NETWORK_NAME","project":"PR-123-456","protocol":"corda","configuration":{"consensus":"single-notary"},"nodes":[{"name":"My node name","type":"dedicated","role":"peer","provider":"gcloud","region":"asia-southeast1","configuration":{}}]}'

See also API reference: Create Network.

Add a peer node to the network

curl -X POST "$APIURL/nodes/" --header "$HDR_AUTH" --header "$HDR_CT" --data '{"name":"NODE_NAME","network":"NETWORK_ID","type": "dedicated","role":"peer","provider":"CLOUD_PROVIDER","region":"LOCATION","configuration":{}}'

where

  • NODE_NAME β€” any name you want to give to your node.
  • NETWORK_ID β€” the ID of the network where the node will be deployed. You can get network IDs by running curl -X GET "$APIURL/networks/" --header "$HDR_AUTH".
  • CLOUD_PROVIDER β€” choose the cloud provider for your node:
    • aws β€” Amazon Web Services
    • azure β€” Microsoft Azure
    • gcloud β€” Google Cloud Platform
  • LOCATION β€” choose the location for your network:
    • ap-southeast-1 β€” Singapore. Available only for Amazon Web Services (aws).
    • us-east-1 β€” the United States, Northern Virginia. Available only for Amazon Web Services (aws).
    • us-west-2 β€” the United States, Oregon. Available only for Amazon Web Services (aws).
    • uksouth β€” the United Kingdom, London. Available only for Microsoft Azure (azure).
    • asia-southeast1 β€” Singapore. Available only for Google Cloud Platform (gcloud).

Example to add a node on Microsoft Azure in London:

curl -X POST "$APIURL/nodes/" --header "$HDR_AUTH" --header "$HDR_CT" --data '{"name":"My node name","network":"NW-123-456-7","type": "dedicated","role":"peer","provider":"azure","region":"uksouth","configuration":{}}'

See also API reference: Create Node.

Get the node access and credentials

curl -X GET "$APIURL/nodes/NODE_ID/" --header "$HDR_AUTH"

where NODE_ID β€” the ID of the node. You can get node IDs by running curl -X GET "$APIURL/nodes/" --header "$HDR_AUTH".

See also API reference: Retrieve Node.

You have created a consortium project, deployed a consortium network, added a node to the network, and retrived the node's access and credentials.