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

# convertOnChainRuleStructToString

> v0.20.5

> **convertOnChainRuleStructToString**(`functionString`, `encodedValues`, `ruleS`, `ruleM`, `foreignCalls`, `trackers`, `mappings`, `ruleId`): [`RuleJSON`](../../../modules/validation/interfaces/RuleJSON)

Defined in: [src/parsing/reverse-parsing-logic.ts:600](https://github.com/Forte-Service-Company-Ltd/forte-rules-engine-sdk/blob/40cc8388cecd8ee445b00b9df2b681cff8552ece/src/parsing/reverse-parsing-logic.ts#L600)

Convert RuleOnChain + metadata into a \{ data, json } pair.

Builds a human-readable `RuleJSON` and a `RuleData` that includes the id,
by reverse-parsing the condition and effects and resolving placeholders.

## Parameters

| Parameter        | Type                                                                                | Description                                          |
| ---------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `functionString` | `string`                                                                            | Calling function signature for the rule JSON.        |
| `encodedValues`  | `string`                                                                            | Encoded calling-function args used to derive names.  |
| `ruleS`          | [`RuleOnChain`](../../../modules/types/type-aliases/RuleOnChain)                    | RuleOnChain (instructionSet, placeholders, effects). |
| `ruleM`          | [`RuleMetadataStruct`](../../../modules/types/type-aliases/RuleMetadataStruct)      | Rule metadata (name, description).                   |
| `foreignCalls`   | [`ForeignCallOnChain`](../../../modules/types/type-aliases/ForeignCallOnChain)\[]   | Foreign calls referenced by placeholders.            |
| `trackers`       | [`TrackerOnChain`](../../../modules/types/type-aliases/TrackerOnChain)\[]           | Trackers referenced by placeholders.                 |
| `mappings`       | [`hexToFunctionString`](../../../modules/types/type-aliases/hexToFunctionString)\[] | Hex-to-function mappings to resolve signatures.      |
| `ruleId`         | `number`                                                                            | Optional id to include in the returned RuleData.     |

## Returns

[`RuleJSON`](../../../modules/validation/interfaces/RuleJSON)

RuleDataAndJSON: `{ data: RuleData, json: RuleJSON }`.

The function processes the `RuleOnChain` object to:

* Extract placeholder names and append them to `plhArray`.
* Parse and format positive and negative effects into strings.
* Reverse parse the rule's instruction set to generate a condition string.
* Populate the `ruleJSON` object with the processed data.
