This document describes how to use Chain to initialize an environment instance.
Introduce the JS SDK.
Use the TLS protocol based on the node environment.
const Chain = require('@alipay/mychain/index.node')
Create a connection instance.
Take the creation of connection instances in the node environment as an example.
const Chain = require("@alipay/mychain/index.node") // Use the TLS protocol in the node environmentconst fs = require("fs")const accountKey = fs.readFileSync("./certs/user.pem", { encoding: "utf8" })const accountPassword = "123abc" // To be replaced with the user-defined user.pem passwordconst keyInfo = Chain.utils.getKeyInfo(accountKey, accountPassword)const passphrase = "123abc" // To be replaced with the user-defined client.key password//Configuration itemslet opt = {host: '127.0.0.1', //IP of the target blockchain nodeport: 18130, //Port numbertimeout: 30000, //Time configuration for the connection timeout periodcert: fs.readFileSync("./certs/client.crt", { encoding: "utf8" }),ca: fs.readFileSync("./certs/ca.crt", { encoding: "utf8" }),key: fs.readFileSync("./certs/client.key", { encoding: "utf8" }),userPublicKey: keyInfo.publicKey,userPrivateKey: keyInfo.privateKey,userRecoverPublicKey: keyInfo.publicKey,userRecoverPrivateKey: keyInfo.privateKey,passphrase: passphrase}//Initialize a connection instanceconst chain = Chain(opt)