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

# Module: chain

## Table of contents

### Chain Functions

* [toEnvironmentName](utils_chain.md#toenvironmentname)
* [getChainId](utils_chain.md#getchainid)
* [getChainName](utils_chain.md#getchainname)
* [createChainConfig](utils_chain.md#createchainconfig)

## Chain Functions

### toEnvironmentName

▸ **toEnvironmentName**(`chainNameOrId`): [`SpaceportChainType`](.././index#spaceportchaintype)

Helper function to safely convert a chain name from utils/chain to a valid environment name

#### Parameters

| Name            | Type                 |
| :-------------- | :------------------- |
| `chainNameOrId` | `string` \| `number` |

#### Returns

[`SpaceportChainType`](.././index#spaceportchaintype)

### getChainId

▸ **getChainId**(`chain`): `number`

Get the numeric chain ID from a SpaceportChainType name

#### Parameters

| Name    | Type                                                              | Description |
| :------ | :---------------------------------------------------------------- | :---------- |
| `chain` | `number` \| [`SpaceportChainType`](.././index#spaceportchaintype) | Chain name  |

#### Returns

`number`

Chain ID as a number

### getChainName

▸ **getChainName**(`chainId`): `string`

Get the chain name from a chain ID

#### Parameters

| Name      | Type     | Description |
| :-------- | :------- | :---------- |
| `chainId` | `number` | Chain ID    |

#### Returns

`string`

Chain name

### createChainConfig

▸ **createChainConfig**(`chainName`): `Object`

Create a chain configuration for the given environment

#### Parameters

| Name        | Type                                                  | Description |
| :---------- | :---------------------------------------------------- | :---------- |
| `chainName` | [`SpaceportChainType`](.././index#spaceportchaintype) | Chain name  |

#### Returns

`Object`

Chain configuration

| Name                      | Type                                                               |
| :------------------------ | :----------------------------------------------------------------- |
| `id`                      | `number`                                                           |
| `name`                    | `string`                                                           |
| `network`                 | `string`                                                           |
| `nativeCurrency`          | \{ `name`: `string` ; `symbol`: `string` ; `decimals`: `number`  } |
| `nativeCurrency.name`     | `string`                                                           |
| `nativeCurrency.symbol`   | `string`                                                           |
| `nativeCurrency.decimals` | `number`                                                           |
| `rpcUrls`                 | \{ `default`: \{ `http`: `string`\[]  }  }                         |
| `rpcUrls.default`         | \{ `http`: `string`\[]  }                                          |
| `rpcUrls.default.http`    | `string`\[]                                                        |
