NodeChain EN
  • NodeChain
  • Learn
    • About NodeChain
    • Infrastructure
      • Connector
        • Wrapper APIs
      • Nodes
      • Startup script
    • License
    • Ecosystem
      • Supported APIs
      • Integrations
      • Acknowledgments
  • Develop
    • Quick start
      • Initial setup
      • Using command-line script
        • Commands
    • How-to
      • Run tests locally
      • Lint automatically with hooks
      • Integrate a new Blockchain/API
      • Connect to a public node
    • Wrapper API definition file
    • Contributing
  • Reference
    • API Reference
      • Admin
      • General Endpoints
      • REST Wrapper API
        • Bitcoin Cash
        • Bitcoin
        • Ethereum
          • ERC-20
      • JSON-RPC Wrapper API
        • Bitcoin Cash
        • Bitcoin
        • Ethereum
          • ERC-20
      • Real-Time Wrapper API
        • Bitcoin
        • Ethereum
Powered by GitBook
On this page
  • Create a Dockerfile
  • Create a Docker-compose
  • Adding a token configuration in the Connector
  • Adding the Wrapper API definition
  • Adding a default configuration
  1. Develop
  2. How-to

Integrate a new Blockchain/API

PreviousLint automatically with hooksNextConnect to a public node

Last updated 3 years ago

If you miss any Blockchain, we invite you to integrate it yourself and make a with the integration.

To do so, follow this tutorial.

Create a Dockerfile

First of all, you need to create a Dockerfile with the blockchain node. In case there is already an official, native node, you do not need to perform this step.

Dockerfiles are inside the packages directory. Each required service will implement a package in this directory.

Create a Docker-compose

The entire node architecture is routed through network-separated docker-composes in the docker-compose directory. These docker-composes are used to define the configuration of all the necessary containers on the node.

Adding a token configuration in the Connector

First, you need to create a package with the following structure in the Connector folder:

/Connector/
    /{TOKEN}/
        /rpcschemas/
            config.json
        __init.py__
        apirpc.py
        config.py
        constants.py
        handler.py
        utils.py

You have to replace {TOKEN} with the token symbol you are testing in lower case

  • __init.py__: import the necessary files

  • apirpc.py: Wrapper API implementation

  • config.py: Wrapper API configuration. It contains a class with the necessary variables.

  • constants.py: Constants file

  • handler.py: Admin API implementation for the token

  • utils.py: Some useful methods

To implement these files, you can take a look at the rest of the token packages

To maintain uniformity in the code, try to follow the standard methods already implemented in apirpc.py.

Adding the Wrapper API definition

Inside the Connector folder, there is a file called availableCurrencies.json. This file contains the definition of each one of the Wrapper APIs.

The availableCurrencies.json file defines all the information necessary to raise the API corresponding to a currency.

In order to add a Wrapper API you need to define the new Wrapper API here. Here is a template you can use:

[
  {
    "name": "${CURRENCY}",
    "token": "${TOKEN}",
    "networks": {
      "${NETWORK_1}": {
        "services": ["${DOCKER_COMPOSE_SERVICE_1}", "DOCKER_COMPOSE_SERVICE_2", ...],
        "dockerComposePath": "${PATH_TO_DOCKER-COMPOSE}",
        "configurable": [
          "${CONFIGURABLE_ENDPOINT_1}",
          "${CONFIGURABLE_ENDPOINT_2}",
          ...
        ]
      },
      "${NETWORK_2}": {
        "services": ["${DOCKER_COMPOSE_SERVICE_1}", "DOCKER_COMPOSE_SERVICE_2", ...],
        "dockerComposePath": "${PATH_TO_DOCKER-COMPOSE}",
        "configurable": [
          "${CONFIGURABLE_ENDPOINT_1}",
          "${CONFIGURABLE_ENDPOINT_2}",
          ...
        ]
      }
      ... MORE NETWORKS HERE ...
    }
  },
  ... MORE WRAPPER API DEFINITIONS HERE ...
]

Adding a default configuration

Optionally, you can create a default configuration so that you do not have to enter the configuration each time you start the node.

Go to scripts folder and create a new default configuration for your Blockchain inside the defaultConfig.json file:

[
  {
    "token": "${TOKEN}",
    "networks": {
      "${NETWORK_1}": {
        "config": {
          "${CONFIGURABLE_ENDPOINT_1}": "${ENDPOINT_1}",
          "${CONFIGURABLE_ENDPOINT_2}": "${ENDPOINT_2}"
        }
      },
      "${NETWORK_2}": {
        "config": {
          "${CONFIGURABLE_ENDPOINT_1}": "${ENDPOINT_1}",
          "${CONFIGURABLE_ENDPOINT_2}": "${ENDPOINT_2}"
        }
      }
    }
  },

Check that the token, network and configurable_endpoint match those defined in the file availableCurrencies.json

PR