https://github.com/symbol/symbol-uri-scheme
URI Scheme library for Symbol
https://github.com/symbol/symbol-uri-scheme
javascript nem scheme symbol typescript uri
Last synced: 6 months ago
JSON representation
URI Scheme library for Symbol
- Host: GitHub
- URL: https://github.com/symbol/symbol-uri-scheme
- Owner: symbol
- License: apache-2.0
- Created: 2019-04-02T00:43:29.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T03:31:03.000Z (over 2 years ago)
- Last Synced: 2024-04-17T00:05:55.598Z (about 1 year ago)
- Topics: javascript, nem, scheme, symbol, typescript, uri
- Language: TypeScript
- Homepage:
- Size: 756 KB
- Stars: 4
- Watchers: 16
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Symbol URI Scheme
[](https://badge.fury.io/js/symbol-uri-scheme)
[](https://travis-ci.com/nemfoundation/symbol-uri-scheme)
[](https://coveralls.io/github/nemtech/symbol-uri-scheme?branch=main)
[](https://symbol.slack.com/messages/CB0UU89GS//)URI Scheme library to serve Symbol transactions ready to be signed.
This is a PoC to validate the proposed [NIP2 Transaction URI Scheme](https://github.com/nemtech/NIP/issues/6). When stable, the repository will be moved to the [nemtech](https://github.com/nemtech) organization.
## Requirements
- Node.js 12 LTS
## Installation
``npm install symbol-uri-scheme``
## Usage
### Generate URI from Transaction
```ts
// examples/TransactionToURI.tsimport { Account, Deadline, EmptyMessage, Currency, NetworkType, TransferTransaction, TransactionMapping } from 'symbol-sdk';
import { TransactionURI } from '../src/uris/TransactionURI';
const epochAdjustment = 1637848847;
const serializedTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Account.generateNewAccount(NetworkType.TEST_NET).address,
[Currency.PUBLIC.createRelative(10)],
EmptyMessage,
NetworkType.TEST_NET
).serialize();const generationHash = 'ABC'; // replace with network generation hash
const nodeUrl = 'http://localhost:3000';
const webhookUrl = 'http://myapp.local/id';const transactionURI = new TransactionURI(serializedTransaction, TransactionMapping.createFromPayload, generationHash, nodeUrl, webhookUrl);
console.log(transactionURI.build());```
### Create Transaction from URI
```ts
// examples/URIToTransaction.tsimport { TransactionMapping } from 'symbol-sdk';
import { TransactionURI } from '../src/uris/TransactionURI';const serializedTransaction = 'B600000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000000000000000' +
'0000000000000000000000000000190544100000000000000005816E98404000000900FFE' +
'A45AEA2EE9B880D5E4F9B91B75857F444F1766CDCB0600010000000000CC403C7A113BDF7' +
'C80969800000000000068656C6C6F';const URI = 'web+symbol://transaction?data=' + serializedTransaction + '&generationHash=test' +
'&nodeUrl=http://localhost:3000&webhookUrl=http://myapp.local/id';
const transactionURI = TransactionURI.fromURI(URI, TransactionMapping.createFromPayload);const transaction = transactionURI.toTransaction();
console.log(transaction);```
## Getting help
Use the following available resources to get help:
- [Symbol Documentation][docs]
- Join the community [slack group (#sig-client)][slack]
- If you found a bug, [open a new issue][issues]## Contributing
Contributions are welcome and appreciated.
Check [CONTRIBUTING](CONTRIBUTING.md) for information on how to contribute.## License
Copyright 2019-present NEM
Licensed under the [Apache License 2.0](LICENSE)
[self]: https://github.com/nemtech/symbol-uri-scheme
[docs]: https://nemtech.github.io
[issues]: https://github.com/nemtech/symbol-uri-scheme/issues
[slack]: https://join.slack.com/t/nem2/shared_invite/enQtMzY4MDc2NTg0ODgyLWZmZWRiMjViYTVhZjEzOTA0MzUyMTA1NTA5OWQ0MWUzNTA4NjM5OTJhOGViOTBhNjkxYWVhMWRiZDRkOTE0YmU