-
Notifications
You must be signed in to change notification settings - Fork 5.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
EIP: Implement eth_chainId
method in JSON-RPC
#695
Changes from 4 commits
6744a28
b54a4e3
3a6b466
ea5b790
68cde9b
45f6e8e
4269d19
1d1799b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
## Preamble | ||
|
||
EIP: 695 | ||
Title: Create `eth_chainId` method for JSON-RPC | ||
Author: Isaac Ardis: [email protected], Wei Tang: [email protected], [@tcz001](https://github.com/tcz001) | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please link |
||
|
||
##### Parameters | ||
none | ||
|
||
##### Returns | ||
|
||
`QUANTITY` - big integer of the current chain id. Defaults are mainnet=61, morden=62. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON RPC has String, Number, Booleans or Null. I guess it's a String representing an integer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe "big integer" is the usual way to say it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I'll change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. Will you add that link to the PR? Maybe in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, 1d1799b |
||
|
||
##### 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. | ||
|
||
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. | ||
|
||
## 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/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, we don't have this. It's fine for me though.