> For the complete documentation index, see [llms.txt](https://docs.taco.build/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taco.build/for-developers/conditions/contractcondition.md).

# ContractCondition

`ContractCondition` is based on the evaluation of contract calls.

Below, we can see an example of using `ContractConditon` to gate access to our data behind an NFT ownership condition.

```typescript
import { conditions } from '@nucypher/taco';

const ownsNFT = new conditions.base.contract.ContractCondition({
  method: 'balanceOf',
  parameters: [':userAddress'],
  standardContractType: 'ERC721',
  contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77',
  chain: 1,
  returnValueTest: {
    comparator: '>',
    value: 0,
  },
});

```

Now, let's break it down step by step.

With `ContractCondition`, we can either use one of the predefined contracts, such as `ERC20` or `ERC721` standards. Alternatively, we can also use [any arbitrary contract calls provided we include `functionAbi`](/for-developers/conditions/contractcondition/use-custom-contract-calls.md) into our condition.

In the case of our condition, we use a `standardContractType` of `ERC721`.

```typescript
standardContractType: 'ERC721',
```

This contract exposes a number of methods, including [`balanceOf`](https://docs.openzeppelin.com/contracts/5.x/api/token/erc721#IERC721-balanceOf-address-). Knowing the signature of this method, we need to pass one parameter into `parameters`

```typescript
 method: 'balanceOf',
 parameters: [':userAddress'],
```

`':userAddress'` is a reserved [context parameter](https://app.gitbook.com/o/R2meumXNNad4y1B10iL7/s/WosjlL4zUGUMlcMfuSAp/~/changes/274/app-development/threshold-access-control-tac/conditions/context-and-context-parameters) that denotes the address of the recipient that will attempt to decrypt our data. Before the attempt is made, the `':userAddress'` value will be replaced with the actual wallet address.

Now that we've specified our contract call, we need to figure out what to do with the contract call results. Let's take a look at the `returnValueTest` field:

```typescript
returnValueTest: {
  comparator: '>',
  value: 0,
},
```

`returnValueTest` is going to evaluate the contract call result according to the following logic:

* Since the contract call returns only one value, we don't need to specify the `index` field
* Compare it using the following comparator, `comparator: '>'`
* Compare it to the following value, `value: 0`

Combining these three, we can see that the `returnValueTest` will hold true if the value returned by the contract call is greater than zero.

In other words, our condition is only satisfied if `ERC721.balanceOf(:userAddress) > 0` i.e. if the user's wallet has the relevant NFT balance greater than 0.

### Learn more

* [Broken mention](broken://pages/3qufTlyKsrLICoyVGk9J)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.taco.build/for-developers/conditions/contractcondition.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
