> ## Documentation Index
> Fetch the complete documentation index at: https://thrackle.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# RulesEngineClient

[Git Source](https://github.com/forte-service-company-ltd/forte-rules-engine/blob/1f7450a94147e76e3930c235a18534779130abee/src/client/RulesEngineClient.sol)

**Author:**
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220

SPDX-License-Identifier: BUSL-1.1

This contract is intended to be inherited by other contracts that require Rules Engine integration.

*Abstract contract that provides functionality to connect and interact with the Rules Engine.
This contract includes methods to set the Rules Engine address, invoke the Rules Engine,
and manage calling contract admin roles.*

## State Variables

### rulesEngineAddress

Address of the Rules Engine contract

```solidity
address public rulesEngineAddress;
```

## Functions

### setCallingContractAdmin

Sets the admin role for the calling contract in the Rules Engine.

*This function assigns the admin role for the calling contract to the specified address.*

```solidity
function setCallingContractAdmin(address callingContractAdmin) external;
```

**Parameters**

| Name                   | Type      | Description                                                       |
| ---------------------- | --------- | ----------------------------------------------------------------- |
| `callingContractAdmin` | `address` | The address to be assigned as the admin for the calling contract. |

### setRulesEngineAddress

Sets the address of the Rules Engine contract.

*This function should be overridden in inheriting contracts to implement role-based access control.*

```solidity
function setRulesEngineAddress(address rulesEngine) public virtual;
```

**Parameters**

| Name          | Type      | Description                               |
| ------------- | --------- | ----------------------------------------- |
| `rulesEngine` | `address` | The address of the Rules Engine contract. |

### \_invokeRulesEngine

Invokes the Rules Engine to evaluate policies.

*This function calls the `checkPolicies` function of the Rules Engine.
The `encoded` parameter must be properly encoded using `abi.encodeWithSelector`.
Example: `bytes memory encoded = abi.encodeWithSelector(msg.sig, to, value, msg.sender);`*

```solidity
function _invokeRulesEngine(bytes memory _encoded) internal returns (uint256 _retval);
```

**Parameters**

| Name       | Type    | Description                                        |
| ---------- | ------- | -------------------------------------------------- |
| `_encoded` | `bytes` | The encoded data to be passed to the Rules Engine. |

**Returns**

| Name      | Type      | Description                                                                               |
| --------- | --------- | ----------------------------------------------------------------------------------------- |
| `_retval` | `uint256` | The return value from the Rules Engine, representing the result of the policy evaluation. |
