> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/vi/phat-trien/co-ban/cach-thuc/lay-so-du-vi.md).

# Lấy số dư ví

## Số dư CHZ của một ví là gì?

Số dư của một ví là tổng lượng tiền mã hóa cụ thể mà ví đó đang nắm giữ. Tùy theo dự án của bạn, bạn có thể cần hiển thị số dư của một loại tiền mã hóa duy nhất, hoặc số dư của tất cả các loại tiền mã hóa mà một ví đang nắm giữ.

Tương tự, tài sản ví bao gồm tất cả các dạng tiền mã hóa, token và tài sản kỹ thuật số được lưu trữ và quản lý trong một ví tiền mã hóa.

## Cách thực hiện với Moralis

Moralis có một [Wallet API](https://moralis.com/api/wallet/) mà bạn có thể sử dụng, và họ thậm chí cung cấp mẫu code cho trường hợp sử dụng số dư ví:

* [Cách lấy số dư native của một địa chỉ](https://docs.moralis.io/web3-data-api/evm/wallet-api/how-to-get-the-balance-of-a-wallet)

Để điều chỉnh mẫu code của họ, chúng ta cần thay thế tham chiếu đến Ethereum bằng ID của họ cho Chiliz Chain, `0x15b38`:

```typescript
import Moralis from "moralis";

const runApp = async() => {
  await Moralis.start({
    apiKey: "YOUR_API_KEY",
    // ...and any other configuration
  });

  const address = "0xYourWalletAddress";

  const chain = "0x15b38", // This is for Chiliz Chain Mainnet.
                           // For Spicy Testnet, use "0x15b32".

  const response = await Moralis.EvmApi.balance.getNativeBalance({
    address,
    chain,
  });

  console.log(response.toJSON());
};

runApp();
```

## Cách thực hiện với Tatum

Tatum có một [Data API](https://tatum.io/blockchain-api) toàn diện mà bạn có thể sử dụng, và họ thậm chí cung cấp mẫu code cho trường hợp sử dụng truy xuất tài sản:

* [Lấy tất cả tài sản mà ví đang nắm giữ](https://docs.tatum.io/docs/get-all-assets-the-wallet-holds)

Để điều chỉnh mẫu code của họ, chúng ta cần thay thế tham chiếu đến Ethereum bằng Chiliz Chain:

```typescript
import {TatumSDK, Network, Chiliz, ResponseDto, AddressBalance} from '@@tatumio/tatum'

const tatum = await TatumSDK.init<Chiliz>({network: Network.CHILIZ})

const balance: ResponseDto<AddressBalance[]> = await tatum.address.getBalance({
  addresses: ['0xYourWalletAddress'], // replace with your address
})

console.log(balance.data)
```

## Cách thực hiện với thirdweb

thirdweb có một số mẫu code ngắn trên trang tài liệu của họ, mà chúng ta có thể dùng làm nguồn tham khảo.

* [Lấy số dư ví](https://portal.thirdweb.com/connect/in-app-wallet/how-to/interact-with-wallets#get-wallet-balance)

Đây là code của họ, [được điều chỉnh cho Chiliz](https://thirdweb.com/chiliz-chain):

```typescript
const sdk = new ThirdwebSDK("https://88888.rpc.thirdweb.com");
const walletAddress = "0xYourWalletAddress";

async function getWalletBalance() {
  try {
    const balance = await sdk.getBalance(walletAddress);
    console.log(`Balance of wallet ${walletAddress}: ${balance.displayValue} ${balance.symbol}`);
  } catch (error) {
    console.error("Error fetching wallet balance:", error);
  }
}

getWalletBalance();
```

## Cách thực hiện với Nodit

Nodit cung cấp mẫu code sau [trong tài liệu của họ](https://developer.nodit.io/reference/chiliz-getnativebalancebyaccount):

```typescript
const url = 'https://web3.nodit.io/v1/chiliz/mainnet/native/getNativeBalanceByAccount';
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    'X-API-KEY': 'nodit-demo'
  },
  body: JSON.stringify({accountAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```


---

# 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.chiliz.com/vi/phat-trien/co-ban/cach-thuc/lay-so-du-vi.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.
