> For the complete documentation index, see [llms.txt](https://docs.ternoa.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ternoa.network/build-1/javascript/nft-features-and-pallets/tokens/g-token/get-gtokens-balances.md).

# Get GTokens balances

Gtoken is a non-fungible utility token used within the Ternoa network, not mineable or tradable with other fungible tokens.

### Prerequisites

Before getting started, make sure you have the following ready:

1. [Create a Ternoa](/getting-started/wallets/ternoa-wallet.md) account with [Alphanet CAPS](broken://pages/ej9gceaLIhCN2PgUBh42)
2. Own a GToken on alphanet created using [Polkadot js portal](https://polkadot.js.org/apps/#/explorer).
3. Install and set up your editor of choice (we will use Visual Studio Code \[VSC] in this tutorial)
4. Install [NodeJS v.14+](https://nodejs.org/en/download/) & NPM
5. [Install & initialize Ternoa-JS](/build-1/javascript/ternoa-js-library-utilities/installation-and-initialization.md)

### How to get the total GTokens balance of an address

This example shows how to get the total GTokens balance of an address using `getAccountAssetBalance().`

```
import {
	initializeApi,
	getAccountAssetBalance,
} from "ternoa-js";

const main = async () => {
	try {
		await initializeApi ();
		
		const ACCOUNT_ADDRESS = "REPLACE_WITH_THE_ADDRESS";
		const GTOKEN_ID = REPLACE_WITH_THE_GTOKEN_ID

		const balance = balance = (await getAccountAssetBalance(
			GTOKEN_ID,
			ACCOUNT_ADDRESS
		))?.toString()
		
		console.log(
			`The GTOKEN balance for address ${ACCOUNT_ADDRESS} is: balance`,
		);
		return balance
	} catch (e) {
		console.error(e);
		process.exit(1)
	} finally {
		process.exit(0)
	}
};

main();
```


---

# 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://docs.ternoa.network/build-1/javascript/nft-features-and-pallets/tokens/g-token/get-gtokens-balances.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.
