From 6744a288785bfd7169fb4e022e37cca9d686de4a Mon Sep 17 00:00:00 2001 From: ia Date: Mon, 21 Aug 2017 11:17:47 -0500 Subject: [PATCH 1/8] EIP: Implement method in JSON-RPC. Rel https://github.com/ethereum/go-ethereum/pull/15002 --- EIPS/eip-rpc_eth_chain_id.md | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 EIPS/eip-rpc_eth_chain_id.md diff --git a/EIPS/eip-rpc_eth_chain_id.md b/EIPS/eip-rpc_eth_chain_id.md new file mode 100644 index 00000000000000..75ec26de2263b4 --- /dev/null +++ b/EIPS/eip-rpc_eth_chain_id.md @@ -0,0 +1,74 @@ +## Preamble + + EIP: + Title: Create `eth_chainId` method for JSON-RPC + Author: Isaac Ardis: isaac.ardis@gmail.com, Wei Tang: hi@that.world + Type: Standard Track + Category: Interface + Status: Draft + Created: 2017-08-21 + + +## Simple Summary +Include `eth_chainId` method in `eth_`-namespaced JSON-RPC methods. + +## Abstract +The `eth_chainId` method should return a single STRING result +for an integer value in hexadecimal format, describing the +currently configured "Chain Id" value used for signing replay-protected transactions, +introduced via EIP-155. + +## Motivation +Currently although we can use net_version RPC call to get the +current network ID, there's no RPC for querying the chain ID. This +makes it impossible to determine the current actual blockchain using +the RPC. + +## Specification + +---- + +### eth_chainId + +Returns the currently configured chain id, a value used in replay-protected transaction +signing as introduced by EIP-155. + +##### Parameters +none + +##### Returns + +`QUANTITY` - big integer of the current chain id. Defaults are mainnet=61, morden=62. + +##### Example +```js +curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' + +// Result +{ + "id":83, + "jsonrpc": "2.0", + "result": "0x3d" // 61 +} +``` + +---- + +## Rationale +An ETH/ETC client can accidentally connect to an ETC/ETH RPC +endpoint without knowing it unless it tries to sign a transaction or +it fetch a transaction that is known to have signed with a chain +ID. This has since caused trouble for application developers, such as +MetaMask, to add multi-chain support. + +## Backwards Compatibility +Not relevant. + +## Test Cases +Not currently implemented. + +## Implementation +Would be good to have a test to confirm that expected==got. + +## Copyright +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From b54a4e3d84ff1ea79c7475f3e65245b2601a4c0b Mon Sep 17 00:00:00 2001 From: ia Date: Mon, 21 Aug 2017 11:18:59 -0500 Subject: [PATCH 2/8] Include related PR link. --- EIPS/eip-rpc_eth_chain_id.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/EIPS/eip-rpc_eth_chain_id.md b/EIPS/eip-rpc_eth_chain_id.md index 75ec26de2263b4..c711064561c3d6 100644 --- a/EIPS/eip-rpc_eth_chain_id.md +++ b/EIPS/eip-rpc_eth_chain_id.md @@ -26,6 +26,11 @@ the RPC. ## Specification +__Related PR__: +https://github.com/ethereum/go-ethereum/pull/15002 + +__Example documentation__: + ---- ### eth_chainId From 3a6b4663b963d225ddc93ca3ef415f7c3c540cf7 Mon Sep 17 00:00:00 2001 From: ia Date: Mon, 21 Aug 2017 16:07:02 -0500 Subject: [PATCH 3/8] Include @tcz001 as author and add related links --- EIPS/eip-rpc_eth_chain_id.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/EIPS/eip-rpc_eth_chain_id.md b/EIPS/eip-rpc_eth_chain_id.md index c711064561c3d6..ab11affe8c207f 100644 --- a/EIPS/eip-rpc_eth_chain_id.md +++ b/EIPS/eip-rpc_eth_chain_id.md @@ -2,7 +2,7 @@ EIP: Title: Create `eth_chainId` method for JSON-RPC - Author: Isaac Ardis: isaac.ardis@gmail.com, Wei Tang: hi@that.world + Author: Isaac Ardis: isaac.ardis@gmail.com, Wei Tang: hi@that.world, [@tcz001](https://github.com/tcz001) Type: Standard Track Category: Interface Status: Draft @@ -26,11 +26,6 @@ the RPC. ## Specification -__Related PR__: -https://github.com/ethereum/go-ethereum/pull/15002 - -__Example documentation__: - ---- ### eth_chainId @@ -66,6 +61,12 @@ it fetch a transaction that is known to have signed with a chain ID. This has since caused trouble for application developers, such as MetaMask, to add multi-chain support. +Please note related links: + +- [Parity PR](https://github.com/paritytech/parity/pull/6329) +- [Geth Classic PR (merged)](https://github.com/ethereumproject/go-ethereum/pull/336) + + ## Backwards Compatibility Not relevant. From ea5b79014936bfb332166490d76de7ae2d58dd89 Mon Sep 17 00:00:00 2001 From: ia Date: Fri, 26 Jan 2018 00:35:55 +0900 Subject: [PATCH 4/8] Assigned lucky number 695 --- EIPS/{eip-rpc_eth_chain_id.md => eip-695.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-rpc_eth_chain_id.md => eip-695.md} (98%) diff --git a/EIPS/eip-rpc_eth_chain_id.md b/EIPS/eip-695.md similarity index 98% rename from EIPS/eip-rpc_eth_chain_id.md rename to EIPS/eip-695.md index ab11affe8c207f..6a26656303c3ea 100644 --- a/EIPS/eip-rpc_eth_chain_id.md +++ b/EIPS/eip-695.md @@ -1,6 +1,6 @@ ## Preamble - EIP: + EIP: 695 Title: Create `eth_chainId` method for JSON-RPC Author: Isaac Ardis: isaac.ardis@gmail.com, Wei Tang: hi@that.world, [@tcz001](https://github.com/tcz001) Type: Standard Track From 68cde9b43ae9149a2bdd819e50fdc73f4c30f13b Mon Sep 17 00:00:00 2001 From: ia Date: Fri, 26 Jan 2018 11:40:17 +0900 Subject: [PATCH 5/8] Relative link to eip-155 --- EIPS/eip-695.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-695.md b/EIPS/eip-695.md index 6a26656303c3ea..5e974a4a7c20ee 100644 --- a/EIPS/eip-695.md +++ b/EIPS/eip-695.md @@ -16,7 +16,7 @@ Include `eth_chainId` method in `eth_`-namespaced JSON-RPC methods. The `eth_chainId` method should return a single STRING result for an integer value in hexadecimal format, describing the currently configured "Chain Id" value used for signing replay-protected transactions, -introduced via EIP-155. +introduced via [EIP-155](./eip-155.md). ## Motivation Currently although we can use net_version RPC call to get the From 45f6e8e48fbcd7ebda64083688728c522fc7190a Mon Sep 17 00:00:00 2001 From: ia Date: Fri, 26 Jan 2018 11:47:28 +0900 Subject: [PATCH 6/8] RPC spec: 'big integer' -> 'integer' --- EIPS/eip-695.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-695.md b/EIPS/eip-695.md index 5e974a4a7c20ee..6366bd4d9d5121 100644 --- a/EIPS/eip-695.md +++ b/EIPS/eip-695.md @@ -38,7 +38,7 @@ none ##### Returns -`QUANTITY` - big integer of the current chain id. Defaults are mainnet=61, morden=62. +`QUANTITY` - integer of the current chain id. Defaults are mainnet=61, morden=62. ##### Example ```js From 4269d195cbdfe9da3394edfcffa90ed61f847f17 Mon Sep 17 00:00:00 2001 From: ia Date: Fri, 26 Jan 2018 11:50:32 +0900 Subject: [PATCH 7/8] Rel link eip-155 for other occurrance --- EIPS/eip-695.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-695.md b/EIPS/eip-695.md index 6366bd4d9d5121..70e8e9b8eff9be 100644 --- a/EIPS/eip-695.md +++ b/EIPS/eip-695.md @@ -31,7 +31,7 @@ the RPC. ### eth_chainId Returns the currently configured chain id, a value used in replay-protected transaction -signing as introduced by EIP-155. +signing as introduced by [EIP-155](./eip-155.md). ##### Parameters none From 1d1799bd2e1c022dd3d746e2f5f28497bb6b2810 Mon Sep 17 00:00:00 2001 From: ia Date: Fri, 26 Jan 2018 19:28:59 +0900 Subject: [PATCH 8/8] Reference hex encoding standard --- EIPS/eip-695.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EIPS/eip-695.md b/EIPS/eip-695.md index 70e8e9b8eff9be..c917d29ced0927 100644 --- a/EIPS/eip-695.md +++ b/EIPS/eip-695.md @@ -76,5 +76,9 @@ Not currently implemented. ## Implementation Would be good to have a test to confirm that expected==got. +## Reference + +Return value `QUANTITY` adheres to standard JSON RPC hex value encoding, as documented here: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding. + ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).