LSP5 - Received Assets
Keeping track of all the tokens that an address owns is currently unfeasible.
If you want to know from which tokens you own, you need to manually import the token contract address and query the balance of your key in it each time for each token. This inconvenience brings light to the following problem: owning tokens without being aware because there are no ways of being notified about the tokens you have received in the first place.
explain the problem of Etherscan. Their API is used to scan the entire network and know the tokens that each address own. Explain that LSP5 remove that by storing the addresses of the tokens you own directly inside your UP storage.
One way to solve this problem is to create generic metadata keys that would register in the smart contract storage how many different tokens you own and the address of the transferred token contracts.
What does this standard represent?
This Metadata standard describes two data keys that can be added to an ERC725Y smart contract to reference and keep track of received assets.
This data key represents a list of all tokens and NFTs currently owned by the contract.
It is advised to query the
LSP5ReceivedAssets data key to verify if a contract supports the LSP5 - ReceivedAsset standard.
This data key represents a map key, both holding:
- an ERC165 interface ID to quickly identify the standard used by each asset smart contract (without the need to query the asset contracts directly).
- the index in the
LSP5ReceivedAssetsArray where the received asset addresses are stored.
LSP5ReceivedAssetsMap data key also helps to prevent adding duplications to the array when automatically added via smart contract (_e.g., _ an LSP1-UniversalReceiverDelegate).
The data keys are also set on the sender Universal Profile to remove the token contract address if all the balance is sent.
If set when transferring tokens, these data keys are automatically updated in the Universal Profile storage via the LSP1UniversalReceiverDelegateUP contract.
Check the token transfer scenario for more details.