How to get the principal of a canister in an Actor?

I want to get the principal of an actor, but

Principal.fromActor(this)

can only be used in actor class but not actor.
How can I solve this problem?

1 Like

I think you can do as following, at least it is what I do:

import Principal "mo:base/Principal";

actor Manager {

  private func helloWorld(): async {
     let self: Principal = Principal.fromActor(Manager);
  };
}
5 Likes