---
title: Network
description: Manage network profiles for connecting to different Thru RPC endpoints
source_url:
  html: https://thru.org/docs/cli-reference/network-commands/
  md: https://thru.org/docs/cli-reference/network-commands.md
---

# Network

The `thru network` command manages named network profiles, letting you configure and switch between different RPC endpoints without editing config files manually.

> **Tip:**
>
> Network profiles are stored in your CLI configuration at `~/.thru/cli/config.yaml`. You can also override the RPC URL for any single command with the `--url` flag.

## Prerequisites

- [CLI setup](https://thru.org/docs/program-development/setting-up-thru-devkit.md)

## Command Overview

- [Add](#add-network): Create a new named network profile
- [Set Default](#set-default): Choose which profile to use by default
- [Update](#update-network): Modify an existing network profile
- [List](#list-networks): Show all configured profiles
- [Remove](#remove-network): Delete a network profile

## Add Network

Create a new named network profile with an RPC endpoint URL and optional authorization token.

```bash
thru network add $NAME --url $URL [OPTIONS]
```

**`NAME` · *string* · **required****

Profile name (case-insensitive). Used to reference this network in other commands.

***string* · **required****

RPC endpoint URL for this network (e.g., `http://localhost:8899` or `https://rpc.thru.dev`).

***string***

Optional authorization token included with RPC requests to this endpoint.

**Example:**

**Local development:**

```bash
thru network add local --url http://localhost:8899
```

**Remote with auth:**

```bash
thru network add mainnet --url https://rpc.thru.dev --auth-token mytoken123
```

> **Caution:**
>
> If a profile with the same name already exists, the command fails. Use [`network set`](#update-network) to modify an existing profile.

## Set Default

Set which network profile the CLI uses when no `--network` or `--url` flag is provided.

```bash
thru network set-default $NAME
```

**`NAME` · *string* · **required****

Name of an existing network profile to use as the default.

**Example:**

```bash
thru network set-default mainnet
```

> **Note:**
>
> The default network is stored in your config file and persists across CLI sessions. You can always override it per-command with `—network <name>` or `—url <url>`.

## Update Network

Update the URL or authorization token on an existing network profile.

```bash
thru network set $NAME [OPTIONS]
```

**`NAME` · *string* · **required****

Name of the network profile to update.

***string***

New RPC endpoint URL.

***string***

New authorization token. Pass an empty string (`""`) to clear the token.

**Example:**

**Change URL:**

```bash
thru network set local --url http://localhost:9000
```

**Update auth token:**

```bash
thru network set mainnet --auth-token newtoken456
```

**Clear auth token:**

```bash
thru network set mainnet --auth-token ""
```

## List Networks

Display all configured network profiles, including which one is set as the default.

```bash
thru network list
```

**Example:**

**Standard output:**

```bash
thru network list
```

**JSON output:**

```bash
thru --json network list
```

## Remove Network

Delete a network profile from the configuration. If the removed profile was the default, the default is cleared.

```bash
thru network rm $NAME
```

**`NAME` · *string* · **required****

Name of the network profile to remove.

**Example:**

```bash
thru network rm local
```

> **Caution:**
>
> If the removed profile is currently the default, the default is cleared and you will need to set a new default or provide `--network`/`--url` on subsequent commands.

## Per-Command Overrides

Any CLI command accepts these flags to override the network for a single invocation, without changing your saved profiles:

```bash
# Use a specific saved profile
thru --network mainnet getversion

# Use an arbitrary URL
thru --url http://localhost:8899 getversion
```

## Common Workflow

1. **Add your network profiles**

   ```bash
     thru network add local --url http://localhost:8899
     thru network add testnet --url https://testnet.thru.dev
     thru network add mainnet --url https://rpc.thru.dev --auth-token mytoken
   ```

2. **Set your default**

   ```bash
     thru network set-default local
   ```

3. **Run commands against the default**

   ```bash
     thru getversion
     thru getbalance
   ```

4. **Switch networks when needed**

   ```bash
     thru --network mainnet getbalance
   ```
