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

# Execute a query function on a contract

> Query the state of a contract by providing the address and blockchain.



## OpenAPI

````yaml openapi/smart-contract-platform.yaml post /v1/w3s/contracts/query
openapi: 3.0.3
info:
  description: This is the Circle Contracts API documentation.
  title: Circle Contracts
  version: '1.0'
servers:
  - url: https://api.circle.com
security:
  - BearerAuth: []
tags:
  - name: Templates
  - name: View / Update
  - name: Interact
  - name: Deploy / Import
  - name: Event Monitors
paths:
  /v1/w3s/contracts/query:
    post:
      tags:
        - Interact
      summary: Execute a query function on a contract
      description: Query the state of a contract by providing the address and blockchain.
      operationId: queryContract
      parameters:
        - $ref: '#/components/parameters/XRequestId'
      requestBody:
        $ref: '#/components/requestBodies/ReadContractState'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadContractState'
          description: Contract read successfully.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error response for the request.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
      security:
        - BearerAuth: []
components:
  parameters:
    XRequestId:
      name: X-Request-Id
      in: header
      description: >
        Developer-provided identifier for this request, used for tracing
        requests in Wallets API logs and the Developer Console, and when
        communicating with Circle Support.

        **Must be a UUID to appear in logs.** Non-UUID values are accepted by
        the API but are ignored by logging and tracing systems.
      schema:
        $ref: '#/components/schemas/XRequestId'
  requestBodies:
    ReadContractState:
      content:
        application/json:
          schema:
            title: ReadContractStateRequest
            type: object
            required:
              - address
              - blockchain
            properties:
              abiFunctionSignature:
                $ref: '#/components/schemas/AbiFunctionSignature'
              abiParameters:
                $ref: '#/components/schemas/AbiParameters'
              abiJson:
                $ref: '#/components/schemas/AbiJson'
              address:
                description: Address of the contract to be queried.
                type: string
                example: '0x1e124d7384cd34448ea5907bd0052a79355ab5eb'
              blockchain:
                $ref: '#/components/schemas/Blockchain'
              callData:
                description: CallData is input data that encodes method and parameters.
                type: string
              fromAddress:
                description: >-
                  FromAddress is the address that will populate msg.sender in
                  the contract call.
                type: string
      description: Read contract state by executing a read ABI function.
      required: true
  schemas:
    ReadContractState:
      title: ReadContractStateResponse
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - outputValues
            - outputData
          properties:
            outputValues:
              type: array
              description: Output for the ABI interaction.
              items:
                $ref: '#/components/schemas/AnyValue'
            outputData:
              description: OutputData is output in hex format.
              format: hex
              type: string
    Error:
      title: Error
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: Code that corresponds to the error.
        message:
          type: string
          description: Message that describes the error.
    XRequestId:
      type: string
      format: uuid
      description: >-
        A unique identifier, which can be helpful for identifying a request when
        communicating with Circle support.
      example: 2adba88e-9d63-44bc-b975-9b6ae3440dde
    AbiFunctionSignature:
      title: AbiFunctionSignature
      type: string
      description: "The contract ABI function signature or\_`callData`\_field is required for interacting with the smart contract. The ABI function signature cannot be used simultaneously with\_`callData`. e.g. burn(uint256)"
      example: burn(uint256)
    AbiParameters:
      title: AbiParameters
      type: array
      items:
        anyOf:
          - type: string
          - type: integer
          - type: boolean
          - type: array
            items: {}
      description: "The contract ABI function signature parameters for executing the contract interaction. Supported parameter types include string, integer, boolean, and array. These parameters should be used exclusively with the abiFunctionSignature and cannot be used with\_`callData`."
      example:
        - '100'
        - '1'
    AbiJson:
      type: string
      description: The contract's ABI in a JSON stringified format.
      example: >-
        [{"inputs": [],"stateMutability": "nonpayable","type":
        "constructor"},...
    Blockchain:
      type: string
      description: >
        The blockchain network that the resource is to be created on or is
        currently on. 

        Required along with `sourceAddress` if you don't provide `walletId`. The
        `blockchain` and `walletId` fields are mutually exclusive.
      enum:
        - ETH
        - ETH-SEPOLIA
        - MATIC
        - MATIC-AMOY
        - ARB
        - ARB-SEPOLIA
        - UNI
        - UNI-SEPOLIA
        - BASE
        - BASE-SEPOLIA
        - OP
        - OP-SEPOLIA
        - AVAX
        - AVAX-FUJI
        - ARC-TESTNET
        - MONAD
        - MONAD-TESTNET
      example: MATIC-AMOY
    AnyValue:
      description: Can be any value - string, number, boolean, array or object.
  headers:
    XRequestId:
      description: >
        Developer-provided header parameter or Circle-generated universally
        unique identifier (UUID v4). Useful for identifying a specific request
        when communicating with Circle Support.
      schema:
        $ref: '#/components/schemas/XRequestId'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: PREFIX:ID:SECRET
      description: >-
        Circle's API Keys are formatted in the following structure
        "PREFIX:ID:SECRET". All three parts are required to make a successful
        request.

````