Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines EIP747, which proposes a new RPC method, wallet_watchAsset, to make it easier for users to track assets in their wallets. It covers the specification as discussed in the original article published on February 25, 2024.

This article translates, summarizes, and expands on the specification linked below.

I also cover a variety of other EIPs.

Overview

This EIP standardizes a new wallet RPC (remote procedure call) method, wallet_watchAsset.

An RPC method allows a program to issue instructions to another computer over a network as though it were invoking a local function. The wallet_watchAsset method lets a client, such as a website or application, suggest that a user's cryptocurrency wallet track a token.

In other words, an application can use the method to suggest that an Ethereum wallet watch (track) a new token, such as a new cryptocurrency or a unique digital asset. If the user accepts the suggestion, the token is added to the wallet, allowing the wallet application to display information such as its balance and transaction history.

The EIP extends wallet functionality and makes it easier for users to manage different tokens. It also gives application developers a new way to improve the user experience.

Motivation

Tracking assets through an Ethereum wallet is now a common use case. Without this EIP (Ethereum Improvement Proposal), wallets need to adopt one of two approaches to tracking assets.

Preloading a list of approved assets

The wallet is responsible for maintaining the list and must bear the bandwidth costs of polling a large number of known assets. From a security perspective, the wallet must keep its approved asset list secure. Efficiently tracking large numbers of assets also requires exchanging substantial amounts of data, which consumes bandwidth.

Having users add assets to their wallets manually

This approach creates a poor user experience. Every time users want to add a new token to their wallet, they must manually enter its address and other details. This takes time and introduces the risk of entering incorrect information.

Adopting the wallet_watchAsset method proposed by this EIP addresses these problems. Applications can suggest that users' wallets track tokens, making it easier to add new assets while substantially reducing the burden on wallets.

Specification

The specification introduces a new RPC method called wallet_watchAsset. It requests that a particular asset be listed in the user's wallet. When the method is called, if the request is valid (its format and parameters are correct), it must immediately return true before presenting anything to the user. If the request is invalid, it returns an error.

The meaning of an asset being listed in the user's wallet depends on the wallet implementation. How an asset is displayed or managed varies according to the wallet's type and design.

A successful call to wallet_watchAsset indicates that the wallet recognized the request and found it valid. It does not indicate whether the user was shown a prompt (a dialog requesting confirmation or a choice), or whether the asset was actually added. A successful call therefore does not guarantee that the asset will appear in the user's wallet. The final decision about adding the asset remains with the user.

wallet_watchAsset parameters

The wallet_watchAsset method is used to request that an asset be added to a wallet. It accepts a single parameter, a WatchAssetParameters object. The object is defined as follows.

  • type
    • A string identifying the asset's interface.
    • It specifies a commonly accepted name for the interface implemented by the asset's smart contract, such as ERC1046.
  • options
    • This field can contain additional information needed to add the asset.
    • The contents of options depend on the asset type, so no particular format is defined here.

For more information about ERC1046, see the article below.

[ERC1046] Bringing ERC721-Style Metadata to ERC20 Tokens

The type field identifies the kind of interface implemented by the asset. For example, a value of ERC1046 indicates that the asset implements the ERC1046 interface. ERC1046 is an Ethereum smart contract standard defining a way to provide information about an asset.

The WatchAssetParameters interface is intended to be extended or modified according to the asset type. Such changes must be explicitly specified in a separate EIP (Ethereum Improvement Proposal). Supporting different kinds of assets may therefore require separate proposals defining requirements specific to each asset type.

wallet_watchAsset parameters

When the wallet_watchAsset method receives a request to add an asset, it immediately returns the Boolean value true to indicate that the request was recognized. The return value indicates that the request was validly processed regardless of whether anything was presented to the user. An invalid request, on the other hand, results in an error.

Possible error conditions include the following.

The asset type is unrecognized or unsupported

For a wallet to recognize an asset, it must support that asset type, such as assets conforming to a particular ERC standard. If a request specifies an unsupported asset type, the wallet cannot add it and returns an error.

The asset is blocked by an allowlist or denylist

Wallets may maintain lists of assets to allow or deny. If a requested asset violates the conditions of those lists, it is blocked from being added and the request is considered invalid. This reflects an underlying issue that developers need to address.

Image download fails

A wallet may need an asset's image to display it. If the image cannot be downloaded, the wallet cannot display the asset properly, and the request may be considered invalid.

The wallet does not load some metadata required to display the asset as a defense against SSRF

Server-side request forgery (SSRF) is an attack in which an attacker induces a server to make unauthorized requests, potentially exposing confidential information or causing unauthorized operations. To protect against such attacks, a wallet may refuse to load particular metadata. This can invalidate the request to add the asset.

These situations illustrate how wallets handle asset-addition requests and when errors may occur.

ERC1046 type

ts
interface ERC1046WatchAssetOptions {
{
    address: string; // The hexadecimal address of the token contract
    chainId?: number; // The chain ID of the asset. If empty, defaults to the current chain ID.
  };
}

The following describes the options field that the wallet_watchAsset method uses to add assets of type ERC1046 to a wallet.

The ERC1046WatchAssetOptions interface defines the format of the object used as the options parameter of wallet_watchAsset. The object contains the following fields.

  • address
    • A required field representing the hexadecimal address of the token contract.
    • The address must use checksummed hexadecimal notation beginning with 0x.
  • chainId
    • An optional field representing the ID of the chain to which the asset belongs.
    • If this field is omitted, it defaults to the current chain ID.

If the address checksum is invalid, the request is considered invalid.

The call must fail if the wallet does not recognize the chainId, or if chainId is omitted and the wallet has no concept of an active chain.

The wallet_watchAsset method must fetch the tokenURI of the ERC1046 token and examine its interop field to determine the token type. If parsing fails or the type is unknown, the RPC call results in an error.

In addition, wallet_watchAsset should compare the name and symbol fields, contract address, and chainId against a list of known tokens. If a name or symbol resembles one on the list but the chainId/address does not match, the wallet should warn the user.

To mitigate SSRF attacks, wallets should allowlist or denylist specific ports and schemes. This restricts unauthorized external requests and improves wallet security.

Legacy ERC20 type

ts
interface ERC20WatchAssetOptions {
{
    address: string; // The hexadecimal address of the token contract
    chainId?: number; // The chain ID of the asset. If empty, defaults to the current chain ID.
  };
}

The following describes the format of the options field for the legacy ERC20 type in the wallet_watchAsset method. The ERC20WatchAssetOptions interface defines the parameters used to add a legacy ERC20 token to a wallet. It contains the following fields.

  • address
    • The hexadecimal address of the token contract. This field is required and must use checksummed hexadecimal notation beginning with 0x.
  • chainId
    • The ID of the chain to which the asset belongs. This field is optional and defaults to the current chain ID if not specified.

The request is considered invalid in the following situations.

  • The address checksum is invalid.
  • The wallet does not recognize the chainId, or chainId is omitted and the wallet has no concept of an active chain.

The wallet_watchAsset method should compare the name and symbol fields, contract address, and chainId against a list of known tokens. If a name or symbol resembles one on the list but the chainId or address does not match, the wallet should warn the user.

Where possible, the ERC1046 type is recommended because it supports images and custom metadata. The ERC1046 type allows richer information and visual elements to be associated with a token, potentially improving the user experience. Whereas the legacy ERC20 type supports only basic functionality, the ERC1046 type extends how tokens can be displayed and managed.

Additional details

Users of modern DApps (decentralized applications) expect basic functionality for displaying their assets. Many wallets either maintain their own client-side asset lists or query balances through centralized APIs. The latter approach reduces decentralization and makes it possible to associate account holders with IP addresses. Periodically updating and polling an asset list over the network is also costly, particularly on devices with limited bandwidth. Maintaining an asset list can become a political activity, creating pressure or harassment to include obscure assets.

Automatically listing assets turns them into a form of spam. Users may suddenly see new assets in their wallets that they have no interest in. This can be used to send unwanted information or facilitate phishing. Airdropped tokens contribute to this phenomenon. Spamming people with new tokens has historically attracted users' attention, making such activity a major source of network congestion.

When users add assets manually, they have likely already learned about those assets through a website. At that point, the interests of both parties are aligned: both want the user to track the token. This is a natural opportunity to introduce an API that makes cooperation between the parties easier.

Security

The following considerations apply when implementing wallet functionality such as wallet_watchAsset. They focus on three main areas: server-side request forgery (SSRF), validation, and fingerprinting.

Server-side request forgery (SSRF)

Wallets must exercise caution when making requests to arbitrary URLs. A wallet could be manipulated into performing unauthorized operations, such as changing data in a locally hosted Redis database. The recommendation is therefore to sanitize URIs by allowlisting specific schemes and ports.

Validation

Wallets should warn users if a token's symbol or name matches or resembles another token's. This is an important measure to prevent phishing. The goal is to stop users from accidentally adding counterfeit tokens.

Fingerprinting

To prevent fingerprinting based on wallet behavior or listed assets, the RPC call must return immediately after a prompt is displayed or an error occurs, as described in this part of the original article. It should not wait for the user to accept or reject the prompt. This makes it more difficult to identify users based on their wallet's behavior.

These security considerations are important for keeping wallet users safe and protecting them against unauthorized activity. Wallet developers should follow these guidelines when implementing secure wallet functionality.

Citation

Dan Finlay (@danfinlay), Esteban Mino (@estebanmino), Gavin John (@Pandapip1), "EIP-747: wallet_watchAsset RPC Method," Ethereum Improvement Proposals, no. 747, August 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-747.

Conclusion

This article covered EIP747, which proposes a new RPC method, wallet_watchAsset, to help users track assets in their wallets. I hope this explanation was helpful.

If you have questions, feel free to reach out via direct message on Twitter.

Twitter @cardene777

I also publish content on other platforms, which you can find below.

https://chaldene.net/