# GetBalance Function

Of all the <mark style="color:yellow;">Smart Native Contracts (SNCs)</mark> we’ve discussed, one stands out for its smart contract interaction: “GetBalance.” This endpoint retrieves the balance of a specific wallet. Its implementation is similar to the constructor, with the key difference being that we’re only fetching the wallet’s balance. Here’s the code for this operation:

```javascript
__GetBalance: function (address) {
    
      // Creates a new wallet instance
      var wallet = Object.create(CRC_Wallet);
    
      // Opens the specified wallet
      if(wallet.OpenWallet(address)){
        
          // if the wallet is available prints out the balance
          println('Balance : ' + wallet.Balance + ' '+ this._Symbol);
          return wallet.Balance;
      }
      return -1;
  }
```

The code is simple: after creating an instance of the specified wallet, we check if it opens successfully, retrieve the balance, and print the result. We don’t need to close the wallet here, as no updates are made. Even if a “CloseWallet” operation were included, it would be ignored since Smart Native Contracts (SNCs) don’t modify the smart contract’s state.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://circular-protocol.gitbook.io/hyper-code-ide-guide/lesson-4-your-first-token/getbalance-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
