# Setup a Multichain Service

### Overview

This guide walks you through configuring your AVS components for proper Multichain support, natively supported by the Othentic Stack, by modifying the following components:

1. Environment Variables
2. Specifying Target Chain on Task Submission

### Prerequisites

1. [Othentic CLI installed](https://docs.othentic.xyz/main/welcome/getting-started/install-othentic-cli)
2. [AVS deployed on all required networks](https://docs.othentic.xyz/main/user-guide/deploy-avs#id-2.-deploy-an-avs-on-multiple-l2s)

For additional reference, [see this Github repo](https://github.com/Othentic-Labs/multi-l2-price-oracle-avs-example) for boilerplate code.

***

## Environment Variables

The Othentic CLI natively supports multi-L2 configurations for L2-specific environment variables.

{% stepper %}
{% step %}

### Set L2\_CHAIN

Specify the names of all L2 chains, separated by commas. You can use standard chain names and specify specific environments as detailed [here](https://docs.othentic.xyz/main/reference/supported-networks), or use numerical `ChainId` s.

{% code title=".env" %}

```sh
L2_CHAIN=<chain1>,<chain2>
```

{% endcode %}

#### Example

{% tabs %}
{% tab title="Human-Readable Names" %}

```
L2_CHAIN=amoy,base-sepolia
```

{% endtab %}

{% tab title="Numerical ChainIds" %}

```
L2_CHAIN=80002,84532
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Set L2\_RPC

Specify the RPC endpoints for all L2 chains, separated by commas:

```
L2_RPC=<chain_id_1>@<rpc_endpoint_1>,<chain_id_2>@<rpc_endpoint_2>
```

#### Example

```
L2_RPC=80002@https://rpc-amoy.example.com,84532@https://rpc-base-sepolia.example.com
```

{% endstep %}

{% step %}

### Set ATTESTATION\_CENTER\_ADDRESS

Specify all the AttestationCenter contracts for all L2 chains, separated by commas:

```
ATTESTATION_CENTER_ADDRESS=<chain_id_1>@<attestation_center_address_1>,<chain_id_2>@<attestation_center_address_2>
```

#### Example

```
ATTESTATION_CENTER_ADDRESS=80002@0x1C4E893Dcc1eAFbf59f8a75e0AbB49Cd841bCECc,84532@0x022AFc410f1190F9a9642AAB990d0668268327a6
```

{% endstep %}

{% step %}

### Send tasks to the corresponding L2

In your [Execution Service](https://docs.othentic.xyz/main/learn/core-concepts/execution-service) implementation, make sure to specify the correct [`targetChainId`](https://docs.othentic.xyz/main/learn/core-concepts/execution-service#task-submission) parameter in the `sendTask` RPC request sent to the AVS network.

{% hint style="success" %}
If `targetChainId` is not specified, the first chain listed in the `.env` file will be used by default.
{% endhint %}

#### Example

```
{
  "jsonrpc": "2.0",
  "method": "sendTask",
  "params": [
    "proof_string",    // <proofOfTask>
    "extra_data",      // <data>
    "1",               // <taskDefinitionId>
    "0xabcd....7890",  // <performerAddress>
    "c35a......62df",  // <signature>
    "bls",             // <signatureType>
    "84532"            // <targetChainId>   <------ Pass target chain ID
  ]
}
```

{% endstep %}
{% endstepper %}
