How do I add cycles to a wallet using command lines?

To add cycles to your wallet, first make sure you have enough funds in your ledger account id:

% dfx ledger --network=ic balance
1.42550150 ICP


Then obtain your wallet address:

% dfx identity --network=ic get-wallet

In this example, the wallet address is ttk2q-5yaaa-aaaap-qadba-caa.


After obtain your wallet address, you can top-up your wallet using the dfx ledger top-up command:

% dfx ledger --network=ic top-up --amount 0.5 ttk2q-5yaaa-aaaap-qadba-caa
Transfer sent at BlockHeight: 3350701
Canister was topped up!


Then confirm that your cycle balance has increased:

% dfx wallet --network=ic balance
4.211 TC (trillion cycles).


You can also double-check that your account balance has decreased by 1 ICP:

% dfx ledger --network ic balance
0.42530150 ICP