# Conditions

This section focuses on `Condition` types, composition and usage.

{% hint style="success" %}
**Authoring conditions with an LLM?** Start with [Building Conditions with an LLM](/for-developers/taco-sdk/references/conditions/building-with-llms.md). The four key references are:

* The [Cookbook](/for-developers/taco-sdk/references/conditions/cookbook.md) — JSON examples for every condition type.
* The [Discord tipping bot deep-dive](/for-developers/taco-sdk/references/conditions/discord-tipping-bot-deep-dive.md) — a fully annotated complex condition.
* The [Schema reference](https://github.com/nucypher/taco-web/blob/signing-epic/packages/taco/schema-docs/condition-schemas.md) — auto-generated source of truth (markdown). A [JSON Schema version](https://raw.githubusercontent.com/nucypher/taco-web/signing-epic/packages/taco/schema-docs/condition-schema.json) is available for editors and structured-output LLMs.
* The [Validator script](/for-developers/taco-sdk/references/conditions/validating-conditions.md) — catch shape errors locally before hitting the network.

When something breaks, see [Troubleshooting](/for-developers/taco-sdk/references/conditions/troubleshooting.md) and the [Context Variables cheatsheet](/for-developers/taco-sdk/references/conditions/context-variables.md).
{% endhint %}

## Base Conditions

Base conditions define specific criteria, and each includes a `returnValueTest` to compare the actual execution result with the expected value. These include:

* [`TimeCondition`](/for-developers/taco-sdk/references/conditions/timecondition.md) – time-based conditions using block height and other blockchain-based timestamps.\
  \&#xNAN;*Example:* only allow access after a certain timestamp.
* [`RpcCondition`](/for-developers/taco-sdk/references/conditions/rpccondition.md) – based on RPC calls as defined in Ethereum's Official [API](https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods).\
  \&#xNAN;*Example:* allow access if the requestor address holds a minimum ETH balance.
* [`ContractCondition`](/for-developers/taco-sdk/references/conditions/contractcondition.md) – uses on-chain state, allowing arbitrary contract function calls.\
  \&#xNAN;*Example:* allow access if this requestor holds a special-purpose NFT.
* [JSON Endpoint Conditions](/for-developers/taco-sdk/references/conditions/json-endpoint-conditions.md) - uses state from a JSON HTTPS endpoint.\
  \&#xNAN;*Example:* allow discount on event tickets/merchandise if there is "bad" weather according to a specific weather API.
* [`JWTCondition`](/for-developers/taco-sdk/references/conditions/jwtcondition.md) - validates [JSON Web Tokens (JWTs)](https://datatracker.ietf.org/doc/html/rfc7519) against a specified public key.
* [Signing Object Conditions](/for-developers/taco-sdk/references/conditions/signing-object-conditions.md) - validates objects submitted for threshold signing meet specified criteria by inspecting the values of designated fields (eg. `UserOperation` for ERC-4337)

Each base condition defines a [`returnValueTest`](#return-value-test) used to compare the obtained execution value with the expected value for the condition.

### returnValueTest

A `returnValueTest` is a mechanism used by a condition to evaluate whether a specific execution result meets a specified criterion. It allows dynamic comparisons between the actual returned value and the expected value.

It consists of three key components:

* `comparator`: defines the comparison operation to apply between the actual value obtained and the expected value. The available operators include:
  * `==`: equal to
  * `!=`: not equal to
  * `>`: greater than
  * `<`: less than
  * `>=`: greater than or equal to
  * `<=`: less than or equal to
  * `in`: value in array of values
  * `!in`: value not in array of values
* `value`: the expected value to compare against the actual returned value.
* `index` *(optional)*: indicates the position of the value to use for comparison within a list or array when multiple values are returned. If the response includes several values, this index determines which entry to evaluate. If the index is not specified, the entire response is used. For instance, if the array `["apple", "banana", "grape"]` is returned during execution, an index of `1` would select `"banana"` as the value for comparison.

### Context Variables

[Context variables](/for-developers/taco-sdk/references/authentication/conditioncontext-and-context-variables.md) provide the ability for placeholder values to be defined within conditions at creation time, and be dynamically populated at verification time e.g. current user wallet address.

## Logical Conditions

Logical conditions use control structures to determine overall condition outcomes based on the results of underlying conditions. These include:

* [`CompoundCondition`](/for-developers/taco-sdk/references/conditions/logical-conditions/condition-set.md) - allows conditions to be combined using logical operators such as `or`, `and` & `not` .
* [`SequentialCondition`](/for-developers/taco-sdk/references/conditions/logical-conditions/sequentialcondition.md) - chains conditions to be executed in a specific order, where the outcome of one condition can be used by subsequent conditions.
* [`IfThenElseCondition`](/for-developers/taco-sdk/references/conditions/logical-conditions/ifthenelsecondition.md) - implements branching logic for conditions where the flow follows an if-then-else structure i.e. **IF** `CONDITION_A` **THEN** `CONDITION_B` **ELSE** `CONDITION_C`

{% hint style="info" %}
Since condition evaluations may require making remote calls (e.g. RPC calls, etc.), the number of conditions allowed within a `Logical Condition` is limited.

A single `Logical Condition`can contain a maximum of five conditions. Additionally, the nesting of a `Logical Condition` within a `Logical Condition` is allowed, but the maximum nesting depth is restricted to two levels. Therefore, a `Logical Condition` can contain a sub-`Logical Condition` but that sub-`Logical Condition` cannot subsequently contain a `Logical Condition`.
{% endhint %}


---

# Agent Instructions: 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.taco.build/for-developers/taco-sdk/references/conditions.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.
