code: func detectEnsAddr(client *rpc.Client) (common.Address, error) {
  	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
  	defer cancel()
  
  	var version string
  	if err := client.CallContext(ctx, &version, "net_version"); err != nil {
  		return common.Address{}, err
  	}
  
  	block, err := ethclient.NewClient(client).BlockByNumber(ctx, big.NewInt(0))
  	if err != nil {
  		return common.Address{}, err
  	}
  
  	switch {
  
  	case version == "1" && block.Hash() == params.MainnetGenesisHash:
  		log.Info("using Mainnet ENS contract address", "addr", ens.MainNetAddress)
  		return ens.MainNetAddress, nil
  
  	case version == "3" && block.Hash() == params.TestnetGenesisHash:
  		log.Info("using Testnet ENS contract address", "addr", ens.TestNetAddress)
  		return ens.TestNetAddress, nil
  
  	default:
  		return common.Address{}, fmt.Errorf("unknown version and genesis hash: %s %s", version, block.Hash())
  	}
  }
docs: // detectEnsAddr determines the ENS contract address by getting both the
  // version and genesis hash using the client and matching them to either
  // mainnet or testnet addresses