2

How can I generate a wallet address when given an Extended Public Key?

For example, an xpub key from Electrum?

I know this can be done with bitcoin and litecoin, is there a way to do it with Ethereum?

Thank you

3

ethereumjs-wallet does support HDWallet and let you calculate the address corresponding to an extended public key

var hdkey = require('ethereumjs-wallet/hdkey');

var extPubKey = 'xpub6ERoQFMqiUoTXAL56JpQYLq5FyXaZypJiKdsAbHKzMUQsSiJTNSMnBtYYRXxda9C6fUx6mMMqatUDNFSKxxXcpBcpPkTqVwyethpWiQN8p5';

var hdwallet = hdkey.fromExtendedKey(extPubKey);
var wallet = hdwallet.getWallet();
var address = wallet.getAddress();

console.log(`Address: 0x${address.toString('hex')}`);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.