-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Today, most web3-compatible browsers have a notion of watching tokens, usually to help a user watch their current balances of tokens.
While it is possible to derive an account's token balances by walking the full history of the blockchain, this is especially impractical in the context of light clients, and so users are frequently instructed to "add this token to your wallet", to help their wallet identify tokens they care about.
To help ease this experience, I'd like to propose a new optional method to be exposed in web3-compatible browsers, eth_watchToken.
This method would take a single parameter, a JavaScript object with the following keys:
- address (required): The address of the token to watch, as a hex-prefixed string.
- symbol: A string representing the ticker symbol. Should be three characters. (Required if the token at the given address does not implement a public
symbol() returns stringmethod. - decimals: number, representing the number of digits to treat as decimals. (Required if the token at the given address does not implement a public
decimals() returns uint8method. - name: string, representing the token's name. Optional.
Web3 browsers should then show some confirmation to the user, requesting their permission to track the given token.
If one of the options (symbol, decimals, name) differs from the result of the token's own public method, I'm not sure what's best, probably default to the page? Open to opinions here, for now this is undefined behavior for the proposed spec.
Valid error messages:
Valid errors I'd like to propose, for the sake of cross-client consistency, are:
Problem prompting the user.Problem tracking the token.User rejected request.