Skip to content

Commit

Permalink
updated document
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLaw committed May 3, 2019
1 parent 843ea0b commit 8803597
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
- added qr-library.
- generate QRcode by string.
- generate image base64 string by string.

## v0.2.0
- added QRcode base class
- added AccountQR Class
- added ContactQR Class
- added TransactionQR Class
- added ObjectQR Class
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { QRCodeGenerator } from 'nem2-qr-library';

// (Optional) create transfer transaction (or read from network)
const transfer = TransferTransaction.create(
Deadline.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
Expand All @@ -40,6 +40,22 @@ const request = QRCodeGenerator.createTransactionRequest(transfer);
const base64 = request.toBase64();
```

### Generate QRCode for a custom object

```typescript
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:

```html
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8803597

Please sign in to comment.