Skip to content

Node manager API

Module: gex.manager()

Create mChain

mChain is used to execute transactions and smart contracts.

Method: createMchain(storageBytes, lifetime, maxNodes, deposit, name)
Type: transaction

Params:
- storage bytes - lifetime of the chain (in seconds) - number of nodes in chain - deposit

Usage:

let storageBytes = 1111;
let lifetime = 355;
let maxNodes = 123;
let deposit = 4444;
let name = 'test';
gex.manager().createMchain(storageBytes, lifetime, maxNodes, deposit);

Create aggregation mChain

Method: createAggregationMchain(storageBytes, lifetime, maxNodes, deposit, name)
Type: transaction

Params:
- storage bytes - lifetime of the chain (in seconds) - number of nodes in chain - deposit

Usage:

let storageBytes = 245678;
let lifetime = 3456789;
let maxNodes = 444;
let deposit = 8909;
let name = 'test';
gex.manager().createAggregationMchain(storageBytes, lifetime, maxNodes, deposit, name);

Get basic mChain

Get info for basic Mchain by id

Method: getMchain(id)
Type: call

Params:
- id: mChain id (integer)

Usage:

async function test() {
  let Mchain = await gex.manager().getMchain(2);
  console.log(Mchain);
}

Get basic mChain list (with info)

Get an array of basic mChains for current account (with info)

Method: getMchainListInfo()
Type: call

Usage:

async function test() {
  let MchainsInfo = await gex.manager().getMchainListInfo();
  console.log(MchainsInfo);
}

Get basic mChain list (id only)

async function test() {
  let MchainsIds = await gex.manager().getMchainList();
  console.log(MchainsIds);
}

Same for aggregation mChains:

async function test() {
  let aggrMchainsIds = await gex.manager().getAggregationMchainList();
  let aggrMchain = await gex.manager().getAggregationMchain(2);
  let aggrMchains = await gex.manager().getAggregationMchainListInfo();
}

Get list of mChains for aggregation mChain

Method: getMchainListInfoFromAggregationMchain(id)
Type: call

Params:
- id: id of aggregation mChain

Returns:
- Array of mChain objects:

{
  mChainID: String;
  owner: String;
  name: String;
  storageBytes: String;
  lifetime: String; // in seconds
  creationDate: String; // in seconds
  maxNodes: String;
  deposit: String
}

Usage:

let mChains = await gex.manager().getMchainListInfoFromAggregationMchain(id);

Withdraw from mChain

Method: withdrawFromMchain()
Type: transaction

Params: - index: Index of mchain in the mchains list

Usage:

gex.manager().withdrawFromMchain(4);

Withdraw from aggregation mChain

Method: withdrawFromAggregationMchain()
Type: transaction

Params: - index: Index of aggregation mchain in the aggregationMchain list

Usage:

gex.manager().withdrawFromAggregationMchain(4);

Node functions (dev only)

Create node

Method: createNode()
Type: transaction

Params: - ip (integer) - port (integer)

Usage:

// lib init, then:
let ip = '255.255.255.255';
let port = 6000;
gex.manager().createNode(ip, port);