1

Would be grateful to be pointed to any resources that would allow me to do this. Thanks!

Rachel
  • 53
  • 8

1 Answers1

1

You need to first parse all the accounts in your HD wallet.

For example, if you have a Ledger Nano, there is a script here.

Or you can just generate addresses from a predefined mnemonic with ethereumjs-wallet as described here.

Finally, once you have the Nth address generated by the HD wallet you can just use:

web3.eth.sendTransaction ( { from: nthaddress, to: singleaddress, value: web3.eth.getBalanceOf( nthaddress ) - fee } )

to do the transaction

where nthaddress is the deriveAccount with the path m/xx'/yy'/0'/.. ( e.g.: "m/44'/60'/0'/0/0" )

Andy B.
  • 66
  • 7
  • Thank you so much, Andrei! I'm attempting this, but am hitting the following error: CONNECTION ERROR: Couldn't connect to node https://mainnet.infura.io. at Object.InvalidConnection (/home/ubuntu/server/node_modules/web3/lib/web3/errors.js:31:16) at HttpProvider.send (/home/ubuntu/server/node_modules/web3/lib/web3/httpprovider.js:87:18) at Eth.send [as getBalance] (/home/ubuntu/server/node_modules/web3/lib/web3/method.js:145:58) ....etc. Could you advise? I'm quite new; apologies if the solution is obvious. – Rachel Mar 05 '18 at 17:53
  • I don't know much about infura.io , all I can suggest is to run your own node (eventually a light node like this https://redd.it/6lzw8y ), sorry... – Andy B. Mar 06 '18 at 11:00