# Contract Integration

If the policyholder is a smart contract, the contract must implement certain functions to interact with an insurance contract for the purposes of issuing, redeeming, and submitting claims for policies.

### onPolicyIssued

```solidity
function onPolicyIssued(address operator, address from, string policyId) external returns (bytes4)
```

This function will called by the insurance contract (policy manager facet) when the policy is issued and the caller is contract.

*The selector can be obtained in Solidity with `IInsuranceIssuer.onPolicyIssued.selector`.*

| Name     | Type    | Description           |
| -------- | ------- | --------------------- |
| operator | address | The operator address. |
| from     | address | The from address.     |
| policyId | string  | The policy id.        |

| Name | Type   | Description                                            |
| ---- | ------ | ------------------------------------------------------ |
| \[0] | bytes4 | The bytes4 of the selector of onPolicyIssued function. |

### onPolicyRedeemed

```solidity
function onPolicyRedeemed(address operator, address from, string policyId) external returns (bytes4)
```

This function will called by the insurance contract (policy manager facet) when the policy is redeemed and the caller is contract.

*The selector can be obtained in Solidity with `IInsuranceIssuer.onPolicyRedeemed.selector`.*

| Name     | Type    | Description           |
| -------- | ------- | --------------------- |
| operator | address | The operator address. |
| from     | address | The caller address.   |
| policyId | string  | The policy id.        |

| Name | Type   | Description                                              |
| ---- | ------ | -------------------------------------------------------- |
| \[0] | bytes4 | The bytes4 of the selector of onPolicyRedeemed function. |

### onClaimSubmitted

```solidity
function onClaimSubmitted(address operator, address from, string policyId) external returns (bytes4)
```

This function will called by the insurance contract (claim manager facet) when the policy is submitted and the caller is contract.

*The selector can be obtained in Solidity with `IInsuranceIssuer.onClaimSubmitted.selector`.*

| Name     | Type    | Description           |
| -------- | ------- | --------------------- |
| operator | address | The operator address. |
| from     | address | The caller address.   |
| policyId | string  | The policy id.        |

| Name | Type   | Description                                              |
| ---- | ------ | -------------------------------------------------------- |
| \[0] | bytes4 | The bytes4 of the selector of onClaimSubmitted function. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.covestlabs.com/covest-insaas-protocol/insaas-smart-contracts/contract-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
