EIP-2256 Wallet owned-assets query RPC (wallet_getOwnedAssets JSON-RPC Method)
No call decision · Other · EIP status Stagnant · created 2019-08-29
Proposes a new JSON-RPC method, wallet_getOwnedAssets, that lets a dApp query, with user permission, the list of assets registered in a wallet.
Why it is needed
Today, a dApp that wants to know a user's holdings must maintain its own list of popular token addresses and ABIs, then query the blockchain separately for each asset's balance. This forces every dApp to repeat the same list-maintenance work and update its list whenever a new token appears. It also causes unwanted airdrop tokens to get mixed into the query targets, exposing asset options the user has no interest in. By contrast, the wallet already knows which assets the user has actually registered (whitelisted) in it, so a standard way to simply ask the wallet is better for both dApps and users.
What changes
Today
- dApps must maintain and manage their own list of popular token addresses and ABIs
- Each asset's balance must be checked with a separate blockchain query
- Unwanted airdrop tokens get mixed into the query and exposure targets
After EIP-2256
- A dApp receives the wallet's registered asset list with a single wallet_getOwnedAssets request
- The wallet obtains user approval and responds with only the needed assets
- The request scope can be narrowed by chain ID, asset type, and count (limit)
Who is affected
- dApp developers: Instead of managing an asset list and ABIs directly, a single standard method can query the user's assets registered in the wallet.
- Wallet developers: On receiving a wallet_getOwnedAssets request, the wallet must implement an approval UI shown to the user along with selection and trimming features.
- Users: The user can approve, deny, or modify, for each request, which assets are exposed to which dApp.
In depth
Arguments
The required argument is the address of the asset owner. An optional options object can carry chainId (an EIP-155 chain identifier), limit (the maximum number of assets the dApp expects), types (an array of desired asset interface identifiers, such as ['ERC20','ERC721']), and justification (a human-readable string explaining the purpose of the request, not required but recommended).
Result format
The response is an array of asset records. Each record includes a checksummed address, the chainId of the chain it is deployed on, an optional type (an ERC interface identifier, EIP-1820 may be used), and options carrying asset-specific details. In the ERC-20 example, options includes name, symbol, icon (base64), balance (smallest unit), and decimals, all optional if the token does not implement that field.
Recommended UI behavior
The wallet must show the request contents to the user. The user can approve or deny the request, or modify it by reducing the number of assets returned. If the entire asset set is requested, the wallet should show the total asset count; if a specific count must be selected, the user should pick directly from the list. As an optimization, the wallet can show frequently used assets first and let the rest be expanded.
Design rationale
The chainId and types parameters serve to narrow the choices shown to the user to match the dApp's functionality. limit indicates the upper bound on the number of assets the user may select; whether to set a lower bound is not yet decided and is currently treated as 1. The options response fields let the dApp use the same visual and text identifiers the wallet uses, making things easier for the user to understand, and balance is an optimization that provides already-public information without a blockchain re-query.
Relationship with EIP-747
EIP-747 is a way for a site to propose that a user add a new asset to their wallet for tracking. This EIP-2256 goes in the opposite direction, providing a way for a dApp to query assets the user has already registered (whitelisted) in their wallet, so the two proposals are complementary.
Standardization Status
This EIP's status is Stagnant, and both the Test Cases and Implementation sections of the body are left as "To be done". In other words, the proposal stalled without an actual implementation or tests, so its content may change or it may never be adopted.