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

# 历史 getMultipleAccounts RPC 方法

> 一次请求读取最多 100 个 Solana 账户在任意过去 slot 的状态。查看历史 getMultipleAccounts 的参数、限制和代码示例。

使用标准的 **getMultipleAccounts** 方法读取最多 100 个账户过去的状态。在配置对象中添加以下其中一项：

* `slot`：每个账户在该 slot 结束时的状态。
* `lastUpdateBeforeSlot`：每个账户在该 slot 之前（不含）各自最后一次更新后的状态。
* `firstUpdateAfterSlot`：每个账户在该 slot 之后（不含）各自第一次更新后的状态。

只能设置其中一项。都不设置时，`getMultipleAccounts` 返回账户的当前状态，见 [getMultipleAccounts](https://docs.solanatracker.io/cn/solana-rpc/http/getmultipleaccounts.md)。

结果按输入顺序返回。使用 `lastUpdateBeforeSlot` 和 `firstUpdateAfterSlot` 时，各账户可能来自不同的 slot，因此结果会增加 `slots`：每个账户一个 slot，按输入顺序排列；账户在该方向没有更新时为 `null`。

## 限制

* 历史读取返回 finalized 数据。`commitment` 会被忽略，`minContextSlot` 不能与这些选项同时使用。
* 账户在该时间点不存在或已关闭，或没有可用数据时，`value` 中对应项为 `null`。
* **SPL Token 和 Token-2022 的 mint 账户**无法按历史读取：返回错误 `-32033`，`data.reason` 为 `"splTokenMint"`，**只要有一个这样的地址，整个请求就会失败**。Stake、vote、config 和 sysvar 账户也返回 `-32033`。
* **代币账户**根据其余额历史重建。会返回余额、mint、所有者和租金 lamports；不返回 Token-2022 扩展、委托人、冻结状态、关闭权限和精确的 `space`。
* 晚于最新可用 slot 的 slot 返回 `-32030`，早于最早可用 slot 的返回 `-32031`，没有可用数据的 slot 返回 `-32034`。`lastUpdateBeforeSlot` 或 `firstUpdateAfterSlot` 遍历超过第一次或最后一次已知更新时返回 `-32020`。
* `dataSlice` 不能与 `jsonParsed` 或 `jsonParsedEnhanced` 同时使用。

一次历史读取消耗 1 积分，与实时调用相同。要遍历单个账户的历史并获取更早版本，请使用[历史 getAccountInfo](https://docs.solanatracker.io/cn/solana-rpc/http/historical-getaccountinfo.md)。

请求配置和错误处理见 [RPC 快速入门](https://docs.solanatracker.io/cn/solana-rpc/quickstart.md)。计费见[积分与限制](https://docs.solanatracker.io/cn/solana-rpc/credits-and-rate-limits.md)。


## OpenAPI

````yaml historical-getmultipleaccounts post /
openapi: 3.1.0
info:
  title: Solana RPC
  version: 1.0.0
  description: Solana RPC HTTP method reference.
servers:
  - url: https://rpc-mainnet.solanatracker.io
    description: Mainnet RPC endpoint
security: []
paths:
  /:
    post:
      summary: Historical getMultipleAccounts
      description: >-
        Read up to 100 accounts as they were at a past slot, in input order.
        Send `getMultipleAccounts` with `slot`, `lastUpdateBeforeSlot` or
        `firstUpdateAfterSlot` in the config object.
      operationId: historical-getmultipleaccounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  allOf:
                    - type: string
                      description: The JSON-RPC protocol version.
                      enum:
                        - '2.0'
                      example: '2.0'
                      default: '2.0'
                id:
                  allOf:
                    - type: string
                      description: A unique identifier for the request.
                      example: '1'
                      default: '1'
                method:
                  allOf:
                    - type: string
                      description: The name of the RPC method to invoke.
                      enum:
                        - getMultipleAccounts
                      example: getMultipleAccounts
                      default: getMultipleAccounts
                params:
                  allOf:
                    - type: array
                      description: Parameters for the method.
                      default:
                        - - 7xK1a6Ut1pCrH9CiMwdEqx7RyhqgUZRux692Sg4m1TTw
                          - H8sMJSCQxfKiFTCfDR3DUMLPwcRbM61LGFJ8N4dK3WjS
                        - encoding: base64
                          slot: 411108200
                      items:
                        oneOf:
                          - type: array
                            description: >-
                              Array of Solana account addresses (up to 100) to
                              fetch in a single optimized batch request.
                            items:
                              type: string
                            example:
                              - vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
                              - 4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA
                          - type: object
                            description: >-
                              Required. Set exactly one of `slot`,
                              `lastUpdateBeforeSlot` or `firstUpdateAfterSlot`.
                              Historical reads always return finalized data.
                            properties:
                              dataSlice:
                                type: object
                                description: >-
                                  Request a slice of the account's data. Not
                                  allowed with `jsonParsed` or
                                  `jsonParsedEnhanced`.
                                properties:
                                  length:
                                    type: integer
                                    description: Number of bytes to return.
                                    example: 50
                                  offset:
                                    type: integer
                                    description: Byte offset from which to start reading.
                                    example: 0
                              encoding:
                                type: string
                                description: >-
                                  Encoding format for the returned account data.
                                  `jsonParsedEnhanced` is `jsonParsed` plus
                                  Anchor IDL decoding of account data the
                                  standard parser leaves unparsed. It costs no
                                  extra credits.
                                enum:
                                  - jsonParsed
                                  - jsonParsedEnhanced
                                  - base58
                                  - base64
                                  - base64+zstd
                                example: base58
                              changedSinceSlot:
                                type: integer
                                description: >-
                                  Only return accounts that have been modified
                                  at or after this slot number. For accounts
                                  that exist but haven't changed since the
                                  specified slot, the response will contain
                                  status as "unchanged".
                                example: 464175999
                              slot:
                                type: integer
                                description: >-
                                  return each account as it was at the end of
                                  this slot (the last update at or before it).
                                  Set at most one of `slot`,
                                  `lastUpdateBeforeSlot` and
                                  `firstUpdateAfterSlot`.
                                example: 411108200
                              lastUpdateBeforeSlot:
                                type: integer
                                description: >-
                                  return each account as of its most recent
                                  update strictly before this slot. Set at most
                                  one of `slot`, `lastUpdateBeforeSlot` and
                                  `firstUpdateAfterSlot`. Each account moves to
                                  its own nearest update; `result.slots` says
                                  which slot each one is from.
                                example: 411108200
                              firstUpdateAfterSlot:
                                type: integer
                                description: >-
                                  return each account as of its first update
                                  strictly after this slot. Set at most one of
                                  `slot`, `lastUpdateBeforeSlot` and
                                  `firstUpdateAfterSlot`. Each account moves to
                                  its own nearest update; `result.slots` says
                                  which slot each one is from.
                                example: 411000000
                      minItems: 2
              required:
                - jsonrpc
                - id
                - method
                - params
            examples:
              historicalAtSlot:
                summary: Historical read at a slot
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getMultipleAccounts
                  params:
                    - - 7xK1a6Ut1pCrH9CiMwdEqx7RyhqgUZRux692Sg4m1TTw
                      - H8sMJSCQxfKiFTCfDR3DUMLPwcRbM61LGFJ8N4dK3WjS
                    - encoding: base64
                      slot: 411108200
              historicalLastUpdateBefore:
                summary: Each account's most recent update before a slot
                value:
                  jsonrpc: '2.0'
                  id: 1
                  method: getMultipleAccounts
                  params:
                    - - 7xK1a6Ut1pCrH9CiMwdEqx7RyhqgUZRux692Sg4m1TTw
                      - H8sMJSCQxfKiFTCfDR3DUMLPwcRbM61LGFJ8N4dK3WjS
                    - encoding: base64
                      lastUpdateBeforeSlot: 411108200
      responses:
        '200':
          description: Successfully retrieved the account details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                  result:
                    allOf:
                      - type: object
                        description: Accounts information with context.
                        properties:
                          context:
                            type: object
                            description: Context of the response.
                            properties:
                              apiVersion:
                                type: string
                                description: API version of the response.
                                example: 2.0.15
                              slot:
                                type: integer
                                description: >-
                                  The slot at which the data was fetched. For
                                  `lastUpdateBeforeSlot` and
                                  `firstUpdateAfterSlot`, the slot you passed.
                                example: 341197247
                          value:
                            type: array
                            description: Array of account details.
                            items:
                              oneOf:
                                - type: 'null'
                                  description: >-
                                    Null if the account doesn't exist. On a
                                    historical read: the account did not exist
                                    or was closed at that point, or no data is
                                    known for it.
                                - type: object
                                  description: Account details.
                                  properties:
                                    lamports:
                                      type: integer
                                      description: >-
                                        Number of lamports assigned to the
                                        account.
                                      example: 88849814690250
                                    owner:
                                      type: string
                                      description: >-
                                        Base-58 encoded Pubkey of the program
                                        the account is assigned to.
                                      example: '11111111111111111111111111111111'
                                    data:
                                      type: array
                                      description: >-
                                        Account data as encoded binary or JSON
                                        format.
                                      items:
                                        type: string
                                      example:
                                        - ''
                                        - base58
                                    executable:
                                      type: boolean
                                      description: >-
                                        Indicates if the account contains a
                                        program.
                                      example: false
                                    rentEpoch:
                                      type: integer
                                      description: >-
                                        Epoch at which this account will next
                                        owe rent.
                                      example: 18446744073709552000
                                    space:
                                      type: integer
                                      description: Data size of the account.
                                      example: 0
                                - type: object
                                  description: >-
                                    Status-only response when account exists but
                                    hasn't changed since the specified slot.
                                  properties:
                                    status:
                                      type: string
                                      description: >-
                                        Status indicating the account hasn't
                                        changed since the specified slot.
                                      enum:
                                        - unchanged
                                      example: unchanged
                          slots:
                            type: array
                            description: >-
                              Only with `lastUpdateBeforeSlot` or
                              `firstUpdateAfterSlot`: the slot of the update
                              returned for each account, in the same order as
                              `value`. `null` where an account has no update on
                              that side of the slot.
                            items:
                              type:
                                - integer
                                - 'null'
                            example:
                              - 411107934
                              - null
              examples:
                historicalLastUpdateBefore:
                  summary: Each account's most recent update before a slot
                  value:
                    jsonrpc: '2.0'
                    id: 1
                    result:
                      context:
                        apiVersion: 4.2.1
                        slot: 411108200
                      value:
                        - data:
                            - ''
                            - base64
                          executable: false
                          lamports: 1523847120
                          owner: '11111111111111111111111111111111'
                          rentEpoch: 18446744073709552000
                          space: 0
                        - null
                      slots:
                        - 411107934
                        - null
                splTokenMint:
                  summary: SPL Token mint (not available historically)
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32033
                      message: >-
                        Historic SPL Token mint state is not archived:
                        EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                      data:
                        pubkeys:
                          - EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                        reason: splTokenMint
                    id: 1
        '400':
          description: Bad Request - Invalid request parameters or malformed request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32602
                      message: Invalid params
                      data:
                        additionalInfo: >-
                          Please check the request parameters and ensure they
                          are valid.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '401':
          description: Unauthorized - Invalid or missing API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32001
                      message: Unauthorized
                      data:
                        additionalInfo: Please verify your API key and try again.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '429':
          description: Too Many Requests - Rate limit exceeded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32005
                      message: Too many requests
                      data:
                        additionalInfo: >-
                          You have exceeded the allowed number of requests.
                          Please wait and try again later.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '500':
          description: Internal Server Error - An error occurred on the server.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32603
                      message: Internal error
                      data:
                        additionalInfo: >-
                          An unexpected error occurred on the server. Please try
                          again later or contact support.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '503':
          description: Service Unavailable - The service is temporarily unavailable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32002
                      message: Service unavailable
                      data:
                        additionalInfo: >-
                          The service is currently unavailable. Please try again
                          later or contact support.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
        '504':
          description: Gateway Timeout - The request timed out.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    allOf:
                      - type: string
                        description: The JSON-RPC protocol version.
                        enum:
                          - '2.0'
                        example: '2.0'
                  error:
                    allOf:
                      - type: object
                        properties:
                          code:
                            type: integer
                            description: The error code.
                            example: -32602
                          message:
                            type: string
                            description: The error message.
                          data:
                            type: object
                            description: Additional data about the error.
                  id:
                    allOf:
                      - type: string
                        description: Identifier matching the request.
                        example: '1'
                refIdentifier: '#/components/schemas/ErrorResponse'
              examples:
                example:
                  value:
                    jsonrpc: '2.0'
                    error:
                      code: -32003
                      message: Gateway timeout
                      data:
                        additionalInfo: >-
                          The request timed out. Please try again later or
                          contact support.
                    id: db16f277-1a22-41ff-9f85-f37e2cd77900
      security:
        - ApiKeyQuery: []
components:
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.