# Exchange API

The following API are exclusively for Exchanges. These APIs are not reachable on default - they need to be enabled first. The Exchange APIs work with plain text secrets. This is normally not recommended for node operators, because a malicious Blockchain nodes could log users secrets and steal all assets.

# Enable Exchange Endpoints

IMPORTANT

To enable the Exchange APIs start the GNY Blockchain with the environment variable EXCHANGE_API=true

Adapt your docker-compose.yml file and pass the environment variable to the GNY Blockchain:

version: "3.3"
services:
  # db1 service omitted
  node1:
    # other keys ommitted
    environment:
      - EXCHANGE_API=true # this activates the /api/exchange endpoints
1
2
3
4
5
6
7

# Open account

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

const connection = new Connection();
const result = await connection.api.Exchange.openAccount(secret);
1
2
3
4
Name Type Required Description
secret string N gny account password

Response Parameter Description:

Name Type Description
success bool Whether login is successful
account json Account information

JSON Response Example:

{
  "account": {
    "address": "G2QEzc5BndQ2h6BsSNqimCWbSBV9L",
    "balance": '20000000000',
    "secondPublicKey": null,
    "lockHeight": '0',
    "lockAmount": '0',
    "isDelegate": 0,
    "username": null,
    "publicKey": "a87c7230d9ade987dbf612605aab652667e6303d2a1c6b2ec91a13733593bb75"
  },
  "latestBlock": {
    "height": 53,
    "timestamp": 3471490
  },
  "version": {
    "version": "1.0.0",
    "build": "Sun Feb 02 2020 19:42:18 GMT+0100 (Central European Standard Time)",
    "net": "testnet"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# Generate Account

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

const connection = new Connection();
const result = await connection.api.Exchange.generateAccount();
1
2
3
4

Request Parameter Description: none
Response Parameter Description:

Name Type Description
success bool Whether request is successful
address string Client's address
secret string gny account password
privateKey string gny account private key
publicKey string gny account public key

JSON Response Example:

{
    "address": "G318FKKb7mF3M6JCUhBqYnLiha6y",
    "secret" : "carpet pudding topple genuine relax rally problem before pill gun nation method",
    "publicKey": "c292db6ea14d518bc29e37cb227ff260be21e2e164ca575028835a1f499e4fe2",
    "privateKey": "c68434b960ef024b2a868118be7641be25e566f720a5eb12ff314022629ccc71575bf8f32b941b9e6ae1af82539689198327b73d77d22a98cdef2460c9257f7b"
}
1
2
3
4
5
6

# Generate publicKey

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

const connection = new Connection();
const result = await connection.api.Exchange.generatePublicKey(secret);
1
2
3
4

Request Parameter Description:

Name Type Required Description
secret string Y gny account password

Response Parameter Description:

Name Type Description
success bool true: response data return successfully
publicKey string public key

JSON Response Example:

{
  "success": true,
  "publicKey": "eafa6d559bf3121de489ab792dc6e5c36a5a85955f4a8bcd8508df7a43215572"
}
1
2
3
4