{"id":13906046,"url":"https://github.com/nknorg/nkn-sdk-js","last_synced_at":"2026-02-12T06:40:16.990Z","repository":{"id":37407060,"uuid":"240843864","full_name":"nknorg/nkn-sdk-js","owner":"nknorg","description":"JavaScript Implementation of NKN Client and Wallet SDK","archived":false,"fork":false,"pushed_at":"2025-03-28T02:43:41.000Z","size":6104,"stargazers_count":44,"open_issues_count":2,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-26T16:58:06.459Z","etag":null,"topics":["blockchain","javascript","nkn","p2p"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nknorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-16T06:32:25.000Z","updated_at":"2025-08-28T02:41:55.000Z","dependencies_parsed_at":"2024-06-19T04:10:12.604Z","dependency_job_id":"86076589-564c-4eae-a6da-3d1e3c4d791b","html_url":"https://github.com/nknorg/nkn-sdk-js","commit_stats":{"total_commits":95,"total_committers":5,"mean_commits":19.0,"dds":0.2947368421052632,"last_synced_commit":"e058fbef443a2bdb0c5b4fb4abc56d164747150a"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/nknorg/nkn-sdk-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknorg%2Fnkn-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknorg%2Fnkn-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknorg%2Fnkn-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknorg%2Fnkn-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nknorg","download_url":"https://codeload.github.com/nknorg/nkn-sdk-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nknorg%2Fnkn-sdk-js/sbom","scorecard":{"id":690266,"data":{"date":"2025-08-11","repo":{"name":"github.com/nknorg/nkn-sdk-js","commit":"a10c62873dc518731d1e3bd06b326ca110b551ef"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":2,"reason":"Found 6/22 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"19 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-7wwv-vh3v-89cq","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4","Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2","Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-9q5w-79cv-947m","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq","Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T02:09:36.444Z","repository_id":37407060,"created_at":"2025-08-22T02:09:36.444Z","updated_at":"2025-08-22T02:09:36.444Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29360644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","javascript","nkn","p2p"],"created_at":"2024-08-06T23:01:28.507Z","updated_at":"2026-02-12T06:40:16.961Z","avatar_url":"https://github.com/nknorg.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# nkn-sdk-js\n\n[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/nknorg/nkn-sdk-js/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/nkn-sdk.svg?style=flat)](https://www.npmjs.com/package/nkn-sdk) [![CircleCI Status](https://circleci.com/gh/nknorg/nkn-sdk-js.svg?style=shield\u0026circle-token=:circle-token)](https://circleci.com/gh/nknorg/nkn-sdk-js) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)\n\n![nkn](logo.png)\n\nJavaScript implementation of NKN client and wallet SDK. The SDK consists of a\nfew components:\n\n- [NKN Client](#client): Send and receive data for free between any NKN clients\n  regardless their network condition without setting up a server or relying on\n  any third party services. Data are end to end encrypted by default. Typically\n  you might want to use [multiclient](#multiclient) instead of using client\n  directly.\n\n- [NKN MultiClient](#multiclient): Send and receive data using multiple NKN\n  clients concurrently to improve reliability and latency. In addition, it\n  supports session mode, a reliable streaming protocol similar to TCP based\n  on [ncp](https://github.com/nknorg/ncp-js).\n\n- [NKN Wallet](#wallet): Wallet SDK for [NKN\n  blockchain](https://github.com/nknorg/nkn). It can be used to create wallet,\n  transfer token to NKN wallet address, register name, subscribe to topic,\n  etc.\n\nAdvantages of using NKN client/multiclient for data transmission:\n\n- Network agnostic: Neither sender nor receiver needs to have public IP address\n  or port forwarding. NKN clients only establish outbound (websocket)\n  connections, so Internet access is all they need. This is ideal for client\n  side peer to peer communication.\n\n- Top level security: All data are end to end authenticated and encrypted. No\n  one else in the world except sender and receiver can see or modify the content\n  of the data. The same public key is used for both routing and encryption,\n  eliminating the possibility of man in the middle attack.\n\n- Decent performance: By aggregating multiple overlay paths concurrently,\n  multiclient can get ~100ms end to end latency and 10+mbps end to end session\n  throughput between international devices.\n\n- Everything is free, open source and decentralized. (If you are curious, node\n  relay traffic for clients for free to earn mining rewards in NKN blockchain.)\n\nDocumentation:\n[https://docs.nkn.org/nkn-sdk-js](https://docs.nkn.org/nkn-sdk-js).\n\n## Install\n\nFor npm:\n\n```shell\nnpm install nkn-sdk\n```\n\nAnd then in your code:\n\n```javascript\nconst nkn = require('nkn-sdk');\n```\n\nor using ES6 import:\n\n```javascript\nimport nkn from 'nkn-sdk';\n```\n\nFor browser, use `dist/nkn.js` or `dist/nkn.min.js`.\n\nFor environment where cryptographically secure random number generator is not\nnatively implemented (e.g. React Native), see [Random bytes\ngeneration](#random-bytes-generation).\n\n## Client\n\nNKN client provides the basic functions of sending and receiving data between\nNKN clients or topics regardless their network condition without setting up a\nserver or relying on any third party services. Typically you might want to use\n[multiclient](#multiclient) instead of using client directly.\n\nCreate a client with a generated key pair:\n\n```javascript\nlet client = new nkn.Client();\n```\n\nOr with an identifier (used to distinguish different clients sharing the same\nkey pair):\n\n```javascript\nlet client = new nkn.Client({\n  identifier: 'any-string',\n});\n```\n\nGet client secret seed and public key:\n\n```javascript\nconsole.log(client.getSeed(), client.getPublicKey());\n```\n\nCreate a client using an existing secret seed:\n\n```javascript\nlet client = new nkn.Client({\n  seed: '2bc5501d131696429264eb7286c44a29dd44dd66834d9471bd8b0eb875a1edb0',\n});\n```\n\nSecret key should be kept **SECRET**! Never put it in version control system\nlike here.\n\nBy default the client will use bootstrap RPC server (for getting node address)\nprovided by nkn.org. Any NKN full node can serve as a bootstrap RPC server. You\ncan create a client using customized bootstrap RPC server:\n\n```javascript\nlet client = new nkn.Client({\n  rpcServerAddr: 'https://ip:port',\n});\n```\n\nGet client NKN address, which is used to receive data from other clients:\n\n```javascript\nconsole.log(client.addr);\n```\n\nListen for connection established:\n\n```javascript\nclient.onConnect(() =\u003e {\n  console.log('Client ready.');\n});\n```\n\nSend text message to other clients:\n\n```javascript\nclient.send(\n  'another-client-address',\n  'hello world!',\n);\n```\n\nYou can also send byte array directly:\n\n```javascript\nclient.send(\n  'another-client-address',\n  Uint8Array.from([1,2,3,4,5]),\n);\n```\n\nThe destination address can also be a name registered using [wallet](#wallet).\n\nPublish text message to all subscribers of a topic (subscribe is done through\n[wallet](#wallet)):\n\n```javascript\nclient.publish(\n  'topic',\n  'hello world!',\n);\n```\n\nReceive data from other clients:\n\n```javascript\nclient.onMessage(({ src, payload }) =\u003e {\n  console.log('Receive message', payload, 'from', src);\n});\n```\n\nIf a valid data (string or Uint8Array) is returned at the end of the handler,\nthe data will be sent back to sender as reply:\n\n```javascript\nclient.onMessage(({ src, payload }) =\u003e {\n  return 'Well received!';\n});\n```\n\nHandler can also be an async function, and reply can be byte array as well:\n\n```javascript\nclient.onMessage(async ({ src, payload }) =\u003e {\n  return Uint8Array.from([1,2,3,4,5]);\n});\n```\n\nNote that if multiple message handlers are added, the result returned by the\nfirst handler (in the order of being added) will be sent as reply.\n\nThe `send` method will return a Promise that will be resolved when sender\nreceives a reply, or rejected if not receiving reply or acknowledgement within\ntimeout period. Similar to message, reply can be either string or byte array:\n\n```javascript\nclient.send(\n  'another-client-address',\n  'hello world!',\n).then((reply) =\u003e {\n  // The reply here can be either string or Uint8Array\n  console.log('Receive reply:', reply);\n}).catch((e) =\u003e {\n  // This will most likely to be timeout\n  console.log('Catch:', e);\n});\n```\n\nClient receiving data will automatically send an acknowledgement back to sender\nif message handler returns `null` or `undefined` so that sender will be able to\nknow if the packet has been delivered. On the sender's side, it's almost the\nsame as receiving a reply, except that the Promise is resolved with `null`:\n\n```javascript\nclient.send(\n  'another-client-address',\n  'hello world!',\n).then(() =\u003e {\n  console.log('Receive ACK');\n}).catch((e) =\u003e {\n  // This will most likely to be timeout\n  console.log('Catch:', e);\n});\n```\n\nIf handler returns `false`, no reply or ACK will be sent.\n\nCheck [examples/client.js](examples/client.js) for complete examples and\n[https://docs.nkn.org/nkn-sdk-js](https://docs.nkn.org/nkn-sdk-js) for full\ndocumentation.\n\n## MultiClient\n\nMultiClient creates multiple NKN client instances by adding identifier prefix\n(`__0__.`, `__1__.`, `__2__.`, ...) to a NKN address and send/receive packets\nconcurrently. This will greatly increase reliability and reduce latency at the\ncost of more bandwidth usage (proportional to the number of clients).\n\nMultiClient basically has the same API as [client](#client), with a few\nadditional initial configurations and session mode:\n\n```javascript\nlet multiclient = new nkn.MultiClient({\n  numSubClients: 4,\n  originalClient: false,\n});\n```\n\nwhere `originalClient` controls whether a client with original identifier\n(without adding any additional identifier prefix) will be created, and\n`numSubClients` controls how many sub-clients to create by adding prefix\n`__0__.`, `__1__.`, `__2__.`, etc. Using `originalClient: true` and\n`numSubClients: 0` is equivalent to using a standard NKN Client without any\nmodification to the identifier. Note that if you use `originalClient: true` and\n`numSubClients` is greater than 0, your identifier should not starts with\n`__X__` where `X` is any number, otherwise you may end up with identifier\ncollision.\n\nAny additional options will be passed to NKN client.\n\nMultiClient instance shares most of the public API as regular NKN client, see\n[client](#client) for usage and examples. If you need low-level property or API,\nyou can use `multiclient.defaultClient` to get the default client and\n`multiclient.clients` to get all clients.\n\nCheck [examples/client.js](examples/client.js) for complete examples and\n[https://docs.nkn.org/nkn-sdk-js](https://docs.nkn.org/nkn-sdk-js) for full\ndocumentation.\n\n### Session\n\nIn addition to the default packet mode, multiclient also supports session mode,\na reliable streaming protocol similar to TCP based on\n[ncp](https://github.com/nknorg/ncp-js).\n\nListens for incoming sessions (without `listen()` no sessions will be accepted):\n\n```javascript\nmulticlient.listen();\n```\n\nDial a session:\n\n```javascript\nmulticlient.dial('another-client-address').then((session) =\u003e {\n  console.log(session.localAddr, 'dialed a session to', session.remoteAddr);\n});\n```\n\nAccepts for incoming sessions:\n\n```javascript\nmulticlient.onSession((session) =\u003e {\n  console.log(session.localAddr, 'accepted a session from', session.remoteAddr);\n});\n```\n\nWrite to session:\n\n```javascript\nsession.write(Uint8Array.from([1,2,3,4,5])).then(() =\u003e {\n  console.log('write success');\n});\n```\n\nRead from session:\n\n```javascript\nsession.read().then((data) =\u003e {\n  console.log('read', data);\n});\n```\n\n`session.read` also accepts a `maxSize` parameter, e.g. `session.read(maxSize)`.\nIf `maxSize \u003e 0`, at most `maxSize` bytes will be returned. If `maxSize == 0` or\nnot set, the first batch of received data will be returned. If `maxSize \u003c 0`,\nall received data will be concatenated and returned together.\n\nSession can be converted to WebStream using `session.getReadableStream()` and\n`session.getWritableStream(closeSessionOnEnd = false)`. Note that WebStream is\nnot fully supported by all browser, so you might need to polyfill it globally or\nsetting `session.ReadableStream` and `session.WritableStream` constructors.\n\nCheck [examples/session.js](examples/session.js) for complete example or try\ndemo file transfer web app at [https://nftp.nkn.org](https://nftp.nkn.org) and\nits source code at\n[https://github.com/nknorg/nftp-js](https://github.com/nknorg/nftp-js).\n\n## Wallet\n\nNKN Wallet SDK.\n\nCreate a new wallet with a generated key pair:\n\n```javascript\nlet wallet = new nkn.Wallet({ password: 'password' });\n```\n\nCreate wallet from a secret seed:\n\n```javascript\nlet wallet = new nkn.Wallet({\n  seed: wallet.getSeed(),\n  password: 'new-wallet-password',\n});\n```\n\nExport wallet to JSON string:\n\n```javascript\nlet walletJson = wallet.toJSON();\n```\n\nLoad wallet from JSON and password:\n\n```javascript\nlet wallet = nkn.Wallet.fromJSON(walletJson, { password: 'password' });\n```\n\nBy default the wallet will use RPC server provided by nkn.org. Any NKN full node\ncan serve as a RPC server. You can create a wallet using customized RPC server:\n\n```javascript\nlet wallet = new nkn.Wallet({\n  password: 'password',\n  rpcServerAddr: 'https://ip:port',\n});\n```\n\nVerify whether an address is a valid NKN wallet address:\n\n```javascript\nconsole.log(nkn.Wallet.verifyAddress(wallet.address));\n```\n\nVerify password of the wallet:\n\n```javascript\nconsole.log(wallet.verifyPassword('password'));\n```\n\nGet balance of this wallet:\n\n```javascript\nwallet.getBalance().then((value) =\u003e {\n  console.log('Balance for this wallet is:', value.toString());\n});\n```\n\nTransfer token to another wallet address:\n\n```javascript\nwallet.transferTo(wallet.address, 1, { fee: 0.1, attrs: 'hello world' }).then((txnHash) =\u003e {\n  console.log('Transfer transaction hash:', txnHash);\n});\n```\n\nSubscribe to a topic for this wallet for next 100 blocks (around 20 seconds per\nblock), client using the same key pair (seed) as this wallet and same identifier\nas passed to `subscribe` will be able to receive messages from this topic:\n\n```javascript\nwallet.subscribe('topic', 100, 'identifier', 'metadata', { fee: '0.1' }).then((txnHash) =\u003e {\n  console.log('Subscribe transaction hash:', txnHash);\n});\n```\n\nCheck [examples/wallet.js](examples/wallet.js) for complete examples and\n[https://docs.nkn.org/nkn-sdk-js](https://docs.nkn.org/nkn-sdk-js) for full\ndocumentation.\n\n## Random bytes generation\n\nBy default, this library uses the same random bytes generator as\n[tweetnacl-js](https://github.com/dchest/tweetnacl-js).\n\nIf a platform you are targeting doesn't implement secure random number\ngenerator, but you somehow have a cryptographically-strong source of entropy\n(not `Math.random`!), and you know what you are doing, you can plug it like\nthis:\n\n```javascript\nnkn.setPRNG(function(x, n) {\n  // ... copy n random bytes into x ...\n});\n```\n\nAn example using node.js native crypto library:\n\n```javascript\ncrypto = require('crypto');\nnkn.setPRNG(function(x, n) {\n  var i, v = crypto.randomBytes(n);\n  for (i = 0; i \u003c n; i++) x[i] = v[i];\n  // clean up v\n});\n```\n\nNote that `setPRNG` *completely replaces* internal random byte generator\nwith the one provided.\n\n## Disable WASM\n\nYou can disable WASM and use pure JavaScript implementation by:\n\n```javascript\nnkn.setDisableWASM(true);\n```\n\n## Contributing\n\n**Can I submit a bug, suggestion or feature request?**\n\nYes. Please open an issue for that.\n\n**Can I contribute patches?**\n\nYes, we appreciate your help! To make contributions, please fork the repo, push\nyour changes to the forked repo with signed-off commits, and open a pull request\nhere.\n\nPlease sign off your commit. This means adding a line \"Signed-off-by: Name\n\u003cemail\u003e\" at the end of each commit, indicating that you wrote the code and have\nthe right to pass it on as an open source patch. This can be done automatically\nby adding -s when committing:\n\n```shell\ngit commit -s\n```\n\n## Community\n\n- [Forum](https://forum.nkn.org/)\n- [Discord](https://discord.gg/c7mTynX)\n- [Telegram](https://t.me/nknorg)\n- [Reddit](https://www.reddit.com/r/nknblockchain/)\n- [Twitter](https://twitter.com/NKN_ORG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnknorg%2Fnkn-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnknorg%2Fnkn-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnknorg%2Fnkn-sdk-js/lists"}