I am trying to change the default address used by the wallet
to send transactions.
let wallet = Wallet.fromMnemonic('hurdle cloud ...').connect(provider);
wallet.address // 0xfB98c...
How do I change the wallet
's address to another address from the same private key? I feel like this should be obvious but digging through the documentation it doesn't appear possible.
Edit
Given that a single private key only has a single public key (and public address), the question needs adjusting. How would it be possible to generate new private keys (and therefore public addresses) from this mnemonic using ethers.js?
Best Answer
You can use an HDNode which is defined as:
When you use this HDNode, you can change the path variable you give it in order to get different private/public key pairs that are derived from this HDNode.
You can learn more about the path variable here. For Ethereum wallets, the default address / private key used is at path:
m/44'/60'/0'/0/0
. To follow the outlined protocol, for ethereum addresses, you can change the account and/or index fields:m/44'/60'/1'/0/0
m/44'/60'/0'/0/1