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 no more than 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
  • Calling Contract Admin may renounce their role

What Happens When the Admin Renounces Their Role?

If the Calling Contract Admin renounces their role, the contract will temporarily have no admin. During this period:
  • No one can configure or change which policies are checked for the contract.
  • Policy management functionality becomes unavailable until a new admin is assigned.
  • Only the contract owner (or another authorized party, depending on your access controls) can assign a new Calling Contract Admin using the setCallingContractAdmin() function.
  • It is recommended to promptly assign a new admin to restore policy management capabilities.
Renunciation is irreversible for the previous admin; they must be re-assigned if they wish to regain the role.

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.