# Register v0.3.1 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.3.1/register

> For the complete documentation index, see [llms.txt](/llms.txt).

> **NOTE: Integrate Chainlink Local into your project**
>
> ### npm
>
> If you use [NPM](https://www.npmjs.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> npm install @chainlink/local@0.3.1
> ```
>
> ### yarn
>
> If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> yarn add @chainlink/local@0.3.1
> ```
>
> ### foundry
>
> If you use [Foundry](https://book.getfoundry.sh/):
>
> ```shell
> forge install smartcontractkit/chainlink-local@v0.3.1
> ```
>
> and then set remappings to: `@chainlink/local/=lib/chainlink-local/` in either `remappings.txt` or `foundry.toml` file
>
> ### RemixIDE
>
> Import the `CCIPLocalSimulator` contract from the `@chainlink/local` package:
>
> ```solidity
> import {CCIPLocalSimulator} from "@chainlink/local@0.3.1/src/ccip/CCIPLocalSimulator.sol";
> ```

## Register

A contract that stores and retrieves network details for various chains.

[`Register`](https://github.com/smartcontractkit/chainlink-local/blob/v0.3.1/src/ccip/Register.sol)

> **NOTE**
>
> This contract maintains a registry of network-specific details including chain selectors, router addresses, and token
> addresses for various supported networks. Built-in network details live in the generated data shards of
> `RegisterData.sol`, which the simulator places with `vm.etch`, instead of being written to storage in the constructor:
> storing \~150 chains cost \~24M gas, which made `CCIPLocalSimulatorFork` too expensive to deploy on 30M-gas-limit forks.
> Sharding keeps every generated contract runtime under the EIP-170 limit. `setNetworkDetails` overrides are stored.

## Structs

### NetworkDetails

Contains configuration details for a specific network/chain.

| Field                            | Type      | Description                                  |
| -------------------------------- | --------- | -------------------------------------------- |
| chainSelector                    | `uint64`  | Unique identifier for the chain in CCIP      |
| routerAddress                    | `address` | Address of the CCIP Router contract          |
| linkAddress                      | `address` | Address of the LINK token contract           |
| wrappedNativeAddress             | `address` | Address of the wrapped native token contract |
| ccipBnMAddress                   | `address` | Address of the CCIP BnM token contract       |
| ccipLnMAddress                   | `address` | Address of the CCIP LnM token contract       |
| rmnProxyAddress                  | `address` | Address of the RMN proxy contract            |
| registryModuleOwnerCustomAddress | `address` | Address of the registry module owner         |
| tokenAdminRegistryAddress        | `address` | Address of the token admin registry contract |

## Variables

### s\_networkDetails

```solidity
mapping(uint256 chainId => NetworkDetails) internal s_networkDetails
```

> **NOTE**
>
> Internal mapping that stores network details set with `setNetworkDetails`, overriding the built-in ones.

### s\_isOverridden

```solidity
mapping(uint256 chainId => bool isOverridden) internal s_isOverridden
```

> **NOTE**
>
> Internal mapping that records whether `setNetworkDetails` was called for a chain ID.

## Functions

### constructor

Initializes the contract.

```solidity
constructor()
```

> **NOTE**
>
> Built-in network details are not stored here; they live in the generated `RegisterData` shards. A bare `new
>   Register()` only serves `setNetworkDetails` overrides.

### getNetworkDetails

Retrieves network details for a given chain ID.

```solidity
function getNetworkDetails(uint256 chainId) external view returns (NetworkDetails memory networkDetails)
```

> **NOTE**
>
> Returns the `setNetworkDetails` override for the chain ID when one was set, otherwise the built-in details from the
> data shards. An unknown chain returns an all-zero struct.

#### Parameters

| Parameter | Type      | Description                                |
| --------- | --------- | ------------------------------------------ |
| chainId   | `uint256` | The ID of the chain to get the details for |

#### Returns

| Parameter      | Type             | Description                                    |
| -------------- | ---------------- | ---------------------------------------------- |
| networkDetails | `NetworkDetails` | The network details for the specified chain ID |

### setNetworkDetails

Sets the network details for a given chain ID.

```solidity
function setNetworkDetails(uint256 chainId, NetworkDetails memory networkDetails) external
```

> **NOTE**
>
> Used to add or update network details when they are not present or have changed from default values.
> `getNetworkDetails` returns an all-zero struct for a chain ID that is not in `Register`.

#### Parameters

| Parameter      | Type             | Description                                           |
| -------------- | ---------------- | ----------------------------------------------------- |
| chainId        | `uint256`        | The ID of the chain to set the details for            |
| networkDetails | `NetworkDetails` | The network details to set for the specified chain ID |

### shardAddress

Returns the deterministic address of built-in data shard `index`.

```solidity
function shardAddress(uint256 index) public view returns (address)
```

> **NOTE**
>
> The simulator places each generated `RegisterDataN` shard at this address with `vm.etch`.

#### Parameters

| Parameter | Type      | Description                               |
| --------- | --------- | ----------------------------------------- |
| index     | `uint256` | The shard index (0 to `_SHARD_COUNT - 1`) |