Skip to content
Experimental library to generate QR specification for Catapult
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.gitignore
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
index.ts
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

nem2-qr-library

npm version Build Status Slack

⚠️ This package is currently still in development, please do not use in production. The author of this package cannot be held responsible for any loss of money or any malintentioned usage forms of this package. Please use this package with caution.

NEM2 QR Library generator to generate QR codes for Catapult (NEM2) accounts and transactions.

This is a PoC to validate the proposed NIP 7 QR Library Standard Definition. When stable, the repository will be moved to the nemtech organization.

Installation

npm install nem2-qr-library

Usage

Generate QRCode for a Transaction Request

import { QRCodeGenerator } from 'nem2-qr-library';

// (Optional) create transfer transaction (or read from network)
const transfer = TransferTransaction.create(
  Deadline.create(),
  Address.createFromPublicKey(
    'C5C55181284607954E56CD46DE85F4F3EF4CC713CC2B95000FA741998558D268',
    NetworkType.MIJIN_TEST
  ),
  [new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10000000))],
  new PlainMessage('Welcome to NEM!'),
  NetworkType.MIJIN_TEST
);

// create QR Code base64
const request = QRCodeGenerator.createTransactionRequest(transfer);

// get base64 notation for <img> HTML attribute
const base64 = request.toBase64();

Generate QRCode for a custom object

import { QRCodeGenerator } from 'nem2-qr-library';

// define custom object to suit your application use case.
const object = {"obj": "test"};

// create QR Code base64
const request = QRCodeGenerator.createExportObject(object, NetworkType.TEST_NET);

// get base64 notation for <img> HTML attribute
const base64 = request.toBase64();

The produced Base64 encoded payload can be used to display the QR Code. An example of display can be done easily with HTML, as follows:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Transfer Transaction QR code" />

Changelog

Important versions listed below. Refer to the Changelog for a full history of the project.

License

Licensed under the Apache License, Version 2.

You can’t perform that action at this time.