Gets the number of tokens a user owns in their currently connected wallet.


Example Usage

// ERC721
const erc721Count = await contract.getTokenBalance();

console.log(erc721Count); // 0, 1, etc..

// ERC1155
const tokenId = 0;
const erc1155Count = await contract.getTokenBalance(tokenId);

console.log(erc1155Count); // 0, 1, etc..


tokenId is required when the contract type is ERC1155.


The SDK will prefix all logs from getTokenBalance() with HM (getTokenBalance) -

Possible Errors

  • Token id required - When tokenId is not provided for an ERC1155 contract
  • Errors in the connect() function


Something not quite right, unclear or can't find what you are looking for? Please let us know at and we will get back to you as soon as we can.