Gluwa SDK for Javascript (Node.js)
If your service is developed in Node.js, the features we provide are available through the SDK. The Gluwa SDK for Node.js is a library with powerful features that enable Node.js developers to easily make requests to the Gluwa APIs.

Getting started

Install the npm package on your Node.js server.
1
$ npm install @gluwa/gluwa-js
Copied!
Never use Gluwa SDK on the client side or make your private key public.
Create and initialize a Gluwa object. Then, enter the APIKey, APISecret and WebookSecret generated from the Gluwa Dashboard, and an Ethereum wallet to manage your funds. You can use credentials from sandbox dashboard and a Rinkeby wallet if you want to test in the sandbox environment.
1
const GluwaJS = require('@gluwa/gluwa-js');
2
3
const GluwaConfig = {
4
production: {
5
APIKey: '{Your production API Key}',
6
APISecret: '{Your production API Secret}',
7
WebhookSecret: '{Your production Webhhok Secret}',
8
MasterEthereumAddress: '{Your Ethereum Address for production}',
9
MasterEthereumPrivateKey: '{Your Ethereum Private Key for production}',
10
isDev: false,
11
},
12
sandbox: {
13
APIKey: '{Your sandbox API Key}',
14
APISecret: '{Your sandbox API Secret}',
15
WebhookSecret: '{Your sandbox Webhhok Secret}',
16
MasterEthereumAddress: '{Your Ethereum Address for sandbox}',
17
MasterEthereumPrivateKey: '{Your Ethereum Private Key for sandbox}',
18
isDev: true,
19
},
20
}
21
22
const Gluwa = new GluwaJS(GluwaConfig.production);
Copied!
Now you are ready to use the Gluwa API.

Method Examples

1
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
2
const Amount = '{Send Amount}'; // e.g 1.581
3
const Target = '{Receiver`s Address}'; // e.g 0xf04349B4A760F5Aed02131e0dAA9bB99a1d1d1e5
4
5
const resultPromise = await Gluwa.postTransaction(Currency, Amount, Target);
Copied!
1
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
2
const Amount = '{Send Amount}'; // e.g 1.581
3
const Optionals = {
4
Note: '', // optional
5
MerchantOrderID: '', // optional
6
Expirty: '1800', // optional, it must be a string
7
};
8
9
const resultPromise = await Gluwa.getPaymentQRCode(Currency, Amount, Optionals);
Copied!
getPaymentQRCode API returns a QR code png image as a Base64 string. You can display the image on your website as below:
1
<img src="data:image/png;base64,{BASE64_STRING_YOU_RECEIVED}" alt="Gluwa Payment QR Code">
Copied!
1
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
2
const Optionals = {
3
Limit: '100', // optional, it must be a string
4
Offset: '0', // optional, it must be a string
5
Status: 'Confirmed', // optional
6
};
7
8
const resultPromise = await Gluwa.getTransactionHistory(Currency, Optionals);
Copied!
1
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
2
const Hash = '{Transaction hash}';
3
4
const resultPromise = await Gluwa.getTransactionDetail(Currency, Hash);
Copied!
1
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
2
3
const resultPromise = await Gluwa.getAddresses(Currency);
Copied!
When user completes transfer via the QR code, the Gluwa API sends a webhook to your webhook endpoint. Verify that the values ​​actually sent by the Gluwa server are correct.
Verify the requested Signature and Payload as follows:
1
// Payload example
2
// {"ID":"9d238b83-e5c7-4a1e-a6b4-5bf7ec1d0218","CreatedDateTime":"2021-01-06T07:46:50.2779406Z","ResourceType":"Transaction","EventName":"TRANSACTION.CREATED","Summary":"A transaction was created.","Resource":{"ID":"62e667cf-1a80-41bf-b064-925999ed5b76","TxHash":"0x89a5d4cb0f1d6b919a4ada42b661ed7b2574ec4dd2d640f5c92642bad532dbe0","Source":"0xf04349B4A760F5Aed02131e0dAA9bB99a1d1d1e5","Target":"0x084Af3876A220F4732e21F7617dc212BB2A1f32E","Amount":"10","Fee":"0.5","Currency":"sUSDCG","Status":"Confirmed"}}
3
4
// Signature example
5
// 7iPzvTRVR81cuZQetKbF1GaGPIk1UkzyvFc6hhgA+VI=
6
7
const resultBoolean = Gluwa.validateWebhook(Payload, Signature);
Copied!

How to resolve promise

All functions except Webhook Validation return promise. This can be used by resolving it like this:
1
resultPromise.then((result) => {
2
console.log(result);
3
}).catch((error) => {
4
console.warn(error);
5
});
Copied!
Last modified 7mo ago