Hi there,
Working to understand how to transfer tokens between two Internet Identity users.
So far ive recevied these outputs.
I took the logged in users Principal ID and used that to interact with the icp ledger. If im getting this right, each II user has a wallet address, where i can send tokens to, yes?
I call printUserBalance from the front-end.
At a high level, you can send ICP to an Account Identifier.
An Account Identifier is a hash that is comprised of a principal ID and a subaccount.
Typically, users want to use their default account which sets the owner
to the Principal ID and subaccount
set to null
as shown in your code:
let accountArgs: {
owner: userPrincipal;
subaccount: null;
}
To get the Account Identifier from this, you are using this line of code:
let account_identifier = await icp_ledger_canister.accountIdentifier(accountArgs);
An Internet Identity can return a principal ID.
The [text representation] in Welcome Back, [text representation] should show the principal from the logged-in Internet Identity. I assume that the backend function tied to this returns msg.caller
.
It is important to note that the principal returned from the same Internet Identity changes per domain. For example, an Internet Identity logged into xyz.com will return a different principal than from same Internet Identity logged into abc.com. It’s a privacy feature that is included in Internet Identity.
There are more details that I can provide. However, for the sake of not overloading you with too much information at the moment, I suggest you review the Digital Assets Overview and the Internet Identity Specification to learn more.
1 Like