Skip to content

Instantly share code, notes, and snippets.

@lengshuiyulangcn
Created March 2, 2018 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengshuiyulangcn/f77cd9378a77aebace2cbfcc8f9790cd to your computer and use it in GitHub Desktop.
Save lengshuiyulangcn/f77cd9378a77aebace2cbfcc8f9790cd to your computer and use it in GitHub Desktop.
nem create account script
var nem = require("nem-sdk").default;
// Create random bytes from PRNG
var rBytes = nem.crypto.nacl.randomBytes(32);
// Convert the random bytes to hex
var privateKey = nem.utils.convert.ua2hex(rBytes);
var keyPair = nem.crypto.keyPair.create(privateKey);
var publicKey = keyPair.publicKey.toString();
//Mainnet (104): N
//Testnet (-104): T
//Mijin (96): M
var address = nem.model.address.toAddress(publicKey, -104)
console.log("--------")
console.log(`privateKey: ${privateKey}`)
console.log(`publicKey: ${publicKey}`)
console.log(`address: ${address}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment