Gluwa
Gluwa Documentation
Gluwa Documentation
  • What is Gluwa
  • Change Log
    • Gluwa API Change Log
    • Gluwa Wallet Change Log
    • Gluwa Exchange Change Log
  • Get Started
    • Gluwa Mobile App
      • Gluwa Invest (Investor DAO) FAQ
      • Gluwa Invest (Fixed-Term Interest Account) FAQ
      • Create a New Gluwa Wallet
      • Restore Wallet
      • Send Gluwacoin to an address
      • Make QR Code Payments
      • Create a Signature
      • Access Private Keys
      • Non-Custodial Wallet
      • Gluwa Lottery Account FAQ
      • Fees
      • Transaction Status
      • Delete your Gluwa Account
    • Gluwa Dashboard
      • API Keys
      • Webhooks
      • Addresses
      • Transactions
    • Gluwacoin
  • Branding
    • Buttons and Marks
  • Development
    • Environments
    • QR Codes
    • Webhooks
    • Creating Signatures
    • Idempotent Requests
    • Sending Address
    • Gluwa SDK for PHP
    • Gluwa SDK for .NET
    • Gluwa SDK for Java
    • Gluwa SDK for JavaScript (Node.js)
  • API
    • API Reference
    • Authorization
    • Currency and Conversion Symbols
    • Errors and Error Codes
    • Balance
    • Fee
    • Transaction
    • Payment QR Code
    • Wrap / Unwrap
  • Exchange API
    • Exchange Webhook
    • Quote
    • Order
    • Exchange Request
    • Order Book
Powered by GitBook
On this page
  • Getting started
  • Method Examples
  • How to resolve promise
  1. Development

Gluwa SDK for JavaScript (Node.js)

PreviousGluwa SDK for JavaNextAPI Reference

Last updated 2 years ago

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.

$ npm install @gluwa/gluwa-js

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 , and an Ethereum wallet to manage your funds. Please note that the sandbox environment is deprecated and will be replaced with an alternative solution in the future.

const GluwaJS = require('@gluwa/gluwa-js');

const GluwaConfig = {
    production: {
        APIKey: '{Your production API Key}',
        APISecret: '{Your production API Secret}',
        WebhookSecret: '{Your production Webhhok Secret}',
        MasterEthereumAddress: '{Your Ethereum Address for production}',
        MasterEthereumPrivateKey: '{Your Ethereum Private Key for production}',
        isDev: false,
    },
    sandbox: {
        APIKey: '{Your sandbox API Key}',
        APISecret: '{Your sandbox API Secret}',
        WebhookSecret: '{Your sandbox Webhhok Secret}',
        MasterEthereumAddress: '{Your Ethereum Address for sandbox}',
        MasterEthereumPrivateKey: '{Your Ethereum Private Key for sandbox}',
        isDev: true,
    },
}

const Gluwa = new GluwaJS(GluwaConfig.production);

Now you are ready to use the Gluwa API.

Method Examples

const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
const Amount = '{Send Amount}'; // e.g 1.581
const Target = '{Receiver`s Address}'; // e.g 0xf04349B4A760F5Aed02131e0dAA9bB99a1d1d1e5

const resultPromise = await Gluwa.postTransaction(Currency, Amount, Target);
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
const Amount = '{Send Amount}'; // e.g 1.581
const Optionals = {
    Note: '', // optional
    MerchantOrderID: '', // optional
    Expirty: '1800', // optional, it must be a string
};

const resultPromise = await Gluwa.getPaymentQRCode(Currency, Amount, Optionals);

getPaymentQRCode API returns a QR code png image as a Base64 string. You can display the image on your website as below:

<img src="data:image/png;base64,{BASE64_STRING_YOU_RECEIVED}" alt="Gluwa Payment QR Code">
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
const Optionals = {
    Limit: '100', // optional, it must be a string
    Offset: '0', // optional, it must be a string
    Status: 'Confirmed', // optional
};

const resultPromise = await Gluwa.getTransactionHistory(Currency, Optionals);
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
const Hash = '{Transaction hash}';

const resultPromise = await Gluwa.getTransactionDetail(Currency, Hash);
const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG

const resultPromise = await Gluwa.getAddresses(Currency);

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:

// Payload example
// {"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"}}

// Signature example
// 7iPzvTRVR81cuZQetKbF1GaGPIk1UkzyvFc6hhgA+VI=

const resultBoolean = Gluwa.validateWebhook(Payload, Signature);

How to resolve promise

All functions except Webhook Validation return promise. This can be used by resolving it like this:

resultPromise.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

Gluwa Dashboard
Create a New Transaction
Create a Payment QR Code
List Transaction History for an Address
Retrieve Transaction Details by Hash
Retrieve a Balance for an Address
Webhook Validation