Hey, I am having some principal difficulties. To begin with, I have created an Internet Identity, I can login to NNS and I have some ICP as well as some ckBTC.
Now, I want to interact with the ckBTC canisters using the same principal - to make a transfer for instance. I have used the identity seed to import the identity locally. But, after successfully importing the identity, running dfx identity --network ic get-principal
does not produce the same principal.
I have also deployed a frontend canister that uses Internet Identity to IC mainnet. When I access that canister and login using Internet Identity - same account - I get a third unrelated principal.
Am I missing something basic?
I cannot answer the dfx part of your question, but the quoted section above is expected. This is by design for anonymity reasons. Each time you sign in with your II anchor on a dapp within a specific domain (including subdomain and port), a different principal is generated.
e.g.
Sign-in on aaa.com => Principal 123
Sign-in on bbb.com => Principal 456
Sign-in on ccc.com => Principal 789
So if you sign-in on NNS dapp and on another frontend dapp, then both dapps see a different principal.
1 Like
Ok, thanks for the quick reply! This question is related to BNT 6 - Point of Sale app.
Do I get this right, that the only way I can interact with the NNS ckBTC is through the NNS app?
In that case, for a POS app, I as a seller would have to accept ckBTC payments to the principal/account tied to the POS app and then transfer them to the NNS account (if that is my main “wallet”)? I cannot let the POS app manage my NNS ckBTC?
Not at all. Anyone can, and any project can, interact with the ckBTC canisters.
In my above answer, I just meant that each frontend dapp on different domain get different principal for the same anchor. Nothing less, nothing more.
Btw. for frontend dapps, just in case there is a library to interact easily with ckBTC: https://github.com/dfinity/ic-js/tree/main/packages/ckbtc
Anyway gonna stop hijacking your thread here, I guess the important part is answering the rest of your original question.
1 Like
That part I get. Let me rephrase:
App 1: NNS
Domain 1: https://nns.ic0.app/
Principal: mnq2j-ddubu…
ckBTC amount: 0.1
App 2: POS
Domain 2: https://pos.com
Principal: z5gfp-skxcd…
ckBTC: not used
From app 2, I would like to:
- Find which principal is tied to app 1 (using same internet identity)
- Interact with ckBTC tied to app 1 -
icrc1_transfer
for instance
ps. If this not possible, all good. Then POS will have to accept payments to ckBTC account tied to app 2 and then transfer.
1 Like
- Find which principal is tied to app 1
I think you cannot for good reasons (keywords no tracking, privacy and anonymous).
Two dapps though can share the same principal if alternative origins are used but I would personally say it’s unlickely that this would happen with NNS dapp and another dapp on the app subnet.
- Interact with ckBTC tied to app 1 -
icrc1_transfer
for instance
For the above reason, I would say you cannot too. The from
of an ICRC-1 transaction is the caller of the function icrc1_transfer
- i.e. the principal used in the dapp that calls the function.
Does it answer your questions?
2 Likes
Yes, thanks! I assumed some kind of ETH centric perspective by default, assuming that one internet identity controls one principal and then you use that principal to interact with canisters independent of app. Thanks for the clarification, that saves me a ton of head scratching.
Thanks you for the feedback. I have no experience with other chain, so really interesting to know!