obyte.js
GitHubDiscord
0.1.1
0.1.1
  • Byteball.js
  • Getting started
    • Quick start
    • Testnet
  • Client
    • Subscribe
    • Just saying
  • API
    • Get witnesses
    • Get peers
    • Get joint
    • Get last MCI
    • Get history
    • Get attestation
    • Get attestations
    • Get bots
    • Get asset metadata
    • Get definition
    • Get balances
    • Get profile units
    • Core
      • Catchup
      • Get hash tree
      • Get light props
      • Post joint
      • Pick divisible coins for amount
  • Post
    • Address definition change
    • Attestation
    • Asset
    • Asset attestors
    • Data
    • Data feed
    • Definition template
    • Payment
    • Poll
    • Vote
    • Profile
    • Text
  • Utils
    • Generate a random address
  • About
    • About
    • Links
    • Tutorials
Powered by GitBook
On this page
  • Paper wallet
  • Node.js
  1. Utils

Generate a random address

PreviousTextNextAbout

Last updated 6 years ago

Paper wallet

To generate a new random address you can use Byteball paper wallet offline here:

Node.js

Open your terminal and run:

npm i bitcore-mnemonic byteballcore wif

Then run this script to generate a new wallet:

const Mnemonic = require('bitcore-mnemonic');
const objectHash = require('byteballcore/object_hash');
const wifLib = require('wif');

const testnet = false; // Change to "true" to generate testnet wallet

const path = testnet ? "m/44'/1'/0'/0/0" : "m/44'/0'/0'/0/0";
const version = testnet ? 239 : 128;
let mnemonic = new Mnemonic();
while (!Mnemonic.isValid(mnemonic.toString())) {
  mnemonic = new Mnemonic();
}
const xPrivKey = mnemonic.toHDPrivateKey();
const { privateKey } = xPrivKey.derive(path);
const privKeyBuf = privateKey.bn.toBuffer({ size: 32 });
const wif = wifLib.encode(version, privKeyBuf, false);
const pubkey = privateKey.publicKey.toBuffer().toString('base64');
const definition = ['sig', { pubkey }];
const address = objectHash.getChash160(definition);

console.log(
  'Seed:', mnemonic.phrase,
  '\nPath:', path,
  '\nWIF:', wif,
  '\nPublic key:', pubkey,
  '\nAddress:', address
);

https://bonuschain.github.io/byteball-paperwallet/