//
you're reading...
Blockchain, Cryptocurrencies, Ethereum, web3j

Manage ether hardware wallets from the command line with web3j + Infura

I recently purchased a Ledger Nano S which is a great little hardware wallet that caters for both Bitcoin and Ether.

Prior to purchasing my hardware wallet I had a lot of Ether in Ethereum wallet files on disk, which isn't a sustainable strategy for storing any cryptocurrency. Using the web3j command line tools with Infura, I was able to transfer my Ether holdings from my local wallet file to the hardware wallet by simply downloading the latest version of the tools and requesting the transfer via an Infura node.

All of the transaction signing happens offline on your machine within web3j (you can view the code here). The signed message is then sent to an Infura node which validates and propagates the transaction for you, so you don't need to worry about any syncing the blockchain yourself. As Infura is available over HTTP port 443, you can even do this behind a corporate firewall!

$ ./web3j-1.0.8/bin/web3j wallet send ~/.ethereum/keystore/<walletfile> 0x<destination address>

              _      _____ _     _        
             | |    |____ (_)   (_)       
__      _____| |__      / /_     _   ___  
\ \ /\ / / _ \ '_ \     \ \ |   | | / _ \ 
 \ V  V /  __/ |_) |.___/ / | _ | || (_) |
  \_/\_/ \___|_.__/ \____/| |(_)|_| \___/ 
                         _/ |             
                        |__/              

Please enter your existing wallet file password: 
Wallet for address 0x<source address> loaded
Please confirm address of running Ethereum client you wish to send the transfer request to [http://localhost:8545/]: https://mainnet.infura.io/<infura token>
Connected successfully to client: Parity//v1.4.4-beta-a68d52c-20161118/x86_64-linux-gnu/rustc1.13.0
What amound would you like to transfer (please enter a numeric value): 10
Please specify the unit (ether, wei, ...) [ether]: ether
Please confim that you wish to transfer 10 ether (10000000000000000000 wei) to address 0x<destination address>
Please type 'yes' to proceed: yes
Commencing transfer (this may take a few minutes) ............................................................................................................................$

Funds have been successfully transferred from 0x<source address> to 0x<destination address>
Transaction hash: 0x<tx hash>
Mined block number: 2673468

If you want to manage Ether from the command line, I encourage you to use the web3j command line tools. The whole process couldn't be simpler.

Discussion

No comments yet.

Leave a Comment

Your email address will not be published. Required fields are marked *