> 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/th/phatthana/phuenthan/how-tos/yot-sali-krapao.md).

# ดูยอดคงเหลือกระเป๋าเงิน

ดึงข้อมูลยอดคงเหลือ CHZ และ token ของกระเป๋าเงินบน Chiliz Chain โดยใช้ Moralis Wallet API พร้อมตัวอย่างโค้ดสำหรับการค้นหาสินทรัพย์เดียวและหลายสินทรัพย์

## ยอดคงเหลือ CHZ ของกระเป๋าเงินคืออะไร?

ยอดคงเหลือของกระเป๋าเงิน หมายถึงจำนวนรวมของสกุลเงินดิจิทัลเฉพาะที่กระเป๋าเงินนั้นถืออยู่ ขึ้นอยู่กับโปรเจกต์ของคุณ คุณอาจต้องแสดงยอดคงเหลือของสกุลเงินดิจิทัลเพียงสกุลเดียว หรือยอดคงเหลือของสกุลเงินดิจิทัลทั้งหมดที่กระเป๋าเงินนั้นถืออยู่

นอกจากนี้ สินทรัพย์ในกระเป๋าเงินยังหมายถึงสกุลเงินดิจิทัล token และสินทรัพย์ดิจิทัลทุกรูปแบบที่จัดเก็บและจัดการอยู่ภายในกระเป๋าเงินดิจิทัล

## วิธีทำโดยใช้ Moralis

Moralis มี [Wallet API](https://moralis.com/api/wallet/) ที่คุณสามารถใช้งานได้ และยังมีตัวอย่างโค้ดสำหรับกรณีการใช้งานยอดคงเหลือของกระเป๋าเงินด้วย:

* [วิธีดูยอดคงเหลือ native ของที่อยู่](https://docs.moralis.io/web3-data-api/evm/wallet-api/how-to-get-the-balance-of-a-wallet)

ในการปรับใช้ตัวอย่างโค้ดของพวกเขา เราต้องแทนที่การอ้างอิงถึง Ethereum ด้วย ID ของ Chiliz Chain ที่ใช้ใน Moralis ซึ่งก็คือ `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();
```

## วิธีทำโดยใช้ Tatum

Tatum มี [Data API](https://tatum.io/blockchain-api) ที่ครอบคลุมซึ่งคุณสามารถใช้งานได้ และยังมีตัวอย่างโค้ดสำหรับกรณีการดึงข้อมูลสินทรัพย์ด้วย:

* [ดูสินทรัพย์ทั้งหมดที่กระเป๋าเงินถืออยู่](https://docs.tatum.io/docs/get-all-assets-the-wallet-holds)

ในการปรับใช้ตัวอย่างโค้ดของพวกเขา เราต้องแทนที่การอ้างอิงถึง Ethereum ด้วย 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)
```

## วิธีทำโดยใช้ thirdweb

thirdweb มีตัวอย่างโค้ดสั้นๆ หลายชิ้นบนเว็บไซต์เอกสารของพวกเขา ซึ่งเราสามารถใช้เป็นแรงบันดาลใจได้

* [ดูยอดคงเหลือของกระเป๋าเงิน](https://portal.thirdweb.com/connect/in-app-wallet/how-to/interact-with-wallets#get-wallet-balance)

นี่คือโค้ดของพวกเขา [ที่ปรับสำหรับ 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();
```

## วิธีทำโดยใช้ Nodit

Nodit มีตัวอย่างโค้ดต่อไปนี้ [ในเอกสารของพวกเขา](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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chiliz.com/th/phatthana/phuenthan/how-tos/yot-sali-krapao.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
