When interacting with NFTs or fungible tokens on the ICP blockchain, you will at some point be faced with two different IDs to choose from: Principal ID and Account ID. In this article, we are going to shed light into the confusion about the two IDs and give you a guide on which one to use. This article is meant to be for the general public and contains some useful links for developers looking to dive deeper.
TL;DR
- The account ID is derived from the principal ID by using a subaccount number
- You cannot derive the principal ID from an account ID
- You can send your NFTs either to your account ID or principal ID, both will arrive safely
- Never send NFTs to your NNS wallet
What are these IDs?
When viewing your profile on Yumi or other marketplaces and wallets in the IC ecosystem, you will oftentimes see your Principal ID and your Account ID:
The principal ID (PID) is your unique wallet identifier that is generated for each wallet. The account ID (AID) is derived from the principal ID and used in the ICP and NFT registries to identify the owners of ICP and NFTs. You can distinguish the two IDs by their structure; the PID is a series of 53 characters separated by hyphens and the AID is a series of 64 characters without any separator.
The principal ID is analogous to the wallet address of Ethereum wallets. The account ID adds an additional layer of privacy to the ICP wallet address and it is used in the ICP ledger and also for the owners of individual NFTs. While you have one wallet address on Ethereum, you have your PID and AID on ICP. Luckily, the relationship between them is straightforward.
How do they relate?
The account ID is the combination of the principal ID and a subaccount number with an encryption. The subaccount number can be any integer equal or larger than zero. The two (PID + subaccount) are put through SHA224 encryption which then yields the account ID. The key of the encryption is to disable the possibility to go back from the AID to the PID. This adds a step of privacy to the wallet IDs, as different AIDs can be generated for different purposes from one PID.
There are some more cryptographic steps involved in the derivation which we will spare here. For tech-savvy readers or developers looking for how to compute the AID from PID, there is a forum post in the dfinity forum which contains useful links about the derivation.
Since you can use any natural number to derive the AID from the PID, there can theoretically be an infinite number of AIDs for one PID. For example, below, you see the respective AIDs for subaccount number zero, one and two from one principal ID.
Which ID should I use?
Most wallets use the subaccount number zero to derive the AID from the PID. This is also the reason why it usually doesn’t matter if you send NFTs or ICP to your principal ID or account ID. Yumi and most wallets will derive the account ID with subaccount number zero.
In the end, the account ID is stored in the NFT registry. For this reason, you can send your NFTs to either your principal ID or account ID, as Yumi and the wallets of ICP derive the account ID with subaccount number zero from principal ID.
Some wallets, e.g. Plug, actually only allow you to send NFTs to your principal ID. For this reason, Yumi displays both IDs on the user profile, even though the account ID is the one that is stored in the registry and is the relevant ID.
How does the Internet Identity handle PIDs?
Dfinity has developed the Internet Identity (II) as a service to authenticate with applications running on ICP. Amongst other wallets like Plug, Astrox ME, Infinity wallet and Stoic, Yumi also included the II as an option to login with. It is important to understand that II is not a wallet per se, but rather an authentication service for the ICP and becomes a wallet when using it for an application. This means that the II can’t hold any tokens or NFTs by itself but only in combination with an application like Yumi. So when you log in to Yumi using the II, a principal ID and account ID are generated that can be used to hold ICP and NFTs within Yumi. This is analogous to any other wallet that you’re using to interact with Yumi.
The difference between II and other wallets is that the II generates a different Principal ID for each application that you login to. Other wallets, like Plug, use the same Principal ID for each application that you login to. An exception is Astrox ME which also offers the option to create a different Principal ID for each application.
Having a different PID for each application when logging in with II has another important implication, especially when working with the Network Nervous System (NNS) of ICP. People have confused the NNS to be the frontend wallet of II. Rather, the NNS is just another application that you can authenticate with using your II. So when logging in to the NNS with your II, you get a different PID than when logging in to Yumi. This implies also that you have a different AID on the NNS as opposed to Yumi. Since the NNS doesn’t offer any frontend to interact with NFTs, any NFTs that are sent to your NNS’ AID will be lost (or at least extremely hard to recover). Therefore, never send any NFTs to your NNS wallet address!
Summary
There are two IDs that are used on ICP. While this may add some confusion to new users, the relationship between them is straightforward and they can be used interchangeably for your experience on Yumi.
The key takeaways from this article are
- The account ID is derived from the principal ID by using a subaccount number
- You cannot derive the principal ID from an account ID
- You can send your NFTs either to your account ID or principal ID, both will arrive safely
- Never send NFTs to your NNS wallet