BloqNodes Setup

Nodes is one of the core services of Bloq. In this tutorial you will learn how to set up and start using a Bloq node on your network of choice.

Before you can create a new node, you first need to set up your Bloq account. If you have not done so, please refer to the corresponding guide.

In order to create a new node you must always use Bloq Console. We also provide the Command Line Interface (CLI) and the REST API where you can perform some other actions like retrieve node info or stop a running node.

Use the Bloq Console to Create a New Node

Log into Bloq Console to spin up a new node. You can pick among different chains and networks and you can customize the performance, the region, and the authentication type.

Once you finish with the configuration, choose the billing plan that fits best and select your payment method.

After your payment is confirmed, you will see your new node in the Nodes View and you will be able to access it.

Use the CLI to check your node info

Open the terminal and make sure that you have a valid session. If not, you can start one running bcl login.

The CLI has the nodes command which lets you list, remove or get info about your nodes. You can run bcl nodes info to retrieve your node information:

bcl nodes info -i node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
✔ Retrieved node with id node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
   * ID:    node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
   * Started At:  2019-08-01T21:55:46.612Z
   * Stopped At:  N/A
   * Chain:    btc
   * Network:    mainnet
   * Version:    core-0.17
   * Performance:  standard
   * State:    started
   * IP:    3.215.178.169
   * User:    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   * Password:    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Use the REST API to check your node info

Retrieving the node information using the REST API requires more steps than the CLI (which automates the whole authentication process). Aside from authentication, the CLI provides the same capabilities as the REST API.

As previously stated, a valid pair of client keys is required prior to using the service. The client keys let you generate your access and refresh tokens. The access token grants you access to the Nodes Service, but for security reasons, the access token is a short term token (expires after one hour). When the access token expires, you can use the refresh token (expires after one year but could be revoked) to get a new valid access token.

Generate the access and refresh tokens.

The first step is to use the client keys to generate access and refresh tokens. In this step you will request access directly to our Accounts Service.

Code Sample

curl -X POST https://accounts.bloq.cloud/auth/token
  -H 'Content-Type: application/json' \
  -d '{
  "grantType": "clientCredentials",
  "clientId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}'

Response

{
  "accessToken": "xxxxxx.xxxxxxxxxx.xxxxxx",
  "refreshToken": "xxxxxx.xxxxxxxxxx.xxxxxx"
}

To check how to renew your access token check this section

Check Node Info and PublicIpAddress

Code Sample

curl -X GET \ https://nodes.bloq.cloud/users/me/nodes/node-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
  -H 'Authorization: Bearer xxxxxx.xxxxxxxxxx.xxxxxx'

Response

{
  "stoppedAt": "2020-04-21T05:00:18.586Z",
  "serviceData": {
    "amiPrefix": "btc",
    "performance": "standard",
    "software": "core-0.17",
    "ports": [8080, 8332]
  },
  "ip": "18.213.193.254",
  "createdAt": "2020-04-21T00:45:07.687Z",
  "ttl": "1588050018",
  "user": "user-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "userPlanData": {
    "startsAt": "2020-04-21T00:45:05.324Z",
    "id": "user-plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "plan": "plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "expiresAt": "2020-05-21T00:45:05.324Z"
  },
  "instance": {
    "region": "us-east-1",
    "id": "i-02cb186c0808950f6",
    "imageId": "ami-01ee6543215d4006b"
  },
  "vendor": {
    "name": "aws",
    "subnet": "subnet-41daba24",
    "securityGroups": [
      "sg-50d39921",
      "sg-0a52e56ee0c02fd7a",
      "sg-784d5703",
      "sg-0769b9650222e64ce"
    ],
    "region": "us-east-1",
    "instanceType": "t3.large",
    "quickSync": true
  },
  "network": "mainnet",
  "state": "stopped",
  "service": "service-f409a426-8bdd-5c65-bcd3-7c6d0424a5ac",
  "auth": {
    "type": "basic",
    "user": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  },
  "updatedAt": "2020-04-21T00:45:09.419Z",
  "chain": "btc",
  "id": "node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

TIP

  • IP is the URL that you are going to use to connect and access your node.

  • At the moment, the supported chains are btc, btctestnet, bch, bchtestnet, ltc, eth, and ethropsten.

Accessing your Node

In addition to the Bloq Console, CLI, and REST API, nodes may also be accessed via interfaces supported by their chain. These include REST, JSON RPC, and WebSocket RPC. Please see the Blockchain Node API section for more information.

Accessing your BTC / BCH / LTC Node

Mainnet and testnet Bloq nodes on Bitcoin, Bitcoin Cash, and Litecoin (mainnet only) are all accessible through REST and JSON RPC interfaces. To access your node, you must use the proper IP port corresponding to the node's chain:

ProtocolChainPort

Bitcoin (BTC)

Mainnet

8332

Bitcoin

Testnet

18332

Bitcoin Cash (BCH)

Mainnet

8332

Bitcoin Cash

Testnet

18332

Litecoin (LTC)

Mainnet

9332

REST Code Sample

curl -k -X GET \
  --user <NodeUser>:<NodePass> \
  https://<ip-address>:8332/rest/chaininfo.json

JSON RPC Code Sample

curl -k -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' \
  https://<ip-address>:8332/

Response

{
  "chain": "main",
  "blocks": 567245,
  "headers": 567245,
  "bestblockhash": "0000000000000000002a127c4e914d03cac111ec2921018eb05b7e4e5516edc3",
  "difficulty": 6068891541676.553,
  "mediantime": 1552684564,
  "verificationprogress": 0.9999988860202572,
  "initialblockdownload": false,
  "chainwork": "000000000000000000000000000000000000000005712777e7fc462e2363baa4",
  "size_on_disk": 237377254316,
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": true
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "active",
      "startTime": 1462060800,
      "timeout": 1493596800,
      "since": 419328
    },
    "segwit": {
      "status": "active",
      "startTime": 1479168000,
      "timeout": 1510704000,
      "since": 481824
    }
  },
  "warnings": ""
}

Accessing Your ETH

Mainnet and Ropsten testnet Ethereum nodes are accessible through JSON and WebSocket RPC interfaces. ETH nodes do not support REST interface. To access your node, you must use the proper IP port corresponding to the node's chain. There is a different port required for JSON RPC and WebSocket RPC commands:

ProtocolChainPortInterface

Ethereum (ETH)

Mainnet

8545

JSON

Ethereum (Ropsten)

Testnet

8545

JSON

Ethereum (ETH)

Mainnet

8546

WebSocket

Ethereum (Ropsten)

Testnet

8546

WebSocket

JSON RPC Code Sample

curl -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{ "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 }' \
  https://<ip-address>:8545/

Response

{
  "jsonrpc": "2.0",
  "result": "0x981fb8",
  "id": 1
}

Accessing Your Avalanche Node

Mainnet and testnet nodes are accessible through a JSON RPC interface. Avalanche nodes listen on the following ports:

ProtocolChainPort

Avalanche (AVAX)

Mainnet

9650, 8080

Avalanche

Testnet

9650, 8080

JSON RPC Code Sample

curl -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{ "jsonrpc": "2.0", "method": "health.getLiveness", "params": [], "id": 1 }' \
  https://<ip-address>:9650/ext/health

Response

{
  "jsonrpc": "2.0",
  "result": {
    "checks": {
      "chains.default.bootstrapped": {
        "timestamp": "2020-09-17T21:27:31.776773-07:00",
        "duration": 5891,
        "contiguousFailures": 0,
        "timeOfFirstFailure": null
      },
      "network.validators.heartbeat": {
        "message": {
          "heartbeat": 1600403244
        },
        "timestamp": "2020-09-17T21:27:31.776793-07:00",
        "duration": 4000,
        "contiguousFailures": 0,
        "timeOfFirstFailure": null
      }
    },
    "healthy": true
  },
  "id": 1
}

TIP

  • Your NodeUser and NodePassword are hexadecimal strings that are accessible through CLI or REST commands above, as well as through the Console website.

  • This username/password pair is unique for each node, and separate from your Bloq username and password.

You now have everything you need to create and request data from your nodes. For more information, please refer to the Nodes Service Technical Reference.

Last updated