Skip to content

Commit

Permalink
Improve usability & reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine committed Oct 2, 2024
1 parent f00cef0 commit 3e1f691
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/top-up-cycles-ledger-account
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ set -euo pipefail

print_help() {
cat <<-EOF
Adds cyles to a given principal's main account on the cycles ledger.
Adds cyles to a given principal's main account on the local cycles ledger.
Usage: $(basename "$0") <principal|canister_name> <cycles>
E.g. $(basename "$0") bd3sg-teaaa-aaaaa-qaaba-cai 1000000000
Or $(basename "$0") my_canister 1000000000
Note: The destination account will be topped up by the desired amount minus fees.
EOF
}

Expand All @@ -18,16 +20,19 @@ print_help() {

account="$1"
sum="$2"
account="$(dfx canister id "$account")" # Converts names to canister IDs
echo "Balance before: $(dfx canister call cycles_ledger icrc1_balance_of '(record { owner = principal "'"$account"'"; subaccount = null })')"
dfx wallet send "$(dfx canister id cycles_depositor)" "$sum"
dfx canister call cycles_depositor deposit '
(
record {
to = record {
owner = principal "'"$(dfx canister id "$account")"'";
owner = principal "'"$account"'";
subaccount = null;
};
memo = null;
cycles = '"$sum"' : nat;
},
)
'
echo "Balance after: $(dfx canister call cycles_ledger icrc1_balance_of '(record { owner = principal "'"$account"'"; subaccount = null })')"

0 comments on commit 3e1f691

Please sign in to comment.