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

# ICRS

# Solidity API

# Contract: ICRS

## External Functions

### registerRoyaltyDue

```solidity theme={null}
function registerRoyaltyDuefunction registerRoyaltyDue(uint256 tokenId, uint256 amountDue, uint256 startDate, uint256 endDate, uint256 royaltyInfoIndex) external
```

Registers or updates the royalty amount due for a specific token and period index.

#### Parameters

| Name               | Description                                            |
| ------------------ | ------------------------------------------------------ |
| `tokenId`          | The ID of the token.                                   |
| `amountDue`        | The amount of royalty due for the period.              |
| `startDate`        | The start date of the royalty period (Unix timestamp). |
| `endDate`          | The end date of the royalty period (Unix timestamp).   |
| `royaltyInfoIndex` | The index for the royalty period (0-based).            |

*Dev:* Can only be called by the VR creator. Creates a new period if index equals current count.

### payRoyalty

```solidity theme={null}
function payRoyaltyfunction payRoyalty(uint256 tokenId, uint256 amountPaid, uint256 periodIndex, address culturaBoundAccount, bytes signature) external
```

Processes an on-chain royalty payment for a specific token and period.

#### Parameters

| Name                  | Description                                                                    |
| --------------------- | ------------------------------------------------------------------------------ |
| `tokenId`             | The ID of the token.                                                           |
| `amountPaid`          | The amount being paid on-chain.                                                |
| `periodIndex`         | The index of the royalty period being paid.                                    |
| `culturaBoundAccount` | The address of the associated Cultura Rights Bound Account.                    |
| `signature`           | Signature required by the CulturaRightsBoundAccount's setPaymentInfo function. |

*Dev:* Can only be called by the VR creator. Interacts with the CulturaRightsBoundAccount.

### reportOffChainPayment

```solidity theme={null}
function reportOffChainPaymentfunction reportOffChainPayment(uint256 tokenId, uint256 periodIndex, uint256 amount, string metadata) external
```

Reports an off-chain payment made for a specific royalty period.

#### Parameters

| Name          | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `tokenId`     | The ID of the VR token.                                     |
| `periodIndex` | The index of the royalty period.                            |
| `amount`      | The amount reported as paid off-chain.                      |
| `metadata`    | Optional metadata about the payment (e.g., transaction ID). |

*Dev:* Can only be called by the VR creator. Sets the payment status to PENDING.

### acceptOffChainPayment

```solidity theme={null}
function acceptOffChainPaymentfunction acceptOffChainPayment(uint256 tokenId, uint256 periodIndex, address culturaBoundAccount, bytes signature) external
```

Accepts a pending off-chain payment report.

#### Parameters

| Name                  | Description                                                 |
| --------------------- | ----------------------------------------------------------- |
| `tokenId`             | The ID of the VR token.                                     |
| `periodIndex`         | The index of the royalty period.                            |
| `culturaBoundAccount` | The address of the associated Cultura Rights Bound Account. |
| `signature`           | The VR owner's EIP712 signature confirming acceptance.      |

*Dev:* Can only be called by the current owner of the VR. Requires EIP712 signature.
Transfers calculated fees from the VR owner to the Cultura Rights Bound Account.

### denyOffChainPayment

```solidity theme={null}
function denyOffChainPaymentfunction denyOffChainPayment(uint256 tokenId, uint256 periodIndex, bytes signature) external
```

Denies a pending off-chain payment report.

#### Parameters

| Name          | Description                                        |
| ------------- | -------------------------------------------------- |
| `tokenId`     | The ID of the VR token.                            |
| `periodIndex` | The index of the royalty period.                   |
| `signature`   | The VR owner's EIP712 signature confirming denial. |

*Dev:* Can only be called by the current owner of the VR. Requires EIP712 signature.

### getFullRoyaltyInfo

```solidity theme={null}
function getFullRoyaltyInfofunction getFullRoyaltyInfo(uint256 tokenId) external view returns (struct ICRS.RoyaltyInfoView[])
```

Retrieves all royalty information views for a specific token.

#### Parameters

| Name      | Description          |
| --------- | -------------------- |
| `tokenId` | The ID of the token. |

#### Return Values

| Description                          |
| ------------------------------------ |
| An array of RoyaltyInfoView structs. |

### getRoyaltyInfoPeriod

```solidity theme={null}
function getRoyaltyInfoPeriodfunction getRoyaltyInfoPeriod(uint256 tokenId, uint256 periodIndex) external view returns (uint256 periodStart, uint256 periodEnd, uint256 amountDue, uint256 amountPaid, uint256[] parentPendingClaims)
```

Retrieves royalty information for a specific token and period index.

#### Parameters

| Name          | Description                      |
| ------------- | -------------------------------- |
| `tokenId`     | The ID of the token.             |
| `periodIndex` | The index of the royalty period. |

#### Return Values

| Description                                            |
| ------------------------------------------------------ |
| The start of the royalty period.                       |
| The end of the royalty period.                         |
| The amount currently due for the period.               |
| The amount already paid for the period.                |
| Empty array (placeholder for signature compatibility). |

### getRoyaltyInfoCount

```solidity theme={null}
function getRoyaltyInfoCountfunction getRoyaltyInfoCount(uint256 tokenId) external view returns (uint256)
```

Retrieves the count of royalty periods registered for a specific token.

#### Parameters

| Name      | Description          |
| --------- | -------------------- |
| `tokenId` | The ID of the token. |

#### Return Values

| Description                    |
| ------------------------------ |
| The number of royalty periods. |

## Events

### `RoyaltyDueRegistered`

```solidity theme={null}
event RoyaltyDueRegisteredevent RoyaltyDueRegistered(uint256 tokenId, address creator, uint256 startDate, uint256 endDate, uint256 amountDue, uint256 periodIndex)
```

### `RoyaltyPaid`

```solidity theme={null}
event RoyaltyPaidevent RoyaltyPaid(uint256 tokenId, address payer, uint256 periodStart, uint256 periodEnd, uint256 amountPaid)
```

### `OffChainPaymentReported`

```solidity theme={null}
event OffChainPaymentReportedevent OffChainPaymentReported(uint256 tokenId, uint256 periodIndex, address reporter, uint256 reportedAmount, string metadata)
```

### `OffChainPaymentAccepted`

```solidity theme={null}
event OffChainPaymentAcceptedevent OffChainPaymentAccepted(uint256 tokenId, uint256 periodIndex, address acceptor, uint256 acceptedAmount, bytes signature)
```

### `OffChainPaymentDenied`

```solidity theme={null}
event OffChainPaymentDeniedevent OffChainPaymentDenied(uint256 tokenId, uint256 periodIndex, address denier, bytes signature)
```
