-
Network environment: should select dev environment, qa, test or main.
import { NetworkEnv } from "grid3_client"; const network = NetworkEnv.dev
-
Mnemonic: 12 words for your account. create one
-
Store secret: it's any word that will be used for encrypting/decrypting the keys on threefold key-value store.
-
Create RMB client
grid 3 client supports communication over RMB MessageBusClient or HTTP HTTPMessageBusClient using one of the deployed grid3 proxies.
HTTP
import { HTTPMessageBusClient } from "ts-rmb-http-client"; const rmb = new HTTPMessageBusClient(0, "", "", "");
Note: twinId and proxyURL are set to
0
and""
as the grid client will auto set them based on network environment selected and mnemonic entered.RMB
import { MessageBusClient } from "ts-rmb-redis-client"; const rmb = new MessageBusClient();
-
project name: it's a name to isolate the deployments into a namespace.
Note: only network can't be isolated, all project can see the same network.
-
Backend storage: can select
fs
,localstorage
,auto
, ortfkvstore
. (default: auto)Note: selecting
auto
will auto detect the process if it's node it will usefs
and if it's browser it will uselocalstorage
.
import { BackendStorageType } from "grid3_client";
const backendStorageType = BackendStorageType.auto
- keypair type: the keypair types supported are
sr25519
ored25519
. (default:sr25519
)
import { KeypairType } from "grid3_client";
const keypairType = KeypairType.sr25519
By gathering all the previous configuration in one script.
import { GridClient, NetworkEnv, BackendStorageType, KeypairType } from "grid3_client";
import { HTTPMessageBusClient } from "ts-rmb-http-client";
import { MessageBusClient } from "ts-rmb-redis-client";
// use http proxy client
const rmb = new HTTPMessageBusClient(0, "", "", "");
const gridClient = new GridClient(NetworkEnv.dev, mnemonic, "mysecret", rmb, "myproject", BackendStorageType.auto, KeypairType.sr25519);
await gridClient.connect();
Important Note: grid client should be disconnected after finishing its usage.
gridClient.disconnect();