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

# createForeignCall

> **createForeignCall**(`config`, `rulesEngineForeignCallContract`, `rulesEngineComponentContract`, `rulesEnginePolicyContract`, `policyId`, `fcSyntax`): `Promise`\<`number`>

Creates a foreign call in the rules engine component contract.

## Parameters

| Parameter                                | Type                                  | Description                                                            |
| ---------------------------------------- | ------------------------------------- | ---------------------------------------------------------------------- |
| `config`                                 | `Config`                              | The configuration object containing network and wallet information.    |
| `rulesEngineForeignCallContract`         | `object`                              | The contract instance for interacting with the rules engine component. |
| `rulesEngineForeignCallContract.abi`     | (`object` \| `object` \| `object`)\[] | -                                                                      |
| `rulesEngineForeignCallContract.address` | \`0x\$\{string}\`                     | -                                                                      |
| `rulesEngineComponentContract`           | `object`                              | -                                                                      |
| `rulesEngineComponentContract.abi`       | (`object` \| `object` \| `object`)\[] | -                                                                      |
| `rulesEngineComponentContract.address`   | \`0x\$\{string}\`                     | -                                                                      |
| `rulesEnginePolicyContract`              | `object`                              | -                                                                      |
| `rulesEnginePolicyContract.abi`          | (`object` \| `object`)\[]             | -                                                                      |
| `rulesEnginePolicyContract.address`      | \`0x\$\{string}\`                     | -                                                                      |
| `policyId`                               | `number`                              | The ID of the policy to associate with the foreign call.               |
| `fcSyntax`                               | `string`                              | A JSON string representing the foreign call definition.                |

## Returns

`Promise`\<`number`>

A promise that resolves to the foreign call index. Returns `-1` if the operation fails.

## Remarks

* The function retries the contract interaction in case of failure, with a delay of 1 second between attempts.
* The `simulateContract` function is used to simulate the contract interaction before writing to the blockchain.
* The `writeContract` function is used to execute the contract interaction on the blockchain.
* The function returns the `foreignCallIndex` for an updated foreign call or the result of the newly created foreign call.

## Throws

Will throw an error if the JSON parsing of `fcSyntax` fails.

## Defined in

[src/modules/foreign-calls.ts:72](https://github.com/forte-service-company-ltd/forte-rules-engine-sdk/blob/5aad4d7c3c8cc91280e4449c17ac8ea31219fbed/src/modules/foreign-calls.ts#L72)
