# toRecord | @aa-sdk/core

> Overview of the toRecord function from @aa-sdk/core

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

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

```ts
function toRecord<T, K, V>(array, selector, fn): Record<T[K], V>;
```

Defined in: [aa-sdk/core/src/utils/index.ts:177](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/core/src/utils/index.ts#L177)

Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.

## Example

```ts
import { toRecord } from "@aa-sdk/core";
import { sepolia, mainnet } from "viem/chains";

const addressesByChain = toRecord([sepolia, mainnet], "id", () => "0x..."); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
```

## Type Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `T` *extends* \{ \[K in string | number | symbol]: string | number | symbol }
      </td>
    </tr>

    <tr>
      <td>
        `K` *extends* `string` | `number` | `symbol`
      </td>
    </tr>

    <tr>
      <td>
        `V`
      </td>
    </tr>

  </tbody>
</table>

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `array`
      </td>

      <td>
        `T`\[]
      </td>

      <td>
        The array of objects to convert to a record
      </td>
    </tr>

    <tr>
      <td>
        `selector`
      </td>

      <td>
        `K`
      </td>

      <td>
        The key used to select the property that will become the record's key
      </td>
    </tr>

    <tr>
      <td>
        `fn`
      </td>

      <td>
        (`item`) => `V`
      </td>

      <td>
        The function that transforms each item in the array into the record's value
      </td>
    </tr>

  </tbody>
</table>

## Returns

`Record`\<`T`\[`K`], `V`>

The resulting record object