Chain Connector Configuration

The Chain Connector serves as a middleware linking the 2PM Node with blockchain systems. It abstracts the blockchain interface, enabling the 2PM Node to support a variety of different blockchain systems. Additionally, the Chain Connector is responsible for key management and signing tasks required by the blockchain system, ensuring the secure usage of these keys.

Downloading the Image

Copy and execute the following command to pull the Docker image:

$ docker pull 2pmmpc/2pm-chain-connector:latest

Initializing Configuration

Before launching the Connector, it is necessary to first initialize its configuration:

Start by creating a new folder named 2pm_chain_connector, which will serve as the root directory for launching the node:

$ mkdir 2pm_chain_connector

Navigate into the node's root directory and enter the following command:

$ cd 2pm_chain_connector
$ docker run -it --rm -v ${PWD}:/app 2pmmpc/2pm-chain-connector:latest init

After executing this command, a new folder named config will be created within the root directory 2pm_chain_connector. This config folder is used to store the node’s configuration files.

Modifying the Configuration File

Below is an example of a configuration file that needs to be updated according to your specific blockchain and smart contract requirements:

{
  "log": {
    "level": "debug"
  },
  "impl": "chain",
  "host": "0.0.0.0",
  "port": 4500,
  "evm": {
    "nodeAddress": "YOUR_PUBLIC_KEY",
    "privateKey": "YOUR_PRIVATE_KEY",
    "provider": "ws://localhost:8545",
    "gasPrice": "CHAIN_GAS_PRICE",
    "gasLimit": "CHAIN_GAS_LIMIT",
    "chainParam": {
      "chainId": "CHAIN_ID",
      "name": ""
    },
    "identity": {
      "contractAddress": "REPLACE_WITH_REAL_ADDRESS"
    },
    "hfl": {
      "contractAddress": "REPLACE_WITH_REAL_ADDRESS"
    },
    "datahub": {
      "contractAddress": "REPLACE_WITH_REAL_ADDRESS"
    },
    "hlr": {
      "contractAddress": "REPLACE_WITH_REAL_ADDRESS",
      "verifiers": {
        "3": "REPLACE_WITH_REAL_ADDRESS"
      }
    }
  }
}

Next, you will need to update the following configurations in the evm section of your file:

  • evm.nodeAddress and evm.privateKey: These are used to configure your blockchain wallet address and private key. You can generate these using any EVM-compatible wallet, such as MetaMask.

This wallet account will also be the one you need to use to stake $2PM before joining any subnets, and to receive rewards after performing computing tasks.

  • evm.provider: This should be set to your blockchain node's WebSocket URL.

  • evm.identity, evm.hfl, evm.datahub, and evm.hlr: These entries correspond to configurations for the IdentityContract, HFLContract, DataHub, and HLR smart contracts respectively. Each contractAddress field represents the address of the corresponding smart contract. In the evm.hlr.verifiers section, you configure addresses for zero-knowledge proof verifiers specific to different input lengths, for instance, evm.hlr.verifiers.3 refers to the address for the smart contract PlonkVerifier3.

Each subnet has corresponding contracts deployed, and you will need to look up these contracts in the subnet information section (deployed smart contracts) to find them.

Last updated