We describe the general strategy for lifting the Wess-Zumino-Witten model from the level of one-loop Kac-Moody Uq( g) k to generic quantum toroidal algebras. A nearly exhaustive presentation is given for the two series Uq,t( gl 1 ) and Uq,t( gl n ), when screenings do not exist and thus all the correlators are purely algebraic, i.e. do not include additional hypergeometric type integrations/summations.Generalizing the construction of the intertwiner (refined topological vertex) of the Ding-Iohara-Miki (DIM) algebra, we obtain the intertwining operators of the Fock representations of the quantum toroidal algebra of type An. The correlation functions of these operators satisfy the (q, t)-Knizhnik-Zamolodchikov (KZ) equation, which features the R-matrix. The matching with the Nekrasov function for the instanton counting on the ALE space is worked out explicitly.We also present an important application of the DIM formalism to the study of 6d gauge theories described by the double elliptic integrable systems. We show that the modular and periodicity properties of the gauge theories are neatly explained by the network matrix models providing solutions to the elliptic (q, t)-KZ equations.Nekrasov partition function for gauge theories on the ALE space ALE n of type A n , which is a resolution of the orbifold C 2 /Z n .Once we obtain the intertwiners, we can introduce the T -operator and the R-matrix in a similar way to [53,54] and write down the (q, t)-KZ equations [55], where the R-matrix is featured as the connection matrix for q-shift of the argument of the intertwiner. The R-matrix can be identified with q-difference of the operator product expansion (OPE) factor of the intertwiners and is essentially diagonal. Since the OPE factor of the intertwiners agrees with the Nekrasov factor (the bi-fundamental contribution to the partition function), we have a fundamental relationship between the R-matrix and the Nekrasov partition function. Basing on this relation, we can find explicit solutions to our (q, t)-KZ equations, which turn out to be the Nekrasov functions for 5d gauge theories on ALE n × S 1 . Since we consider only the setup with unit central charges, all the solutions to the KZ equations are still algebraic.Moreover, for the unrefined case with unit central charges, we actually demonstrate that the intertwiners of U q,q ( gl n ) essentially factorize into products of noninteracting U q n ,q n ( gl 1 ) intertwiners. The most complicated and interesting case of representations with general central charges in non-Abelian DIM algebra is left for the future.1.1.3 Modular and periodic properties of 6d gauge theories.To demonstrate the effectiveness of DIM formalism, we are going to describe an important application of network matrix models to 6d gauge theories with adjoint matter compactified on the torus T 2 . These theories are, in a certain sense, the highest step in the hierarchy of gauge theories with eight supercharges, for which the Seiberg-Witten and Nekrasov solutions are available. Within the Seiberg-Witten...