> For the complete documentation index, see [llms.txt](https://yuga.gitbook.io/zkyuga-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga.gitbook.io/zkyuga-whitepaper/developer-guide/stablecoin/getbalance.md).

# getBalance

The `getBalance` function in StableCoin Contracts is designed to retrieve the balance of a specific Ethereum address in terms of the stablecoin tokens. This function is crucial for users and applications to check token balances, facilitating various transactions and operational decisions.

## Method Signature

```typescript
async getBalance(userAddress: string): Promise<string>
```

## Parameters

* `userAddress: string`: The Ethereum address whose token balance is to be retrieved. This can be a standard Ethereum address or an ENS name.

## Function Logic

1. **Resolve ENS Name**: If the `userAddress` is an ENS name, it is resolved to the corresponding Ethereum address.
2. **Get Contract Instance**: Obtains an instance of the stablecoin contract to interact with the blockchain.
3. **Query Balance**: Executes the `balanceOf` method on the contract with the user's address.
4. **Return Result**: The balance, typically a large number, is returned in a string format.

## Example Usage

```typescript
const userAddress = "user.eth";

stableCoinContract.getBalance(userAddress)
    .then(balance => 
        // add your logic here 
    )
    .catch(error => 
        // add your logic here
    );
```

## Notes

* The `getBalance` function is a fundamental tool for token management and auditing in the context of ERC20 tokens.
* Accuracy in resolving ENS names to Ethereum addresses is vital for obtaining correct balance information.
