0

if i have 2 nodes, one ETH and one ETC, and I am writing a program to use these nodes, how can i determine which node I am using at any given time?

the best i can come up with is to check a known block after the fork and simply compare # of tx. I know how many tx are in that block on both chains, so i can differentiate that way.

this seems clunky. is there a better way to do this?

Edit: this is not a duplicate of "Does ETH and ETC uses the same network ID?" because i am not asking about the network id. i am asking about the network as a whole. eth/etc share a network id of 1 for the main network.

  • 1
    Does net_version do the trick? – user19510 Dec 1 '18 at 18:23
  • @smarx I believe Ethereum and Ethereum classic have the same network id – flygoing Dec 1 '18 at 18:27
  • 1
    Possible duplicate of Does ETH and ETC uses the same network ID? – flygoing Dec 1 '18 at 18:29
  • Okay, then my suggestion won't help. But I don't think this question is a duplicate of the one indicated. (That one doesn't seem to have an answer to this question either.) – user19510 Dec 1 '18 at 18:33
  • net_version returns 1 for both (as expected). is there no way to do it besides the way i described (comparing 2 known blocks)? – i_am_not_ethereum Dec 1 '18 at 18:52
1

You can pull the block data for block 1920000 using web3. This is the dao fork block so the block hash will be different.

ETC is 0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f

ETH is 0x4985f5ca3d2afbec36529aa96f74de3cc10a2a4a6c44f2157a57d2c6059a11bb

0

Like the others said in the comments, doesn't look like any RPC commands do the job, but if your script/program has access to the machine where Geth is running (perhaps over ssh), you could either try grepping the logs, or killing and restarting Geth to get the log output.

(Having said that, if you have access to the machine, the datadir name gives the game away anyway: .ethereum-classic vs. .ethereum, unless a non-default name was manually specified on node boot.)

ETC:

$ cat /home/richard/.ethereum-classic/mainnet/log/geth.INFO | grep chainID
I1201 18:56:27.326033 cmd/geth/flag.go:767]         chainID: 61

ETH:

No similar file to that above, but on restarting Geth:

INFO [12-01|19:09:25.456] Initialised chain configuration  config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"

(I'm assuming - perhaps incorrectly - that in the ETH case chainID does equate to the chain ID and not network ID. Either way, the absence of a log file you can grep will allow you to deduce it's ETH and not ETC.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.