Skip to content

Network

View as Markdown

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

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

Terminal window
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:

Terminal window
thru network add local --url http://localhost:8899

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

Terminal window
thru network set-default $NAME

NAME · string · required

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

Example:

Terminal window
thru network set-default mainnet

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

Terminal window
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:

Terminal window
thru network set local --url http://localhost:9000

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

Terminal window
thru network list

Example:

Terminal window
thru network list

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

Terminal window
thru network rm $NAME

NAME · string · required

Name of the network profile to remove.

Example:

Terminal window
thru network rm local

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

Terminal window
# Use a specific saved profile
thru --network mainnet getversion
# Use an arbitrary URL
thru --url http://localhost:8899 getversion
  1. Add your network profiles

    Terminal window
    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

    Terminal window
    thru network set-default local
  3. Run commands against the default

    Terminal window
    thru getversion
    thru getbalance
  4. Switch networks when needed

    Terminal window
    thru --network mainnet getbalance