# Default Chains and Tokens

## Squid Widget v2.0: Default Chains and Tokens Configuration Guide

This guide explains how to configure default chains and tokens for the Squid Widget v2.0. Note that there have been significant changes from previous versions.

### Finding Chain IDs and Token Addresses

Before configuring, you'll need to know the correct chain IDs and token addresses:

* **Chain IDs**:
  * Use Squid's [API playground](https://api.squidrouter.com/docs)
  * Or access the [chains endpoint](https://api.squidrouter.com/v1/chains) directly
* **Token Addresses**:
  * Use the [tokens endpoint](https://api.squidrouter.com/v1/tokens)
  * Or filter by chain in the [API playground](https://api.squidrouter.com/docs#/tokens/get_v1_tokens) (input the chain ID in the `/tokens` reference)

### Configuring Initial Assets (Chains and Tokens)

In Squid v2.0, `initialFromChainId` and `initialToChainId` have been replaced by the `initialAssets` object:

```jsx
<SquidWidget
  config={{
    initialAssets: {
      from: {
        address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // Token address
        chainId: "1", // Ethereum
      },
      to: {
        address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // Token address
        chainId: "42161", // Arbitrum
      },
    },
    // ... other configuration options
  }}
/>
```

### Configuring Default Tokens Per Chain

The `defaultTokens` property has been renamed to `defaultTokensPerChain`:

```jsx
<SquidWidget
  config={{
    defaultTokensPerChain: [
      {
        address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH on Ethereum
        chainId: "1",
      },
      {
        address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH on Arbitrum
        chainId: "42161",
      },
    ],
    // ... other configuration options
  }}
/>
```

### Visible Tokens And Chains

Limit the tokens and chains visible on your widget by applying `availableChains` and `availableTokens` on the `source` or `destination`.

```jsx
<SquidWidget
  config={{
    "availableChains": {
      "destination": [
        "56",
        "8453",
        "42161"
      ]
    },
    "availableTokens": {
      "destination": {
        "56": [
          "0xf3527ef8de265eaa3716fb312c12847bfba66cef",
          "0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
        ],
        "8453": [
          "0xf3527ef8de265eaa3716fb312c12847bfba66cef",
          "0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
        ],
        "42161": [
          "0xf3527ef8de265eaa3716fb312c12847bfba66cef",
          "0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
        ]
      }
    }
   // ... other configuration options
}}
/>
```

### Removed Features

Please note that the following features have been removed in Squid v2.0:

* `favTokens`: Favorite tokens are no longer supported.
* Several other properties including `companyName`, `titles`, `enableExpress`, `mainLogoUrl`, and others. Refer to the migration guide for a full list.

### Full Example

Here's a complete example combining these configurations:

```jsx
import { SquidWidget } from '@0xsquid/widget';

function App() {
  return (
    <SquidWidget
      config={{
        integratorId: "<your-integrator-id>",
        apiUrl: "https://apiplus.squidrouter.com",
        initialAssets: {
          from: {
            address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            chainId: "1",
          },
          to: {
            address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            chainId: "42161",
          },
        },
        defaultTokensPerChain: [
          {
            address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            chainId: "1",
          },
          {
            address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
            chainId: "42161",
          },
        ],
        // ... other configuration options
      }}
    />
  );
}

export default App;
```
