Generate a random address

프로그램에서 바로 사용할 수 있는 실시간 임시 주소 생성 방법

Paper wallet

종이지갑은 오프라인에서도 사용이 가능합니다. 아래 링크를 참조하면 종이지갑에 사용할 임시 주소 생성 및 기타 목적의 임시 주소를 생성할 수 있습니다.

https://testnet.dubu4.com/paper-wallet/

Node.js

터미널에서 아래와 같이 실행합니다:

npm i https://github.com/dubu4-dev/shark-dag-js bitcore-mnemonic --save

새로운 월렛을 생성하기 위해서는 아래 코드를 참고하세요. 특히 생성된 WIF 데이터를 이용해 다양한 월렛 프로그램을 할 수 있습니다.

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

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";
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 = toWif(privKeyBuf, testnet);
const pubkey = privateKey.publicKey.toBuffer().toString('base64');
const definition = ['sig', { pubkey }];
const address = getChash160(definition);

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

Last updated

Was this helpful?