Skip to content

Instantly share code, notes, and snippets.

@hm0429
Created March 11, 2018 01:39
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 hm0429/b1ccecd7bfaf6228eadf49afeecfd919 to your computer and use it in GitHub Desktop.
Save hm0429/b1ccecd7bfaf6228eadf49afeecfd919 to your computer and use it in GitHub Desktop.
var Wallet = require('ethereumjs-wallet');
var EthUtil = require('ethereumjs-util');
// 既存の privateKey を使用して、wallet インスタンスを取得
const privateKeyBuffer = EthUtil.toBuffer('0x61ce8b95ca5fd6f55cd97ac60817777bdf64f1670e903758ce53efc32c3dffeb');
const wallet = Wallet.fromPrivateKey(privateKeyBuffer);
// ウォレットの秘密鍵を取得
const privateKey = wallet.getPrivateKeyString();
console.log(privateKey);
// ウォレットの公開鍵を取得
const publicKey = wallet.getPublicKeyString();
console.log(publicKey);
// ウォレットのアドレスを取得
const address = wallet.getAddressString();
console.log(address);
// keystore の名前を取得
const keystoreFilename = wallet.getV3Filename();
console.log(keystoreFilename);
// keystore (JSONフォーマット) を取得
const keystore = wallet.toV3("PASSWORD");
console.log(keystore);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment