> For the complete documentation index, see [llms.txt](https://circular-protocol.gitbook.io/hyper-code-ide-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://circular-protocol.gitbook.io/hyper-code-ide-guide/lesson-4-your-first-token/getbalance-function.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
