Skip to main content

LSP5 - Received Assets

Standard Document

Introduction

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.

Explorers like Etherscan are currently responsible for listing all the tokens each address owns. They do so through their API by scanning the entire network of Ethereum, including the balance on each token contract and potential interacting address. As a result, keeping track of the user's owned assets and balances relies on such centralized services.

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. LSP5 removes the problem listed above by storing the addresses of the tokens you own directly inside your UP storage or any contract that implements LSP5.

What does this standard represent?

Recommendation

Make sure to understand the ERC725Y Generic Key/Value Store and LSP2 - ERC725YJSONSchema Standards before going through the ERC725Y Data Keys.

This Metadata standard describes two data keys that can be added to an ERC725Y smart contract to reference and keep track of received assets.

LSP5ReceivedAssets[]

This data key represents a list of all tokens and NFTs currently owned by the contract.

{
"name": "LSP5ReceivedAssets[]",
"key": "0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b",
"keyType": "Array",
"valueType": "address",
"valueContent": "Address"
}
Recommendation

It is advised to query the LSP5ReceivedAssets[] data key to verify if a contract supports the LSP5 - ReceivedAsset standard.

LSP5ReceivedAssetsMap

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 LSP5ReceivedAssets[] Array where the received asset addresses are stored.

The LSP5ReceivedAssetsMap data key also helps to prevent adding duplications to the array when automatically added via smart contract (_e.g., _ an LSP1-UniversalReceiverDelegate).

{
"name": "LSP5ReceivedAssetsMap:<address>",
"key": "0x812c4334633eb816c80d0000<address>",
"keyType": "Mapping",
"valueType": "(bytes4,uint128)",
"valueContent": "(Bytes4,Number)"
}

Flow

Note

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.

note

Check the token transfer scenario for more details.

Token transfer detailed flow

LSP5 Received Assets Flow