Skip to content
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

EIP-2015: Wallet Update Chain Method #2015

Merged
merged 7 commits into from May 14, 2019
@@ -0,0 +1,74 @@
---
eip: 2015
title: Wallet Update Chain Method
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 13, 2019

Member

The other RPC related EIPs all had a title meantioning RPC or the method. I think that would be useful here.

This comment has been minimized.

Copy link
@pedrouid

pedrouid May 13, 2019

Author Contributor

I've changed it, let me know what you think

author: Pedro Gomes (@pedrouid)
discussions-to: https://ethereum-magicians.org/t/add-wallet-methods-to-improve-dapp-to-wallet-interaction/1848/31
status: Draft
type: Standards Track
category: ERC
created: 2019-05-12
---
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 13, 2019

Member

Please add requires: 155 as this depends on a chain id.


## Simple Summary
Wallets can update the active chain when connected to a Dapp but not vice-versa, with wallet_updateChain the Dapp will be able to request this change from the Wallet.
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 14, 2019

Member

Can you quote wallet_updateChain with backticks here?


## Abstract
Dapp can request the Wallet to switch chains by providing the minimal parameters of chainId, networkId, rpcUrl and nativeCurrency. The Wallet will display a UI element to inform the user of this change.
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 14, 2019

Member

Can you quote the field names or change them to regular text?

This comment has been minimized.

Copy link
@axic

axic May 14, 2019

Member

Also they are inconsistent with the specification, for example networkId vs. networkID, but chainId has a lowercase d letter in both cases.


## Motivation
Wallet and Dapp comunication rely on the present provider that acts as middleware between the two. Using JSON-RPC methods, the Dapp is able to access not only the active accounts but also the active chain. With EIP-1102 we introduced the ability for Dapps to request access to the active accounts and the Wallet is able to provide a simple UI to inform the user of this action however the same is not currently possible for switching chains. The current pattern is to display some UI to request the user to switch chains within the Dapp, however this could be easily improved by triggering a UI from the Wallet side that can be approved or rejected by the user instead.
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 14, 2019

Member

Can you make EIP-1102 a link to https://eips.ethereum.org/EIPS/eip-1102 ?

This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@axic

axic May 14, 2019

Member

comunication -> communication


## Specification
The JSON RPC method will be part of `wallet_` methods which include methods that improve the UX and interoperability between Dapps and Wallets.

### Required Parameters
- chainId (number): the id of the chain complaint with EIP-155
- networkID (number): the id of the chain's network
- rpcUrl (string): the url endpoint for RPC requests for this chain
- nativeCurrency (string): the ticker/symmbol for the native currency of this chain


### Best Practices
- The Wallet should display a UI view similar to a EIP-1102 informing the user that the currently connected Dapp wants to switch to the specified chain.
- the Wallet should default the rpcUrl to any existing endpoints matching a chainId known previously to the wallet, otherwise it will use the provided rpcUrl as a fallback.
- the Wallet should call the rpcUrl with `net_version` and `eth_chainId` to verify the provided chainId and networkId match the responses from the rpcUrl
- the Wallet should change all nativeCurrency symbols to the provided parameter

### Example 1
A JSON-RPC request from a Dapp to switch the Ethereum Goerli chain would be as follows:
```json
{
"id":1,
"jsonrpc": "2.0",
"method": "wallet_updateChain",
"params": [
{
"chainId": 5,
"networkId": 5,
"rpcUrl": "https://goerli.infura.io/v3/406405f9c65348f99d0d5c27104b2213",
"nativeCurrencyName": "gorETH"
}
]
}
```

### Example 2
A JSON-RPC request from a Dapp to switch the POA Network's xDAI chain would be as follows:
```json
{
"id":1,
"jsonrpc": "2.0",
"method": "wallet_updateChain",
"params": [
{
"chainId": 100,
"networkId": 100,
"rpcUrl": "https://dai.poa.network",
"nativeCurrencyName": "xDAI"
This conversation was marked as resolved by pedrouid

This comment has been minimized.

Copy link
@jdkanani

jdkanani May 13, 2019

how about having name and symbol both? Like "Kovan Ethers" and "KETH"?

This comment has been minimized.

Copy link
@pedrouid

pedrouid May 13, 2019

Author Contributor

Sounds good 👍

}
]
}
```

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.