> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getCompressedBalance

> 返回具有给定地址或哈希的压缩账户的余额。

## 请求参数

<ParamField body="address" type="string" default="11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP">
  以base58字符串表示的Solana公钥。
</ParamField>

<ParamField body="hash" type="string">
  以base58字符串表示的32字节哈希。
</ParamField>


## OpenAPI

````yaml zh/openapi/zk-compression/getCompressedBalance.yaml POST /
openapi: 3.0.3
info:
  title: photon-indexer
  description: 用于一般压缩的Solana索引器
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 0.50.0
servers:
  - url: https://mainnet.helius-rpc.com
    description: 主网RPC端点
  - url: https://devnet.helius-rpc.com
    description: 开发网RPC端点
security: []
paths:
  /:
    post:
      description: 检索压缩账户余额
      operationId: getCompressedBalance
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - jsonrpc
                - id
                - method
                - params
              properties:
                jsonrpc:
                  type: string
                  description: JSON-RPC协议的版本。
                  enum:
                    - '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: 用于标识请求的ID。
                  example: '1'
                  default: '1'
                method:
                  type: string
                  description: 要调用的方法名称。
                  enum:
                    - getCompressedBalance
                  default: getCompressedBalance
                params:
                  type: object
                  description: 请求压缩账户数据
                  default:
                    address: null
                    hash: '11111111111111111111111111111111'
                  properties:
                    address:
                      type: string
                      allOf:
                        - $ref: '#/components/schemas/SerializablePubkey'
                      nullable: true
                    hash:
                      type: string
                      allOf:
                        - $ref: '#/components/schemas/Hash'
                      nullable: true
                  additionalProperties: false
                  example:
                    address: null
                    hash: '11111111111111111111111111111111'
        required: true
      responses:
        '200':
          description: 成功从Solana区块链检索压缩账户余额
          content:
            application/json:
              schema:
                type: object
                required:
                  - context
                  - value
                properties:
                  context:
                    $ref: '#/components/schemas/Context'
                  value:
                    $ref: '#/components/schemas/UnsignedInteger'
                additionalProperties: false
        '400':
          description: 错误请求 - 请求参数无效或请求格式错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: 参数无效
                id: '1'
        '401':
          description: 未授权 - API密钥无效或缺失。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: 未授权
                id: '1'
        '429':
          description: 请求过多 - 超出速率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: 请求过多
                id: '1'
        '500':
          description: 内部服务器错误 - 服务器发生错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: 内部错误
                id: '1'
        '503':
          description: 服务不可用 - 服务暂时不可用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: 服务不可用
                id: '1'
        '504':
          description: 网关超时 - 请求超时。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: 网关超时
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    SerializablePubkey:
      type: string
      description: 表示为 base58 字符串的 Solana 公钥。
      default: 11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP
      example: 11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP
    Hash:
      type: string
      description: 表示为 base58 字符串的 32 字节哈希。
      example: 11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP
    Context:
      type: object
      required:
        - slot
      properties:
        slot:
          type: integer
          default: 100
          example: 100
    UnsignedInteger:
      type: integer
      default: 100
      example: 100
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: JSON-RPC 协议版本。
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: 错误代码。
              example: -32602
            message:
              type: string
              description: 错误信息。
            data:
              type: object
              description: 关于错误的附加数据。
        id:
          type: string
          description: 与请求匹配的标识符。
          example: '1'
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: >-
        您的 Helius API
        密钥。您可以在[仪表板](https://dashboard.helius.dev/api-keys)中免费获取一个。

````