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
  4. ContractCondition

Use custom contract calls

In this section we show how to use implement support for custom contract calls in ContractCondition.

Let's start with the following example:

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

const myFunctionAbi: conditions.base.contract.FunctionAbiProps =  {
  name: 'myFunction',
  type: 'function',
  stateMutability: 'view',
  inputs: [
    {
      internalType: 'address',
      name: 'account',
      type: 'address',
    },
    {
      internalType: 'uint256',
      name: 'myCustomParam',
      type: 'uint256',
    },
  ],
  outputs: [
    {
      internalType: 'uint256',
      name: 'someValue',
      type: 'uint256',
    },
  ],
};

const myContractCallCondition = new conditions.base.contract.ContractCondition({
  method: 'myFunction', // `myMethodAbi.name`
  parameters: [':userAddress', ':myCustomParam'], // `myMethodAbi.inputs`
  functionAbi: myFunctionAbi, // Our custom function ABI
  contractAddress: '0x0...1',
  chain: 5,
  returnValueTest: {
    comparator: '>',
    value: 0,
  },
});

First, let's take a look at myFunctionAbi:

  • We define a complete function ABI with name, type, stateMutability, inputs, and outputs

  • With those fields in place, our function shapes up to be defined as myFunction(address, uint256): uint256

  • Note that type field required to be function and stateMutability to pure and view to avoid accidentally mutating the contract state

Now, looking at myContractCallCondition we can see that:

  • We need to pass myFunction as method and myFunctionAbi as functionAbi for our contract call to be recognized correctly

  • Lastly, the myFunctionAbi.outputs will be used by returnValueTest to compare with the selected threshold value, resulting in a test myFunctionAbi.outputs[0] > 0

Learn more

PreviousContractConditionNextImplement access revocation via smart contract

Last updated 8 months ago

We've mapped our function parameters to parameters, so that address is represented as ':userAddress' and uint256 is represented as ':myCustomParam'. See for more details.

See how to implement access control revocation using custom contract calls .

Condition Context and Context Variables
here