> For the complete documentation index, see [llms.txt](https://docs.theselfrule.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.theselfrule.org/abstract/phytgital-services/default-phygital-resolution/off-chain-data-fetching.md).

# Off-Chain Data Fetching

### Overview of Off-Chain Data Fetching with PAL Using EIP-3668 (CCIP-read)

The PAL protocol utilizes the EIP-3668 standard, known as CCIP-read, for off-chain data retrieval. For a detailed understanding, reading the standard is encouraged, but below is the tailored process for PAL:

### Process Steps

**Initial Request**

1. **Request Resolution**: A user initiates chip resolution via an EIP-3668 enabled client by providing the chipId.

**Processing**

1. **Pass ChipId**: The client sends the chipId to `resolveChipId` on the ChipRegistry.
2. **Handle Unclaimed Chips**: If the chip is unclaimed, an `OffChainLookup` error is triggered, which returns:

| Field             | Description                                          |
| ----------------- | ---------------------------------------------------- |
| Array of Gateways | An array of gateways to consult for validation data. |
| Parameters        | Parameters for calling the gateway.                  |
| Callback Function | A callback function on the smart contract.           |

**Data Retrieval and Validation**

1. **Gateway Query**: The client queries one or more gateways from the array using the provided parameters.
2. **Data Return**: Gateways return all necessary data encoded in bytes to the client (details in Appendix), which validates and uses this data to determine the correct Service Records.

**Finalization and User Interaction**

1. **Callback Execution**: The client executes the callback function (`resolveUnclaimedChip`) and receives an array of Service Records.
2. **Service Redirection**: The client then either redirects to a service or offers the user a choice of services.

This flow outlines the general procedure for fetching off-chain data depending on the chip's state within PAL.
