You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, it's possible to suggest addition of an ERC20 token only using metamask. Is it possible to abstract this, to work on every connector?
This should be useful for every project that makes an ERC20 token, and instead of users having to copy and paste an adddress (and sometimes the decimals amount and the token alias), they would have to only click a button, on every wallet.
I think that the same goes for adding network.
For example, I would like to make a "hook" that did the same thing as this:
consttokenAddress="0xd00981105e61274c8a5cd5a88fe7e037d935b513";consttokenSymbol="TUT";consttokenDecimals=18;consttokenImage="http://placekitten.com/200/300";exportconstaddCustomToken=async()=>{try{// wasAdded is a boolean. Like any RPC method, an error may be thrown.constwasAdded=awaitwindow.ethereum.request({method: "wallet_watchAsset",params: {type: "ERC20",// Initially only supports ERC20, but eventually more!options: {address: tokenAddress,// The address that the token is at.symbol: tokenSymbol,// A ticker symbol or shorthand, up to 5 chars.decimals: tokenDecimals,// The number of decimals in the tokenimage: tokenImage,// A string url of the token logo},},});if(wasAdded){console.log("Thanks for your interest!");}else{console.log("Your loss!");}}catch(error){console.log(error);}};
Except I would like it to work on every connector except just metamask.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Right now, it's possible to suggest addition of an ERC20 token only using metamask. Is it possible to abstract this, to work on every connector?
This should be useful for every project that makes an ERC20 token, and instead of users having to copy and paste an adddress (and sometimes the decimals amount and the token alias), they would have to only click a button, on every wallet.
I think that the same goes for adding network.
For example, I would like to make a "hook" that did the same thing as this:
Except I would like it to work on every connector except just metamask.
Beta Was this translation helpful? Give feedback.
All reactions