Anonymous user ids...confusing

Going through a tutorial online on Motoko and came across the concept that every user on a canister gets a user id but the strange thing is that you can send tokens to this id so that it is essentially an actual wallet address.

So every user that goes into a canister website gets automatically created a new wallet address (anonymous user id) and if this is so then how does this wallet access their funds? How and where do wallet extensions play a role here?

This is confusing me and I don’t know where I would have even come across this info if it wasn’t for this tutorial. Where can I read the entirety of how ICP works for building apps 101? I’ve read a lot so far and haven’t come across any of this.


There’s some information in the dev docs for Ledger and the ledger reference.

The concept you’re looking for is called ‘subaccount’. Every principal has a default account on the ICP ledger, but can create an (almost) infinite number of subaccounts in order to separate funds somehow. Now, many canisters need to distinguish payments by different customers/users/…, therefore they just use the user id as the subaccount identifier. It’s still the canister that controls the funds (they can just say ‘transfer x ICP out of subaccount y’), but it can distinguish to which user the funds are assigned.