How Can We Help?

Search for answers or browse our knowledge base.


Still need help? Ask our Service Desk!

Categories
< All Topics
Print

How to install the JavaScript API

Install GNY Client

Install by npm

npm install @gny/client

Usage

import { Connection } from "@gny/client";

const connection = new Connection();
const accountApi = connection.api.Account;

const generateAccount = async () => {
  const response = await accountApi.generateAccount();
  console.log(response);
};

(async () => {
  await generateAccount();
})();

Connection configuration

:::: tabs

::: tab mainnet

This is the mainnet configuration:

const host = "https://mainnet.gny.io";
const port = 8096;
const network = "mainnet";
const https = true;

const connection = new Connection(host, port, network, https);

:::

::: tab testnet

This is the testnet configuration:

const host = "https://testnet.gny.io";
const port = 4096;
const network = "testnet";
const https = true;

const connection = new Connection(host, port, network, https);

:::

::::

Default value

All the args of Connection are optional, and the default values are:

{
  "host": "127.0.0.1",
  "port": 4096,
  "network": "localnet",
  "https": false
}
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Previous Contract Commands
Next How to use the Exchange API
Table of Contents