> For the complete documentation index, see [llms.txt](https://docs.guild.xyz/guild/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.guild.xyz/guild/how-to-setup-requirements/contract-query.md).

# Contract query

Check if a smart contract method returns specific values when called. Perfect for verifying custom onchain conditions, protocol holdings, or complex smart contract states.

\
**Setting up Contract Query requirements:**

* In the role editor, click **"Add requirements"** and select **Contract query**
* Fill out the parameters:

  * Select the **Chain** where your contract is deployed

  * Enter the **Contract address** you want to query

  * Choose the contract **Method** from the dropdown (Guild automatically fetches available methods from the contract ABI)

  * Fill in the **Input parameters** - Guild shows the exact fields needed with names, types, and indexes

  * Select **Output to check** - choose which return value from the contract method to verify

    * **Output index** - Smart contract methods can return multiple values. The index (0, 1, 2, etc.) specifies which returned value to check:

      * Index 0 = first returned value
      * Index 1 = second returned value
      * Index 2 = third returned value, and so on

      \
      \&#xNAN;*If a contract method returns `(uint256 balance, address owner, bool isActive)`, you would:*

      * *Use index 0 to check the balance (bigint)*
      * *Use index 1 to check the owner address*
      * *Use index 2 to check if it's active (boolean)*

    * **Output types:**
      * **Output bigint** - Large numbers (token balances, timestamps, counts, IDs)
      * **Output address** - Wallet addresses or contract addresses
      * **Output boolean** - True/false values (eligibility checks, status flags)

  * Add custom image and name for the requirement if you want

  * Click **"Add requirement"**<br>

Members connect their wallet and Guild automatically calls the specified contract method with the configured parameters. If the contract returns the expected output value, the member qualifies for the role.


---

# 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:

```
GET https://docs.guild.xyz/guild/how-to-setup-requirements/contract-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
