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:
- Get your API key.
- Export your API variables.
- Create a project.
- Create a network.
- Add a node to the network.
- 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:
- Corda Single Notary — single-notary
- Hyperledger Fabric Raft — raft
- Quorum Raft — raft
- Quorum IBFT — ibft
- MultiChain round-robin — round-robin.
 
- Corda Single Notary — 
- NODE_NAME — any name you want to give to your first peer node deployed as part of the network.
- NODE_TYPE — dedicatedis the only available option for consortium networks.
- NODE_ROLE — use the peervalue 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.