Is it possible to call a function in a motoko canister deployed on the IC network locally from terminal?

I want to assign some access control roles to a canister deployed on the network, is it possible to do that from terminal locally or I will have to create a frontend interface in my project to do that because with candind ui only interface I don’t see how that can be possible.

I don’t quite understand what you are trying to do. Are you talking about a canister’s controllers? Those can be manipulated using dfx canister update-settings. Or are you talking about a custom canister? Then you probably have to go through something like CandidUI or dfx canister call. But in general I’d expect that it can be done

Yes it’s about canister controllers, I want to impliment this access-control system in my project, here, Internet Computer Loading, So I want the canister owner to be able to give roles to some principal IDs, locally I am doing that like this according to the tutorial:

dfx canister call access_hello assign_role '((principal "Principal_Id_of_someone"),opt variant{admin})'

But now I want to do that to a canister that is deployed on the IC newtork., I will then do some logic in the frontend so that people with principal IDs that have admin roles will only have access to certain services in the project. That’s what I want I want to achieve, I don’t know if there are other better ways to do that?.

1 Like

You can call all your canister interface by any agent, for example agentjs and use a nodejs script to do that.

1 Like

I found the solution, It’s this command:

dfx canister --network ic call <canister_name> <function_name> <function_input>