As you mentioned, to get the ETH balance of an address you need to do this:
eth.getBalance("<ADDRESS_HERE>", <BLOCK_NUMBER>);
If you want to get the balance of an ERC20 token, you need to make a call to that token's contract. To do this you will need three things:
- The token contract address.
- Your account address.
- The token contract’s ABI.
So, you need instantiate the contract ABI by doing:
> var tokenContract = eth.contract([{
"type":"function",
"name":"balanceOf",
"constant":true,
"payable":false,
"inputs":[{"name":"","type":"address"}],
"outputs":[{"name":"","type":"uint256","value":"0"}]
}]);
And then you can do:
> var erc20ContractAddress = "<ADSRESS_OF_TOKEN'S_CONTRACT>";
> var account = "YOUR_ADDRESS";
> tokenContract.at(erc20ContractAddress).balanceOf(account);
This outputs the token balance in plain tokens, i.e. without showing a decimal point.