Network
The thru network command manages named network profiles, letting you configure and switch between different RPC endpoints without editing config files manually.
Prerequisites
Section titled “Prerequisites”Command Overview
Section titled “Command Overview”Add Network
Section titled “Add Network”Create a new named network profile with an RPC endpoint URL and optional authorization token.
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:
thru network add local --url http://localhost:8899thru network add mainnet --url https://rpc.thru.dev --auth-token mytoken123Set Default
Section titled “Set Default”Set which network profile the CLI uses when no --network or --url flag is provided.
thru network set-default $NAMENAME · string · required
Name of an existing network profile to use as the default.
Example:
thru network set-default mainnetUpdate Network
Section titled “Update Network”Update the URL or authorization token on an existing network profile.
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:
thru network set local --url http://localhost:9000thru network set mainnet --auth-token newtoken456thru network set mainnet --auth-token ""List Networks
Section titled “List Networks”Display all configured network profiles, including which one is set as the default.
thru network listExample:
thru network listthru --json network listRemove Network
Section titled “Remove Network”Delete a network profile from the configuration. If the removed profile was the default, the default is cleared.
thru network rm $NAMENAME · string · required
Name of the network profile to remove.
Example:
thru network rm localPer-Command Overrides
Section titled “Per-Command Overrides”Any CLI command accepts these flags to override the network for a single invocation, without changing your saved profiles:
# Use a specific saved profilethru --network mainnet getversion
# Use an arbitrary URLthru --url http://localhost:8899 getversionCommon Workflow
Section titled “Common Workflow”-
Add your network profiles
Terminal window thru network add local --url http://localhost:8899thru network add testnet --url https://testnet.thru.devthru network add mainnet --url https://rpc.thru.dev --auth-token mytoken -
Set your default
Terminal window thru network set-default local -
Run commands against the default
Terminal window thru getversionthru getbalance -
Switch networks when needed
Terminal window thru --network mainnet getbalance