Skip to main content
Version: v5.7.0

opschain context use

Included from Basic tier

opschain context use <name>

Switch the active context to a defined one and persist the choice to $OPSCHAIN_HOME/contexts.json. The reserved name local clears the active context, returning to local mode:

opschain context use production
Switched to context production

opschain context use local
Switched to context local

-q suppresses the confirmation line. Switching does not touch stored credentials — the token recorded by opschain login for that server is picked up again as soon as the context is active. Note that --server and OPSCHAIN_SERVER still outrank the active context on any later command, and --local outranks everything.

An undefined name errors with context "<name>" is not defined — the full message names the opschain login invocation that both logs in and records the context (exit 1).

Exit codes: 0 on success, 1 for an undefined name or a contexts file that cannot be read or written, 2 for a missing argument.

See also​

  • opschain docs cli/context-list — what can be switched to.
  • opschain docs cli/login — define a context.