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

# Running OPinit Bots

Weave provides a streamlined way to configure and run
[OPinit Bots](/home/core-concepts/interwoven-stack/opinit-framework/introduction)
(executor and challenger) for your rollup.

## Setting Up

```bash theme={null}
weave opinit init
```

This command will guide you through selecting the bot type (executor or
challenger), configuring bot keys if needed, and setting up the bot's
configuration.

You can also specify the bot type directly:

<Tabs>
  <Tab title="Executor">
    ```bash theme={null}
    weave opinit init executor
    ```

    To set up Executor from the [config file](https://github.com/initia-labs/opinit-bots/blob/main/executor/README.md) without going through the interactive setup process, use the `--with-config` flag together with either `--generate-key-file` or `--key-file` flags.

    For example, to let Weave generate Executor's keys for you, use the following command:

    ```bash theme={null}
    weave opinit init executor --with-config <path-to-config-file> --generate-key-file
    ```

    To provide your own keys, use the following command:

    ```bash theme={null}
    weave opinit init executor --with-config <path-to-config-file> --key-file <path-to-key-file>
    ```

    **Available Flags**

    <ParamField path="--opinit-dir" type="string" default="~/.opinit">
      The directory to store OPinit bots data and configuration files
    </ParamField>

    <ParamField path="--minitia-dir" type="string" default="~/.minitia">
      Path to the rollup directory that contains the rollup's artifacts. This is
      useful when you are setting up OPinit bots for a rollup that you have just
      launched, as it can use the artifacts from the rollup to setup the bots.
    </ParamField>

    <ParamField path="--with-config" type="string">
      Path to the rollup [config file](https://github.com/initia-labs/opinit-bots/blob/main/executor/README.md). Use this flag to set up Executor from a config file without going through the interactive setup process.
    </ParamField>

    <ParamField path="--generate-key-file" type="boolean" default="false">
      Whether to generate Executor's keys during the setup process. Can only be used when `--with-config` flag is provided. Conflicts with `--key-file` flag.
    </ParamField>

    <ParamField path="--key-file" type="string">
      Path to the Executor's keys file. Can only be used when `--with-config` flag is provided. Conflicts with `--generate-key-file` flag.
    </ParamField>
  </Tab>

  <Tab title="Challenger">
    ```bash theme={null}
    weave opinit init challenger
    ```

    To set up Challenger from the [config file](https://github.com/initia-labs/opinit-bots/blob/main/challenger/README.md) without going through the interactive setup process, use the `--with-config` flag together with either `--generate-key-file` or `--key-file` flags.

    For example, to let Weave generate Challenger's keys for you, use the following command:

    ```bash theme={null}
    weave opinit init challenger --with-config <path-to-config-file> --generate-key-file
    ```

    To provide your own OPinit bot keys, use the following command:

    ```bash theme={null}
    weave opinit init challenger --with-config <path-to-config-file> --key-file <path-to-key-file>
    ```

    **Available Flags**

    <ParamField path="--opinit-dir" type="string" default="~/.opinit">
      The directory to store OPinit bots data and configuration files
    </ParamField>

    <ParamField path="--minitia-dir" type="string" default="~/.minitia">
      Path to the rollup directory that contains the rollup's artifacts. This is
      useful when you are setting up OPinit bots for a rollup that you have just
      launched, as it can use the artifacts from the rollup to setup the bots.
    </ParamField>

    <ParamField path="--with-config" type="string">
      Path to the rollup [config file](https://github.com/initia-labs/opinit-bots/blob/main/challenger/README.md). Use this flag to set up Challenger from a config file without going through the interactive setup process.
    </ParamField>

    <ParamField path="--generate-key-file" type="boolean" default="false">
      Whether to generate Challenger's keys during the setup process. Can only be used when `--with-config` flag is provided. Conflicts with `--key-file` flag.
    </ParamField>

    <ParamField path="--key-file" type="string">
      Path to the Challenger's keys file. Can only be used when `--with-config` flag is provided. Conflicts with `--generate-key-file` flag.
    </ParamField>
  </Tab>
</Tabs>

## Managing Keys

To modify bot keys, use the following command to either generate new keys or
restore existing ones:

```bash theme={null}
weave opinit setup-keys
```

**Available Flags**

<ParamField path="--opinit-dir" type="string" default="~/.opinit">
  The directory to store OPinit bots data and configuration files
</ParamField>

<ParamField path="--minitia-dir" type="string" default="~/.minitia">
  Path to the rollup directory that contains the rollup's artifacts. This is
  useful when you are setting up OPinit bots for a rollup that you have just
  launched, as it can use the artifacts from the rollup to setup the bots.
</ParamField>

<Warning>
  For the Executor bot to work, set up the Bridge Executor, Output Submitter, and Batch Submitter keys.

  For the Challenger bot to work, set up the Challenger key.

  For rollups with built-in oracle enabled, set up the Oracle Executor key.
</Warning>

## Resetting OPinit Bots

<Tabs>
  <Tab title="Executor">
    Reset Executor's database. This will clear all the data stored in the Executor's database (the configuration files are not affected).

    ```bash theme={null}
    weave opinit reset executor
    ```
  </Tab>

  <Tab title="Challenger">
    Reset Challenger's database. This will clear all the data stored in the Challenger's database (the configuration files are not affected).

    ```bash theme={null}
    weave opinit reset challenger
    ```
  </Tab>
</Tabs>

## Running OPinit Bots

<Tabs>
  <Tab title="Executor">
    <Tabs>
      <Tab title="Start">
        `bash weave opinit start executor ` **Available Flags**

        <ParamField path="--detach, -d" type="boolean" default="false">
          Whether to run the Executor in the background.
        </ParamField>
      </Tab>

      <Tab title="Stop">`bash weave opinit stop executor `</Tab>
      <Tab title="Restart">`bash weave opinit restart executor `</Tab>

      <Tab title="View logs">
        `bash weave opinit log executor ` **Available Flags**

        <ParamField path="-n" type="number" default="100">
          The number of lines to display from the end of the Executor's logs.
        </ParamField>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Challenger">
    <Tabs>
      <Tab title="Start">
        `bash weave opinit start challenger ` **Available Flags**

        <ParamField path="--detach, -d" type="boolean" default="false">
          Whether to run the node in the background.
        </ParamField>
      </Tab>

      <Tab title="Stop">`bash weave opinit stop challenger `</Tab>
      <Tab title="Restart">`bash weave opinit restart challenger `</Tab>

      <Tab title="View logs">
        `bash weave opinit log challenger ` **Available Flags**

        <ParamField path="-n" type="number" default="100">
          The number of lines to display from the end of the logs.
        </ParamField>
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

## Help

To see all the available commands:

```bash theme={null}
weave opinit --help
```
