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

eth,internal: add eth_chainId method to PublicEthereumApi JSONRPC #15002

Closed
wants to merge 2 commits into from

Conversation

@whilei
Copy link

commented Aug 18, 2017

I'm stealing @sorpaas words from his congruent Parity client PR:

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. 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.

Recently merged the same endpoint to ETC's go-ethereum: ethereumproject/go-ethereum#336

@GitCop

This comment has been minimized.

Copy link

commented Aug 18, 2017

Thank you for your contribution! Your commits seem to not adhere to the repository coding standards

  • Commit: dc0641c
  • Commits must be prefixed with the package(s) they modify

Please check the contribution guidelines for more details.


This message was auto-generated by https://gitcop.com

@whilei whilei force-pushed the whilei:chain-id-rpc branch from dc0641c to ee555bc Aug 18, 2017
@whilei whilei changed the title Add eth_chainId method to PublicEthereumApi JSONRPC eth,internal: add eth_chainId method to PublicEthereumApi JSONRPC Aug 18, 2017
@karalabe

This comment has been minimized.

Copy link
Member

commented Aug 19, 2017

Would be nice to have an EIP for it before adding methods to the standardized eth_ namespace.

@tcz001

This comment has been minimized.

Copy link

commented Aug 21, 2017

Good to see this, I was facing with same problem when using Web3js, which was using the net_getId by default, just created a EIP694

whilei added a commit to whilei/EIPs that referenced this pull request Aug 21, 2017
@whilei

This comment has been minimized.

Copy link
Author

commented Aug 21, 2017

Please find an EIP PR here: ethereum/EIPs#695

@bas-vk

This comment has been minimized.

Copy link
Member

commented Sep 4, 2017

The proper way to retrieve the chainID is:

if config := api.e.chainConfig; config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
		chainID = config.ChainId
}

Although the EIP is not finalized it is likely that a QUANTITY is returned. You can return one the of integer types in the hexutil package for that. They will take care of the appropiate encoding that is used for quantity types.

Copy link
Contributor

left a comment

Parity just added this method aswell, looks good to me.
Actually, hold that. How will this respond when doing e.g. a full-sync, before reaching EIP-155?

@holiman holiman dismissed their stale review Sep 27, 2017

x

@whilei

This comment has been minimized.

Copy link
Author

commented Sep 27, 2017

It will return hexutil.Uint(new(big.Int)) == 0x0, which does not conflict with any existing chainId in EIP155.

@frankiebee

This comment has been minimized.

Copy link

commented Apr 11, 2018

whats the status on this? seems like a stale PR. did chainId make it in somewhere else?

@turbobit

This comment has been minimized.

Copy link

commented Jun 5, 2018

ESN ( https://ethersocial.org ) using customized RPC-API for using Metamask.
api : https://api-meta.esn.gonspool.com
api return RPC call "net_version" as chainId value "31102"
"chainId 31102 " is ESN's chainid.

by using this customized RPC-API.
i am sucess send a coin with

@fjl

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2018

Closing in favor of #17617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.