Hardware Wallet CLI
In addition to the NNS frontend dapp that runs within a browser, the Ledger Nano hardware wallet is also supported by the ic-hardware-wallet CLI tool.
Installing ic-hardware-wallet
Installation of ic-hardware-wallet
follows the steps laid out in the file README.md, which is first installing a sufficiently recent version of Node.js and then using npm
to install the tool itself. After you completed these steps, you will be able to call ic-hardware-wallet
in your terminal.
Retrieve the principal and ICP account
After the tool ic-hardware-wallet
has been installed on your computer as described above, you can view the principal and ICP account associated with the hardware wallet by running the command ic-hardware-wallet info
. The output contains a principal whose format looks similar to this: hw5je-hd33v-7xl3v-g7t2y-aapa3-635og-fz5dz-mhma6-dthmt-kzqlk-wqe
.
Maintaining ICP
The command ic-hardware-wallet balance
will output the balance (in e8s, that is, units of 10-8 ICP) of the main ICP account associated with the hardware wallet. You can send ICP by using the ic-hardware-wallet transfer --to [64-char hex address] --amount [in e8s]
command.
Minting and maintaining ckBTC with the hardware wallet
This section contains a step-by-step guide for minting ckBTC to an account controlled by the hardware wallet. Two steps are needed as a preparation: Installing the ic-hardware-wallet tool as described above, as well as ic-repl, which can be installed by downloading a release binary from the repository.
- Obtain the main principal that is associated with your hardware wallet by running
ic-hardware-wallet info
as described above. - Compute the Bitcoin address for depositing funds. This is done as follows:
- Run
ic-repl -r ic
to enter theic-repl
CLI. - Load a non-anonymous identity, for instance via
identity default "~/.config/dfx/identity/default/identity.pem"
, this assumes that thedfx
default
identity is installed. (Other PEM-files work as well, but the actual identity does not really matter, the canister simply does not accept anonymous messages.) - Retrieve the BTC address from the ckBTC minter canister. Using the example principal from above, this is done via
call "mqygn-kiaaa-aaaar-qaadq-cai".get_btc_address(record { owner = opt principal "vcruu-d2fof-5dudt-i7txp-krvmo-65mku-lvjne-nxmp4-z6qya-zzqgc-3ae"; subaccount = null })
. Please adapt theowner
value to your hardware wallet principal. The result of this call is a BTC address, in this casebc1qelxlq9jzds3e2vfqaz9qpnj3l69ktx8sfqz384
.
- Run
- Send BTC to the address you retrieved in the previous step.
- After waiting for 12 confirmations (approximately 2 hours), use the
ic-repl
CLI to runcall "mqygn-kiaaa-aaaar-qaadq-cai".update_balance(record { owner = opt principal "vcruu-d2fof-5dudt-i7txp-krvmo-65mku-lvjne-nxmp4-z6qya-zzqgc-3ae"; subaccount = null })
, again adapting owner to your hardware wallet principal. If this step returns successful, the ckBTC will be in your wallet. - Validate the ckBTC balance by calling
ic-hardware-wallet icrc balance --canister-id mxzaz-hqaaa-aaaar-qaada-cai
.
The ckBTC controlled by the hardware wallet can then be transferred by calling ic-hardware-wallet icrc transfer --canister-id mxzaz-hqaaa-aaaar-qaada-cai --to [principal] --amount [in e8s]
and confirming the transaction on the hardware wallet.