> ## 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.

# createCallingFunction

> **createCallingFunction**(`config`, `rulesEngineComponentContract`, `policyId`, `callingFunction`, `encodedValues`): `Promise`\<`number`>

Creates a Calling Function in the rules engine component contract.

This function parses the provided calling function, maps its arguments to their respective
types, and interacts with the smart contract to create the calling function. If the contract
interaction fails, it retries with a delay until successful.

## Parameters

| Parameter                              | Type                                  | Description                                                                                        |
| -------------------------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `config`                               | `Config`                              | The configuration object containing network and wallet information.                                |
| `rulesEngineComponentContract`         | `object`                              | The contract instance containing the address and ABI                                               |
| `rulesEngineComponentContract.abi`     | (`object` \| `object` \| `object`)\[] | -                                                                                                  |
| `rulesEngineComponentContract.address` | \`0x\$\{string}\`                     | -                                                                                                  |
| `policyId`                             | `number`                              | The ID of the policy for which the calling function is being created.                              |
| `callingFunction`                      | `string`                              | The calling function string to be parsed and added to the contract. of the rules engine component. |
| `encodedValues`                        | `string`                              | The encoded values string for the calling function.                                                |

## Returns

`Promise`\<`number`>

A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.

## Throws

Will retry indefinitely on contract interaction failure, with a delay between attempts.

## Defined in

[src/modules/calling-functions.ts:59](https://github.com/forte-service-company-ltd/forte-rules-engine-sdk/blob/5aad4d7c3c8cc91280e4449c17ac8ea31219fbed/src/modules/calling-functions.ts#L59)
