-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for dapp to request network change #5101
Comments
Hi there, I am really insteresting in developing the feature myself and share it with the community, but I would like to be sure it has a real chance of being accepted. cheers |
@etienneroudeix I think this proposal makes a lot of sense. We've discussed this internally a couple times and would love to collaborate on a solution. This could be a good candidate for an EIP, and will likely have some downstream effects on the Custom RPC UI we show in our settings menu. cc @danfinlay |
This is very aligned with my general thinking of MetaMask going forward. For example, it is reminiscent of how we have begun addressing managing a list of tokens: Once we merge support for custom chainIds, we could begin implementing this. Two open questions from that PR:
Both of these things (prices & explorer links) have previously been neatly trustless parts of MetaMask (you can cross-check what a Dapp claims against them). If Dapps could propose networks, how would we answer these basic questions? |
@danfinlay I would like to know the eta schedule for optional chain id support , it has been open from 12 days ago and still no sign of review or merge 😂 |
@bdresser @danfinlay Thank for these answers and the referred issues/PR links. |
New EIP for this: ethereum/EIPs#2015 |
Hi, the EIP-2015 looks really nice for UX. |
Yes, we're looking forward on integrating an API for suggesting network change, but we currently think it might be more appropriate to either/both:
We are doing work towards both of those right now, and while this might be slightly lower-hanging fruit, these solutions seem more beneficial long-term. Thoughts? |
hi @danfinlay
Does it mean a dapp can ask the user to sign a tx on Rinkeby (or any other network) while his current network is the main network ? |
Long term, I think the concept of "connected network" will become less meaningful. What is more important are the assets you hold. Some are test ether, some are real ether. If we represent the asset being transferred correctly, we should be able to provide a good inter-chain dapp development experience without exposing the user to unusual phishing risks. |
Could we first add a feature allowing the dapp to query the address of the node it is connected to, in addition to being able to get the chainID? This is much more important for custom RPC addresses. The user can see what's there, but the dapp currently cannot, and this reduces usability by adding failure paths that are not intuitive for users to debug, even/especially when they can verify that dapp files (e.g. HTML and Javascript) are coming from an expected server. |
Some RPC URLs include private authorization keys as query parameters, so I'm not sure I'd want to leak that information to every site a user visits. I would hope providing chainId/networkId checks as well as the ability to suggest a specific RPC would satisfy most applications' needs. If checking the exact URL of the user's RPC were really necessary, I would be inclined to provide it as an additional sign-in permission, so the user would explicitly grant that information disclosure. |
How would a dapp know if it needs to request a network change, if it doesn't know what it's on? |
For the time being, the |
any update on implementing EIP-2015? |
We are currently putting more effort into EIP 2255, which will eventually incorporate the parameters from EIP 2015, but allowing the wallet to connect to different networks on different dapps, instead of preserving the fairly broken notion of a single network for all browser tabs. |
Hi @danfinlay any ETA for this function to be supported? looking forward to it |
I see here that EIP-2255 has been integrated into the browser version "Currently, the only permission is eth_accounts, which allows you to access the user's Ethereum address(es). More permissions will be added in the future." Is the proposed EIP-2015 functionality still planning to be incorporated as a permission call? If so, is there any idea when this may be? |
Update: We're doing this: https://eips.ethereum.org/EIPS/eip-3085 It's basically like 2015, but without update functionality (for now). We'll have some additional restrictions on the kind of chains that can be added, and will ignore some fields for the time being, but e.g. xDAI, Optimism, and similar EVM-compatible chains with ETH-analogue native currencies (with 18 decimals) will be addable using Basically, fi you can add via the existing custom network RPC form today, you should be able to add via the new RPC method once it ships (soon), so long as the chain ID does not collide with one of the default MetaMask networks. |
Woooooo! 🍻 |
Any updates on this? |
@sameepsi we're close to finishing the feature on our end and should ship soon. |
@rekmarks , thanks for your work on this issue. NEAR is waiting for this too. |
@rekmarks wow, that will make everything so much easier especially in those gasintense times right now :) DEUS is also waiting! |
Fuse is waiting anxiously as well :) |
@brad-decker, great work! Congratz! |
They merged a PR with the "T12-DONOTMERGE" tag... |
Any updates on this? |
Apparently, that doesn't allow to switch users to a built-in network though, which makes operation a lot more difficult for anything that wants to switch and is not using custom chains... |
Pancakeswap does this 'network change request', do you guys have any idea how they do it. |
Hello @masterbd You should use wallet_addEthereumChain (https://docs.metamask.io/guide/rpc-api.html#wallet-addethereumchain) for network change request. Small snippet:
|
@zkipart switching between added chains and adding new chains are fundamentally different things though, also metamask doesn't allow to add default chains so any multichain service that also serves on ethereum mainnet can categorically scratch the idea of using this. is there any reason why this issue was closed? |
#10597 is the current issue for this request, FWIW - but someone still needs to implement it... |
Hello,
I would like to connect a metamask user to a custom network directly from my dapp.
The idea is to avoid the user to have to copy the new custom RPC url and paste it in a second page metamask form.
Context :
Today when a dapp running on a custom Ethereum blockchain wants a user to sign a transaction, the user needs to :
And this a very long process. And metamask does not always remember the custom network.
My proposal :
The web3 metamask provider accepts a new function to add a custom RPC from the dapp.
The metamask extension shows a window to warn the metamask user that it’s network has been changed. The warning should be enforced if the chainId is 1.
The dapp can ask the user to send a tx to the custom network using
eth_sendTransaction
.What do you think about this feature ?
The text was updated successfully, but these errors were encountered: