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
  • Examples
  • IF conditionA then conditionB else conditionC
  • IF conditionA then conditionB else True
  • Nested IfThenElseCondition
  • Development References
  1. For Developers
  2. API
  3. Access Control
  4. Logical Conditions

IfThenElseCondition

The IfThenElseCondition allows for conditional branching, where different conditions are executed based on the outcome of an initial "if" condition. It operates with a simple "if-then-else" structure and provides flexibility in determining the behaviour when a condition is true or false.

A condition that allows for if-then-else branching based on underlying conditions i.e. IF CONDITION_A THEN CONDITION_B ELSE CONDITION_C.

It is composed of:

  • ifCondition: A required field that specifies the condition to be evaluated first. If the condition evaluates to true, the thenCondition is executed; if it evaluates to false, the elseCondition is executed.

  • thenCondition: A required field that specifies the action or condition to execute if the ifCondition evaluates to true.

  • elseCondition: A required field that specifies the action or condition to execute if the ifCondition evaluates to false. This can be a CONDITIONor a boolean value (true or false), specifying the result when the ifCondition is false. This gives users control over what the overall condition returns when the ifCondition is false.

When combined with other conditions (e.g., SequentialCondition, CompoundCondition), the IfThenElseCondition allows for complex, branching workflows.

Examples

IF conditionA then conditionB else conditionC

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

const conditionA = ...
const conditionB = ...
const conditionC = ...

const condition = new conditions.ifThenElse.IfThenElseCondition({
  ifCondition: conditionA,
  thenCondition: conditionB,
  elseCondition: conditionC,
});

IF conditionA then conditionB else True

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

const conditionA = ...
const conditionB = ...

const condition = new conditions.ifThenElse.IfThenElseCondition({
  ifCondition: conditionA,
  thenCondition: conditionB,
  elseCondition: true,
});

Nested IfThenElseCondition

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

const conditionA = ...
const conditionB = ...
const conditionC = ...
const conditionD = ...

const nestedIfThenElseCondition = new conditions.ifThenElse.IfThenElseCondition({
  ifCondition: conditionA,
  thenCondition: conditionB,
  elseCondition: false,
});

const condition = new conditions.ifThenElse.IfThenElseCondition({
  ifCondition: conditionC,
  thenCondition: conditionD,
  elseCondition: nestedIfThenElseCondition,
});

Individual conditions within the IfThenElseCondition can use different chain IDs as long as the chain IDs are supported by the domain network being used.

Development References

PreviousCompoundConditionNextSequentialCondition

Last updated 7 months ago

Client-side:

Server-side:

https://github.com/nucypher/taco-web/pull/593
https://github.com/nucypher/nucypher/pull/3558