xian-cli
xian-cli is the command-line control plane for Xian. It has two distinct roles:
- operator workflows such as node setup, network manifests, profile handling, health checks, snapshots, contract bundle validation, and recovery
- client automation through
xian client ..., backed directly byxian-py
If you are writing Python application code, use xian-py. If you are writing shell scripts, CI jobs, or one-off operational commands, use xian-cli.
Installation
Published package:
uv tool install xian-tech-cli
xian --helpThe installed command is xian.
Command Layout
Top-level namespaces:
xian keys ...xian setup ...xian network ...xian node ...xian snapshot ...xian recovery ...xian doctor ...xian contract build-artifacts ...xian contract bundle ...xian client ...
The client namespace is the JSON-first surface for wallet, query, and transaction automation.
Operator Workflows
Use the non-client namespaces when you are shaping manifests and profiles or inspecting a running node.
High-value flows include:
xian setup node ...for a guided local node setup or network joinxian network create ...for local or private network manifestsxian network join ...for generating a local node profile from a canonical network manifestxian node init|start|stop|status|health|endpoints ...for local lifecycle and inspection--validator-selection-modeon local genesis creation when a fresh chain should start inmanual,auto_top_n, orhybridvalidator-selection mode--enable-intentkitand--enable-dex-automationonnetwork create/network joinwhen the node should manage those optional sidecarsxian snapshot restore ...andxian recovery apply ...for restore and recovery workflowsxian contract build-artifacts ...when you need to buildxian_vm_v1deployment artifacts from contract sourcexian contract bundle validate ...when you need to verify hash-pinned contract bundle sources before bootstrap
--dry-run is available on setup node, network create, network join, and recovery-plan application so you can validate inputs and inspect the planned artifact paths before anything is written to disk.
Guided Node Setup
Use xian setup node when you want the CLI to ask for the setup path, network, node name, validator key mode, runtime preset, local validator-selection policy, and start behavior. The same command also accepts advanced runtime flags such as --tx-fee-mode when you need a non-default network policy:
uv run xian setup nodeUse --plan to see the generated lower-level commands and paths:
uv run xian setup node --mode join --network testnet --name validator-1 --planUse --yes for non-interactive setup. Scripted runs do not start the node unless --start is supplied:
uv run xian setup node --mode join --network testnet --name validator-1 \
--preset indexed --key-mode existing \
--validator-key-ref ./keys/validator-1/validator_key_info.json \
--start --yesThe basic preset maps to single-node-dev; the indexed preset maps to single-node-indexed and enables BDS, dashboard, and monitoring. See Installation & Setup for the full wizard reference.
Local Genesis Validator Selection
--validator-selection-mode is a genesis-time setting for fresh local networks. It seeds the validators.selection_mode constructor argument when xian network create renders a local genesis from a contract bundle.
uv run xian setup node --mode local --network local-dev --name validator-1 \
--preset basic --key-mode generate \
--validator-selection-mode hybrid \
--planThe lower-level command exposes the same setting:
uv run xian network create local-dev --chain-id xian-local-1 \
--bootstrap-node validator-1 \
--generate-validator-key \
--validator-selection-mode auto_top_nAllowed values are:
| Value | Use |
|---|---|
manual | validator admission is controlled directly by governance votes |
auto_top_n | eligible registered validators are ranked by bonded stake during rebalancing |
hybrid | governance approves candidate eligibility, then rebalancing ranks approved candidates by bonded stake |
The flag is intentionally not part of network join, and it is rejected with an external --genesis-source. Joined networks already have a canonical genesis. Existing chains change validator policy through validators.update_policy governance rather than through node-local setup flags.
xian-cli is also manifest-aware. When a canonical network manifest includes pinned node images and release provenance, network join carries that posture into the generated local profile. The broader network-manifest metadata, including shielded/privacy operator policy, stays available as first-class manifest data instead of being reduced to ad hoc local flags.
Node Status And Health
Use xian node status <name> for the human-facing runtime summary. It includes the age of the latest observed block so a stalled node is obvious even when the RPC is still technically reachable.
Use xian node health <name> for machine-readable checks. On profiles with BDS enabled it surfaces the effective snapshot bootstrap source plus BDS lag, spool, and database posture.
When To Use xian client
Use xian client ... when you need:
- deterministic CLI output for scripts
- wallet generation in local tooling or CI
- direct balance, nonce, block, or receipt queries
- contract calls and simulations from shell automation
- signed transaction submission without writing Python code
Do not use it as a replacement for application SDKs if you are already writing Python or TypeScript services. In those cases, use xian-py or xian-js.
Connection Defaults
Most xian client commands accept:
--node-url--chain-id
Environment fallbacks:
XIAN_NODE_URLXIAN_CHAIN_ID
Example:
export XIAN_NODE_URL=http://127.0.0.1:26657
export XIAN_CHAIN_ID=xian-local-1After that, you can omit both flags in most commands.
Wallet Commands
Generate a new Ed25519 wallet:
xian client wallet generateExample output:
{
"address": "0f2b...abcd",
"public_key": "0f2b...abcd"
}If you explicitly need the private key in output:
xian client wallet generate --include-private-keyWrite the private key to a file:
xian client wallet generate --private-key-out ./wallet.keyBy default, the private key is not printed.
Query Commands
Get the next nonce for an account:
xian client query nonce <address>Get a balance:
xian client query balance <address>
xian client query balance <address> --contract currencyGet a transaction receipt:
xian client query tx <tx_hash>Get a block:
xian client query block --height 42
xian client query block --block-hash <hash>All query commands emit JSON and are safe to pipe into tools like jq.
Calls And Simulation
Readonly contract call:
xian client call currency balance_of \
--kwargs-json '{"address":"<address>"}'Transaction simulation:
xian client simulate currency transfer \
--kwargs-json '{"amount":1,"to":"<recipient>"}'--kwargs-json must decode to a JSON object.
Transaction Submission
The tx namespace signs and submits transactions.
Available commands:
xian client tx sendxian client tx submit-artifactsxian client tx transfer
Supplying A Private Key
Choose exactly one of:
--private-key--private-key-env--private-key-file
Examples:
xian client tx transfer \
--private-key-file ./wallet.key \
<recipient> 1.25export XIAN_PRIVATE_KEY=<hex>
xian client tx transfer \
--private-key-env XIAN_PRIVATE_KEY \
<recipient> 1.25Using environment variables or files is usually better than passing private keys directly on the command line, because direct flags are easier to expose in shell history and process lists.
Transfer Example
xian client tx transfer \
--node-url http://127.0.0.1:26657 \
--private-key-env XIAN_PRIVATE_KEY \
bob \
1.25Generic Contract Transaction
xian client tx send \
--node-url http://127.0.0.1:26657 \
--private-key-env XIAN_PRIVATE_KEY \
currency \
approve \
--kwargs-json '{"to":"con_dex","amount":7}'Submit Prebuilt Contract Artifacts
xian client tx submit-artifacts \
--node-url http://127.0.0.1:26657 \
--private-key-env XIAN_PRIVATE_KEY \
./artifacts/my-contract.jsonSubmission Controls
Useful submission flags:
--chi--nonce--mode async|checktx|commit--wait-for-tx--timeout-seconds--poll-interval-seconds--chi-margin--min-chi-headroom
These map directly onto the xian-py submission model.
Practical guidance:
- use
--mode checktxfor fast admission confirmation - use
--wait-for-txwhen your script depends on final receipt data - omit
--chiunless you have a reason to override the SDK estimate
Automation Practices
For shell automation:
- set
XIAN_NODE_URLonce per job or script - prefer
--private-key-envor--private-key-file - keep
--kwargs-jsonstable and explicit - parse output with
jq - treat non-zero exit codes as command failure
Example:
tx_hash="$(
xian client tx transfer \
--private-key-env XIAN_PRIVATE_KEY \
bob 5 \
| jq -r '.tx_hash'
)"
xian client query tx "$tx_hash" | jq .Relationship To xian-py
xian-cli does not reimplement blockchain client logic. The xian client ... commands are thin wrappers around xian-py.
Use:
xian-clifor shell scripts, CI, and operator automationxian-pyfor Python applications, services, watchers, and long-running integrations