# galacticad CLI Usage Cheat Sheet

This guide provides essential commands for managing your account and validator on the Galactica Network using the `galacticad` CLI.

## Installation and Setup

For detailed instructions on installing `galacticad`, please refer to our comprehensive [Installation Guide](/galactica-developer-documentation/validator-guide/installation.md).

## Node Setup

For every command, replace `[chain_id]` with the appropriate chain ID for the network you're interacting with. You can also specify custom home directories using the `--home` flag:

```sh
galacticad [command] --chain-id [chain_id] --home [home_directory]
```

### Configure Node Client RPC

Set the RPC node URL for the client to connect to.

```sh
galacticad config node [rpc_node_url]
```

### Initialize Node

Initialize a new node home directory with a moniker and chain ID. This command creates a new node configuration in the specified home directory.

```sh
galacticad init [moniker] --chain-id [chain_id]
```

### Start Node

Start your node to begin syncing with the network.

```sh
galacticad start --chain-id [chain_id]
```

### Show Node Info

Display information about node status, including the latest block height and other details. This command queries the node set by `galacticad config node [rpc_node_url]`.

```sh
galacticad status
```

## Keys Management

### Create a New key

```sh
galacticad keys add [key_name]
```

After entering the command, you need to input the passphrase for the keys. You might need to re-enter the passphrase.

Example output:

```
Enter keyring passphrase (attempt 1/3): #
Re-enter keyring passphrase:

- address: [gala_address]
  name: [key_name]
  pubkey: [public_key]
  type: local


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

<<seed phrase here>>
```

### Import mnemonic

If you already have a mnemonic phrase, you can import it using the following command:

```sh
galacticad keys add [key_name] --recover
```

### Export a Key

Export your key to a file for backup.

```sh
galacticad keys export [key_name] > [key_file]
```

### Import a Key

Import a key from a file.

```sh
galacticad keys import [key_name] [key_file]
```

### Delete a Key

```sh
galacticad keys delete [key_name]
```

### Show Gala Address

Displays the Gala address associated with your key. The `-a` flag shows the address only. It has a prefix `gala`.

```sh
galacticad keys show [key_name] -a
```

### Show ETH Address

Converts your Gala address to an Ethereum-compatible address. It is useful for interacting with Ethereum-based DAPPs or wallets. It is in hex format (with the `0x` prefix).

```sh
galacticad keys convert-bech32-to-hex $(galacticad keys show [key_name] -a)
```

### Export Ethereum Private Key in Hex Format

Exports your Ethereum private key for use in other wallets or applications. You could import this key into a wallet like MetaMask or Keplr.

```sh
galacticad keys unsafe-export-eth-key [key_name]
```

### Check Account Balance

Displays the current balance of your account.

```sh
galacticad query bank balances $(galacticad keys show [key_name] -a)
```

## Validator Management

### Get Validator Address

Validator address is required for staking and other validator-specific operations. It has prefix `galavaloper`.

```sh
galacticad keys show [key_name] --bech val -a
```

### Get Consensus Address

Consensus address is the address used for consensus operations. It has prefix `galacons`.

```sh
galacticad keys show [key_name] --bech cons -a
```

### Get Validator Public Key

Validator public key is used for signing blocks and other validator operations. It is in bech32 format.

```sh
galacticad keys show [key_name] --bech val -p
```

### Get Consensus Public Key

Consensus public key is used for consensus operations. It is in bech32 format.

```sh
galacticad keys show [key_name] --bech cons -p
```

### Sharing your Peer ID

Your node's Peer ID is required for P2P communication. You can share it with other validators to establish connections.

```sh
galacticad tendermint show-node-id
```

* *Peer Format*: `node_id@ip:port`
* *Example*: `c722e6dc5f762b0ef19be7f8cc8fd67cdf988946@seed01-reticulum.galactica.com:26656`

## Staking and Rewards

### Get address delegations

```sh
galacticad query staking delegations $(galacticad keys show [key_name] -a)
```

### Delegate Tokens

Delegate tokens to a validator. Replace `[amount_agnet]` with the amount of tokens you wish to delegate.

```sh
galacticad tx staking delegate \
    $(galacticad keys show [key_name] --bech val -a) \
    [amount_agnet] \
    --gas="200000" \
    --gas-prices="100agnet" \
    --from=[key_name]
```

### Unbond Tokens

Unbond tokens from a validator.

```sh
galacticad tx staking unbond \
    $(galacticad keys show [key_name] --bech val -a) \
    [amount_agnet] \
    --gas="200000" \
    --gas-prices="100agnet" \
    --from=[key_name]
```

### Redelegate Tokens

Redelegate tokens from one validator to another. First argument is the source validator, and the second argument is the destination validator address.

```sh
galacticad tx staking redelegate \
    $(galacticad keys show [key_name_src] --bech val -a) \
    $(galacticad keys show [key_name_dst] --bech val -a) \
    [amount_agnet] \
    --gas="200000" \
    --gas-prices="100agnet" \
    --from=[key_name]
```

### Withdraw Rewards

Withdraw staking rewards, including commission if you're a validator.

```sh
galacticad tx distribution withdraw-rewards \
  $(galacticad keys show [key_name] --bech val -a) \
  --from=[key_name] \
  --commission \
  --gas="200000" \
  --gas-prices="100agnet"
```

## Validator Unjailing

### Unjail Validator

Unjail your validator if it has been jailed for downtime.

```sh
galacticad tx slashing unjail \
  --from=[key_name] \
  --gas="300000" \
  --gas-prices="100agnet"
```

### Jail reason

```sh
galacticad query slashing signing-info [validator-conspub]
```

## Governance

### Get list of proposals

```sh
galacticad query gov proposals
```

### Get proposal details

```sh
galacticad query gov proposal [proposal_id]
```

### Vote on a proposal

```sh
galacticad tx gov vote [proposal_id] [yes|no|no_with_veto|abstain] --from [key_name]
```

### Submit a proposal

```sh
galacticad tx gov submit-proposal [proposal_type: text|param_change|software_upgrade] [proposal_file] --from [key_name]
```

## Validators

### Get list of validators

```sh
galacticad query staking validators
```

### Get validator info

```sh
galacticad query staking validator [validator_address]
```

## Transactions

### Get Transaction Info by Hash

```sh
galacticad query tx [tx_hash]
```

For more advanced commands and network-specific details, refer to the galacticad help command:

```sh
galacticad --help
```

This cheat sheet covers basic commands needed to interact with the Galactica Network via the `galacticad` CLI.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.galactica.com/galactica-developer-documentation/validator-guide/usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
