loader


We’re excited to share that NKN just released and made open-source our Javascript Wallet this week.

What is it?

Essentially, the wallet is a JavaScript SDK that developers can use to get information, such as the balance of an NKN user’s wallet, and make payments/transfers to other accounts. It can also be used to build web and native applications that involve transactions on NKN blockchain platform.

For developers, below is a simple usage example of the wallet:

  • import
const nknWallet = require('nkn-wallet');
  • create a new wallet
const wallet = nknWallet.newWallet('pwd')
  • get wallet’s json string
const walletJson = wallet.toJSON()
  • load wallet from a wallet json string
const walletFromJson = nknWallet.loadJsonWallet(walletJson, 'pwd')
  • restore wallet from a private key
const walletFromPrivateKey = nknWallet.restoreWalletByPrivateKey('the private key', 'new-wallet-password')
  • query asset balance for this wallet
wallet.queryAssetBalance().then(function(value) {
console.log('asset balance for this wallet is: ', value.toString())
}).catch(function(error) {
console.log('query balance fail: ', error)
})
  • transfer asset to some address
wallet.transferTo(wallet.address, 100, 'pwd').then(function(data) {
console.log('success: ', data)
}).catch(function(error) {
console.log('fail: ', error)
})

The open source wallet will pave the way for future developments and adoption of NKN public testnet, which will be launched at the end of August, 2018 and experimental mining afterwards.

For more detailed guidelines and examples regarding the NKN wallet, please visit our Github: https://github.com/nknorg/nkn-wallet-js.