# How canister get the \`message.caller\`？

**URL:** https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076
**Category:** Developers
**Created:** [March 3, 2021, 8:02am UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076 "2021-03-03T08:02:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![flyq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/flyq/32/3637_2.png) [@flyq](https://forum.dfinity.org/u/flyq)
#### Post date: [March 3, 2021, 8:02am UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076/1 "2021-03-03T08:02:24Z")

</div>

I’m learning the account model of canister.  
I run [whoami example](https://github.com/dfinity/examples/blob/master/motoko/whoami/src/Main.mo#L5)，and read [Principals and caller identification](https://sdk.dfinity.org/docs/language-guide/caller-id.html).

My question is how canister get the `message.caller` when I run `dfx canister call whoami whoami`. In other blockchain system, the message.caller is getted by the signature. For different callers have different signature, the blockchain system can get the different caller.

Is there any other information about this?

---

<div class="post-metadata">

### Author: ![Ori](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Ori](https://forum.dfinity.org/u/Ori)
#### Post date: [March 3, 2021, 8:18am UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076/2 "2021-03-03T08:18:21Z")

</div>

There’s a brief overview of it here, along with another example of its usage: [Add access control with identities :: Internet Computer](https://sdk.dfinity.org/docs/developers-guide/tutorials/access-control.html)

---

<div class="post-metadata">

### Author: ![flyq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/flyq/32/3637_2.png) [@flyq](https://forum.dfinity.org/u/flyq)
#### Post date: [March 7, 2021, 3:35pm UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076/3 "2021-03-07T15:35:45Z")

</div>

I init the actor with the initializer

```auto
shared({ caller = initializer }) actor class TestCaller() {
    private stable let owner_ : Principal = initializer;

    public query func owner() : async Principal {
    	return owner_;
    };
    public shared({ caller }) func callerPrincipal() : async Principal {
        return caller;
    };
};

```

In dfx v0.6.23, the owner\_ will be the my default account’s Principal.

and I upgrade dfx to v0.6.24 today, and in dfx v0.6.24, the owner\_ will be the wallet canister’s id, for detail: [0.6.24 release note](https://sdk.dfinity.org/docs/release-notes/0.6.24-rn.html#_dfx).

This is the demo:

```auto
$ dfx canister create testcaller
Creating canister "testcaller"...
Creating the canister using the wallet canister...
Creating a wallet canister on the local network.
The wallet canister on the "local" network for user "default" is "rwlgt-iiaaa-aaaaa-aaaaa-cai"
"testcaller" canister created with canister id: "rrkah-fqaaa-aaaaa-aaaaq-cai"

$ dfx canister call testcaller owner
(principal "rwlgt-iiaaa-aaaaa-aaaaa-cai")

$ dfx canister call testcaller callerPrincipal
(principal "l73xb-uaoom-uk6vy-yjmwy-ffdjj-tfbbn-wlsve-xxy7i-5d27t-6yh3t-fqe")

```

So how to get the default account’s Principal when init the constructor, except input as a argument?

---

<div class="post-metadata">

### Author: ![enzo](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/enzo/32/268_2.png) [@enzo](https://forum.dfinity.org/u/enzo)
#### Post date: [March 9, 2021, 1:36am UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076/4 "2021-03-09T01:36:10Z")

</div>

You can get the owner by passing it as an installation argument. I’ve updated the whoami example to reflect this. You probably want something like this:

```auto
actor class TestCaller(arg : Principal) {
    public query func owner() : async Principal {
    	return arg;
    };
};

```

and then install with

```auto
dfx canister install --argument='(principal "...")'

```

---

<div class="post-metadata">

### Author: ![flyq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/flyq/32/3637_2.png) [@flyq](https://forum.dfinity.org/u/flyq)
#### Post date: [March 9, 2021, 1:56am UTC](https://forum.dfinity.org/t/how-canister-get-the-message-caller/2076/5 "2021-03-09T01:56:58Z")

</div>

Yes, passing it as an installation argument can solve it.
