1

I know that in Ethereum, same addresses works across the network(mainnet and all testnets).

But I am looking to know if there are any chances to find out the network on which a contract is deployed by using its contract address because only relevant network will be having the data of contract stored.

Also how much reliable this approach can be?

Aniket
  • 3,545
  • 2
  • 20
  • 42
  • This is also related: https://ethereum.stackexchange.com/questions/18314/is-there-a-way-to-differentiate-between-an-account-on-the-main-net-and-the-test – Richard Horrocks Mar 28 '19 at 13:00

2 Answers2

2

May be this is not the best solution but can be helpful for now:

set web3 provider for every testnet one by one and then try to get the size of the contract using following web3 call.

web3.eth.getCode(address [, defaultBlock] [, callback])

this returns the data if the address is a contract.

you may get the data from multiple chains. In this case you'll end up with multiple networks having code for same address.

rohit_sethi
  • 108
  • 7
1

You may try to find this address in https://etherscan.io/ on different networks and see where it has some code or non-zero ether balance:

Etherscan also has an API for this that you can use to automate such lookups.

Mikhail Vladimirov
  • 7,313
  • 1
  • 23
  • 38