obyte.js
GitHubDiscord
0.1.14
0.1.14
  • Obyte.js
  • Getting started
    • Quick start
    • Testnet
  • 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
    • Get data feed
    • Autonomous Agents
      • Dry run AA
      • Get AA state vars
      • Get AAs by base AAs
      • Get AA responses
      • Get AA response chain
    • Core
      • Catchup
      • Get hash tree
      • Get light props
      • Post joint
      • Pick divisible coins for amount
      • Heartbeat
  • Post
    • Address definition change
    • Attestation
    • Asset
    • Asset attestors
    • Data
    • Data feed
    • Definition
    • Definition template
    • Payment
    • Poll
    • Vote
    • Profile
    • Text
    • Multi
  • Client
    • Subscribe
    • Just saying
    • Requests
  • Utils
    • Sign a message
    • Validate signed message
    • Generate a random address
    • Get definition address
    • Is valid address
    • Keep connection alive
  • About
    • About
    • Links
    • Tutorials
Powered by GitBook
On this page
  • Paper wallet
  • Node.js
  1. Utils

Generate a random address

PreviousValidate signed messageNextGet definition address

Last updated 3 years ago

Paper wallet

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

Node.js

Open your terminal and run:

npm i byteball bitcore-mnemonic --save

Then run this script to generate a new wallet:

const { toWif, getChash160 } = require('byteball/lib/utils');
const Mnemonic = require('bitcore-mnemonic');

const testnet = false; // Change to "true" to generate testnet wallet
const passphrase = ''; // Add a passphrase for encryption

const path = "m/44'/0'/0'/0/0";
let mnemonic = new Mnemonic();
while (!Mnemonic.isValid(mnemonic.toString())) {
  mnemonic = new Mnemonic();
}
const xPrivKey = mnemonic.toHDPrivateKey(passphrase);
const { privateKey } = xPrivKey.derive(path);
const privKeyBuf = privateKey.bn.toBuffer({ size: 32 });
const wif = toWif(privKeyBuf, testnet);
const pubkey = privateKey.publicKey.toBuffer().toString('base64');
const definition = ['sig', { pubkey }];

const { privateKey: devicePrivateKey } = xPrivKey.derive('m/1');
const devicePubKey = devicePrivateKey.publicKey.toBuffer().toString('base64');

console.log(
  'Root private key:', xPrivKey.toString(),
  '\nSeed words:', mnemonic.phrase,
  '\nPath:', path,
  '\nWIF:', wif,
  '\nWallet public key:', pubkey,
  '\nWallet address:', getChash160(definition),
  '\nDevice address:', `0${getChash160(devicePubKey)}`
);

https://bonustrack.github.io/obyte-paperwallet/