Threshold Access Control (TACo)
  • Getting Started
    • Introduction to TACo
    • How TACo Works
    • Quickstart (Testnet)
  • For Developers
    • Integrate TACo Into Apps
      • Testnets
      • Mainnet Access
      • Mainnet Deployment
    • Ecosystem Integrations
      • OrbisDB
      • Waku
      • Irys
      • ComposeDB
      • Turbo
    • API
      • Encryptor Allowlist
      • Encrypt & Decrypt
      • Authentication
        • Condition Context
      • Access Control
        • TimeCondition
        • RpcCondition
        • ContractCondition
          • Use custom contract calls
          • Implement access revocation via smart contract
        • JSON Endpoint Conditions
          • JsonApiCondition
          • JsonRpcCondition
        • JWT Conditions
        • Logical Conditions
          • CompoundCondition
          • IfThenElseCondition
          • SequentialCondition
        • WIP / Feature Requests
          • Any (Major) EVM Chain Condition Support
    • Blueprints & Inspiration
      • Seed phrase recovery & transfer
      • Digital Rights Management for on-chain assets
      • Trustless channels for journalists, archivists & whistleblowers
      • Crowdsourcing real-world data with trustless contribution
  • For Product Leads
    • Value Propositions
    • Capabilities & Extensions
    • Use cases
      • Seed phrase recovery & transfer
      • Digital Rights Management for on-chain assets
      • Trustless channels for journalists, archivists & whistleblowers
      • Crowdsourcing real-world data with trustless contribution
    • Mainnet Fees
    • Trust Assumptions
      • Mainnet Trust Disclosure (Provider Answers)
      • Mainnet Trust Model Foundation
      • Trust levers & parameter packages
  • Reference
    • Contract Addresses
    • Architecture
      • Porter
    • Github
    • TACo Playground
    • TACo Scan
  • For Node Operators
    • Getting Set Up
      • Minimum System Requirements
      • Run a TACo Node with Docker
    • Operations
      • TACo Node Management
      • TACo Node Recovery
      • Stake Authorization
    • Duties, Compensation & Penalties
    • Run a Porter Instance
Powered by GitBook
On this page
  1. For Developers
  2. API
  3. Access Control

ContractCondition

PreviousRpcConditionNextUse custom contract calls

Last updated 7 months ago

ContractCondition allow data access 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.

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 ContractConditions, we can either use one of the predefined contracts, such as ERC20 or ERC721 standards. Alternatively, we can also use into our condition.

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

standardContractType: 'ERC721',
 method: 'balanceOf',
 parameters: [':userAddress'],

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:

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

  • API

This contract exposes a number of methods, including . Knowing the signature of this method, we need to pass one parameter into parameters

':userAddress' is a reserved 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.

any arbitrary contract calls provided we include functionAbi
balanceOf
context parameter