I'll assume we're talking about complex functions; if real, tensor with $\mathbb{C}$. Now pass to the group of units. With the topology given by spectral radius (this is an algebraic description of the C-* topology), the group of connected components of the group of units is $H^1(X, \mathbb{Z})$ which of course knows the genus. If you really like idempotents then you should try learning about K-theory. There's a very concrete and elementary way to define $K^0$ in terms of idempotents in the matrix algebras $M_n(A)$. You don't need the C*-structure of $A$. But on the other hand $K^0$ doesn't know the genus of a surface. $K^1$ does but it's a bit trickier to define, I think. **Edit:** $H^1(X, \mathbb{Z})$ can be isolated a bit more algebraically too. To extract $H^1(X, \mathbb{Z})$ from the group of units it suffices to isolate the connected component of the identity. The elements in this connected component can be distinguished by the fact that they are divisible. **Edit #2:** So, purely for the sake of distinguishing $S^2$ and $T^2$, you can say the following: on $S^2$, every unit has a square root, but not on $T^2$.