Skip to content

Instantly share code, notes, and snippets.

@hm0429 hm0429/index.js
Created Mar 11, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.