What is a Calling Contract Admin?

A Calling Contract Admin is a special role that manages which policies are checked when a contract interacts with the rules engine. Think of it as a “policy manager” for a specific contract.

Key Responsibilities

  • Policy Selection: Decides which rules and policies should be applied when the contract makes requests to the rules engine
  • Configuration Management: Sets up what gets checked during policy evaluations
  • No Policy Creation: Cannot create or modify the actual policies themselves - only chooses which ones to use

Important Rules

  • Each calling contract can have exactly one Calling Contract Admin
  • One person/address can be the Calling Contract Admin for multiple different contracts
  • Only the Calling Contract Admin can configure which policies are checked for their specific contract

Setting Up a Calling Contract Admin

Step 1: Prepare Your Contract

Your contract must inherit from the RulesEngineClient abstract contract, which is available in the forte-rules-engine npm package.

Step 2: Deploy and Assign

After deployment, the contract owner can assign a Calling Contract Admin using the setCallingContractAdmin() function (inherited from RulesEngineClient).

Step 3: Secure the Function

Important: You must override the setCallingContractAdmin() function with proper access controls to prevent unauthorized users from changing the admin. It’s recommended that only the current Calling Contract Admin should be able to invoke this function.

Transferring the Role

The Calling Contract Admin role can be transferred to another address, but there’s a safety mechanism:
  1. The current admin initiates the transfer
  2. The new admin must accept the role
  3. Only after acceptance is the transfer completed
This two-step process ensures that roles aren’t transferred to unwilling recipients.