npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gluwa/gluwa-js

v1.1.3

Published

Gluwa-JS

Downloads

8

Readme

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.

$ 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 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.

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

Create a New Transaction

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);

Create a Payment QR Code

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">

List Transaction History for an Address

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);

Retrieve Transaction Details by Hash

const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG
const Hash = '{Transaction hash}';

const resultPromise = await Gluwa.getTransactionDetail(Currency, Hash);

Retrieve a Balance for an Address

const Currency = '{USDG or sUSDCG or KRWG}'; // e.g USDG

const resultPromise = await Gluwa.getAddresses(Currency);

Webhook Validation

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);
});