Transfer Cycles from Canister Wallet to Principal Default Wallet

After RTFM’ing, I figured out the issue and how to pass functions to a canister via dfx canister. The original code that accepts a function works correctly in local dev, but please make sure to add access control in production(!!!). Here’s the working snippet to pass a function to dfx canister:

dfx canister call rrkah-fqaaa-aaaaa-aaaaq-cai wallet_send '(256_000_000_000, func "rwlgt-iiaaa-aaaaa-aaaaa-cai".wallet_receive)'

As shown in the opening post, in canister rrkah-fqaaa-aaaaa-aaaaq-cai, I created a wallet_send() function that accepts an amount of cycles and a function. It simply adds cycles to a wallet then executes the function and returns the amount of cycles that the sender intended to transfer. To pass a function in Candid IDL, you must pass a supported type, canister id, followed by a dot (.), and function name:

func "w7x7r-cok77-xa".hello
func "w7x7r-cok77-xa"."☃"
func "aaaaa-aa".create_canister

Read more about Candid Types below:

To read a more detailed help for dfx canister call, read the following link:

To learn how to add access control, view the tutorial here:

3 Likes