This talk addresses the problem of counting the microstates of supersymmetric asymptotically AdS black holes in terms of a holographically dual field theory. We focus on a particular BPS class of AdS$_2 x S^2$ near-horizon geometry in N=2 gauged supergravity relevant both for AdS$_4$ and AdS$_5$ black holes. We consider in the large N limit the topologically twisted index of the ABJM theory and the partition function of N=4 SYM and show that they correctly reproduce the Bekenstein-Hawking entropy of the AdS$_4$ and AdS$_5$ black holes, respectively. An extremization of the partition functions with respect to a set of chemical potentials is required. We interpret it as the selection of the exact R-symmetry of the superconformal quantum mechanics describing the horizon of the black holes.