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

RpcCondition

PreviousTimeConditionNextContractCondition

Last updated 7 months ago

RpcConditions allows data access based on the evaluation of a JSON-RPC call.

Below, we can see an example of using RpcCondition to gate access based on a native asset balance.

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

const ownsETH = new conditions.base.rpc.RpcCondition({
  method: 'eth_getBalance',
  parameters: [':userAddress'],
  chain: 1,
  returnValueTest: {
    comparator: '>=',
    value: 1,
  },
});

Knowing the , we need to pass a wallet address parameter into the parameters field (the default block used is latest).

 method: 'eth_getBalance',
 parameters: [':userAddress'],

':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.

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: 1,
},

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

  • Since the RPC call returns only one value, we don't need to specify the index field

  • Compare it using the following comparator, comparator: '>='

  • Compare the value returned by the RPC call to the following value, value: 1

Combining these three, we can see that the returnValueTest will "trigger" if the value returned by the RPC call is greater than one.

In other words, our condition is only satisfied if eth_getBalance(:userAddress) >= 1 i.e. only if the user's wallet has a native balance greater than or equal to 1.

Learn more

  • API

signature of this method
context variable