  We study a family of 2d N=(0,4) gauge theories which describes at low energy
the dynamics of E-strings, the M2-branes suspended between a pair of M5 and M9
branes. The gauge theory is engineered using a duality with type IIA theory,
leading to the D2-branes suspended between an NS5-brane and 8 D8-branes on an
O8-plane. We compute the elliptic genus of this family of theories, and find
agreement with the known results for single and two E-strings. The partition
function can in principle be computed for arbitrary number of E-strings, and we
compute them explicitly for low numbers. We test our predictions against the
partially known results from topological strings, as well as from the instanton
calculus of 5d Sp(1) gauge theory. Given the relation to topological strings,
our computation provides the all genus partition function of the refined
topological strings on the canonical bundle over 1/2 K3.
