# Commands

## 📚Useful commands📚

## ⚙️Service

**Info**

```python
curl -s http://localhost:26657/status | jq
curl -s http://localhost:26657/status | jq .result.sync_info
```

**Check node logs**

```python
sudo journalctl -fu story-geth -o cat
sudo journalctl -fu story -o cat
```

**Restart service**

```python
sudo systemctl restart story-geth
sudo systemctl restart story
```

**Stop service**

```python
sudo systemctl stop story-geth
sudo systemctl stop story
```

**Start service**

```python
sudo systemctl start story-geth
sudo systemctl start story
```

**reload/disable/enable**

```python
sudo systemctl daemon-reload
sudo systemctl disable story-geth
sudo systemctl disable story
sudo systemctl enable story-geth
sudo systemctl enable story
```

Your enode

```bash
geth --exec "admin.nodeInfo.enode" attach ~/.story/geth/odyssey/geth.ipc
```

### 💲Staking <a href="#staking" id="staking"></a>

Delegate to yourself

```bash
story validator stake --validator-pubkey $(story validator export | grep "Compressed Public Key (base64)" | awk '{print $NF}') --stake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Delegate

```bash
story validator stake --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --stake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Delegate on behalf of other delegator

```bash
story validator stake-on-behalf --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --delegator-pubkey <DELEGATOR_PUB_KEY_IN_BASE64> --stake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Add operator

```bash
story validator add-operator --operator <OPERATOR_EVM_ADDRESS> --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Unstake from yourself

```bash
story validator unstake --validator-pubkey $(story validator export | grep "Compressed Public Key (base64)" | awk '{print $NF}') --unstake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Unstake

```bash
story validator unstake --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --unstake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Unstake on behalf of other delegator. To do so, you must be a registered authorized operator for this delegator.

```bash
story validator unstake-on-behalf --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --delegator-pubkey <DELEGATOR_PUB_KEY_IN_BASE64> --unstake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Remove operator

```bash
story validator remove-operator --operator <OPERATOR_EVM_ADDRESS> --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

Set or change withdrawal address

```bash
story validator set-withdrawal-address --withdrawal-address <YOUR_EVM_ADDRESS> --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

### ⚙️Validator operations <a href="#validator-operations" id="validator-operations"></a>

Validator info

```bash
curl localhost:$(sed -n '/\[rpc\]/,/laddr/ { /laddr/ {s/.*://; s/".*//; p} }' $HOME/.story/story/config/config.toml)/status | jq
```

Check Validator public key

```bash
story validator export
```

Check Validator private key

```bash
cat $HOME/.story/story/config/private_key.txt
```

### ⚡Geth commands <a href="#geth-commands" id="geth-commands"></a>

Check the latest block

```bash
geth --exec "eth.blockNumber" attach ~/.story/geth/odyssey/geth.ipc
```

Peers your client is connected to

```bash
geth --exec "admin.peers" attach ~/.story/geth/odyssey/geth.ipc
```

Check if syncing is still in progress: will output "true" if geth is syncing

```bash
geth --exec "eth.syncing" attach ~/.story/geth/odyssey/geth.ipc
```

Check gas price

```bash
geth --exec "eth.gasPrice" attach ~/.story/geth/odyssey/geth.ipc
```

Check account balance

```bash
geth --exec "eth.getBalance('<YOUR_EVM_ADDRESS>')" attach ~/.story/geth/odyssey/geth.ipc
```
