> For the complete documentation index, see [llms.txt](https://stratos.gitbook.io/st-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stratos.gitbook.io/st-docs/stratos-chain-english/stratos-chain-testnet/stratos-chain-testnet-upgrade-from-v0.4.0-to-v0.5.0.md).

# Stratos-Chain-Testnet upgrade from v0.4.0 to v0.5.0

Please follow these steps to upgrade your Stratos-Chain Testnet

**1. Backup and cleanup current blockchain data**

**1.1 Backup `data` folder**

```bash
mkdir ./backups/data
mv ./data/* ./backups/data/
```

**1.2 Create `priv_validator_state.json` file in `data` folder**

```bash
 echo '{
 "height": "0",
 "round": "0",
 "step": 0
  }' \
 > ./data/priv_validator_state.json
```

**2. Prepare `genesis.json` file**

**2.1 Download `genesis.json`**

```bash
wget https://raw.githubusercontent.com/stratosnet/stratos-chain-testnet/main/genesis.json
```

**2.2 Replace`genesis.json` file in `config` folder with the downloaded one**

**3. Existing multiple nodes(optional)**

If you have multiple nodes, repeat Step 1 and Step 2 for each node.

**4. Update binary**

Download the updated `stchaind` and `stchaincli` binary files

```bash
wget https://github.com/stratosnet/stratos-chain/releases/download/v0.5.0/stchaincli
wget https://github.com/stratosnet/stratos-chain/releases/download/v0.5.0/stchaind
```

**4.1 Check the granularity**

```bash
md5sum stchain*

## expect output 
## aded93fa2f1f4816375dcb425ec4ce42 stchaincli
## 2d79092bd2096baa82879edc64c17294 stchaind
```

**4.2 Replace old `stchaincli` and `stchaind` binary files with these downloaded ones**

**4.3 Add `execute` permission for these downloaded binary files**

```bash
chmod +x stchaincli
chmod +x stchaind
```

**4 Update binary -alternative**

**4.1 Compile the binary with source code**

Make sure you have Go 1.15+ installed ([link](https://golang.org/doc/install)).

```bash
git clone https://github.com/stratosnet/stratos-chain.git
cd stratos-chain
git checkout v0.5.0

# The binary can be found in ./build folder
make build 

#or install to default $GOPATH/bin
make install 
```

**5. Run your node**

```bash
./stchaind start --home ./ 
```

Hereafter, the node will try to catch up with the blockchain to the latest block

**5.1 Run the node in background**

```bash
./stchaind start --home ./ 2>&1 >> chain.log &
```

**6. Get test tokens from `faucet`(`https://faucet-test.thestratos.org/`)**

```bash
curl -X POST https://faucet-test.thestratos.org/faucet/<your-wallet-address>

```

For example: in your terminal,

```bash
curl -X POST https://faucet-test.thestratos.org/faucet/st1gwtcnptte6fpxck3f9xs45ufrru9sz2500edn8
```

Note:

1 stos = 1000000000 ustos

By default, `faucet` will send 100stos(100000000000ustos) to the given wallet address

**7. Check your account balance**

Note: Account balance is only available after your node has finished catching up with the blockchain.

```bash
./stchaincli query account <your address> --home ./
```

**Example**

```shell
root@2fb153d9009c:/stchaind# ./stchaincli query account st1gwtcnptte6fpxck3f9xs45ufrru9sz2500edn8 --home ./
|
  address: st1gwtcnptte6fpxck3f9xs45ufrru9sz2500edn8
  coins:
  - denom: ustos
    amount: "49999999900000000"
  public_key: stpub1addwnpepqd3x0rpxp6hrrmuwm25cz5yvuvaxmqgj9rfxqnu4pgpln7ytx9mrjz0pa3d
  account_number: 0
  sequence: 1
```

<br>

**8. Check your node status**

```bash
./stchaincli status --home ./
```

**Example**

```shell
root@4bed4f6fb8f9:/stchaind# ./stchaincli status --home ./
```

```json
{
  "node_info": {
    "protocol_version": {
      "p2p": "7",
      "block": "10",
      "app": "0"
    },
    "id": "65d5e80214b5239b7397830879998cd3065fab57",
    "listen_addr": "tcp://0.0.0.0:26656",
    "network": "test-chain-localnet",
    "version": "0.33.9",
    "channels": "4020212223303800",
    "moniker": "node0",
    "other": {
      "tx_index": "on",
      "rpc_address": "tcp://127.0.0.1:26657"
    }
  },
  "sync_info": {
    "latest_block_hash": "4F9E3AB72D578CC6153445CF7154E593360DF39B2BBB63317241B94CA89967E9",
    "latest_app_hash": "3DA857CCF4D4F151E107BEC943C6A3A394D4B239F23B37091E7E33FE61B96AFB",
    "latest_block_height": "361",
    "latest_block_time": "2021-10-14T02:35:22.222386147Z",
    "earliest_block_hash": "87AA89CB8FEF876C38BAE4F810D3CEA6249C0330E7CF0673464EEEE734A72400",
    "earliest_app_hash": "",
    "earliest_block_height": "1",
    "earliest_block_time": "2021-09-29T21:48:00.612410904Z",
    "catching_up": false
  },
  "validator_info": {
    "address": "82B659FC939521E845E552DCE32BA29DA2EA8718",
    "pub_key": {
      "type": "tendermint/PubKeyEd25519",
      "value": "O+naHHEZ5SexfhniH73WXhJiC83lLPjDiav40GfPp5M="
    },
    "voting_power": "100"
  }
}
```

<br>

**9. Try your first tx - `send`**

```bash
./stchaincli tx send <from address> <to address> <amount> --home ./ --keyring-backend test --chain-id stratos-testnet-3 
```

**Example**

Tx command:

```shell
./stchaincli tx send st1kuhyf59qvukk8r5manky062d6c66utvytm7az6 st1m4f4hnyfhpaeqlcgv7lfhgzjwmrvfeggwnpygz  1000000ustos --home=./ --chain-id=stratos-testnet-3 --keyring-backend=test --gas=auto
```

Output:

```shell
          ...
          
    confirm transaction before signing and broadcasting [y/N]: y
    height: 0
    txhash: 0BFC71FFAFCB4554A95586E7C63042698F5E1D1BD5443B09C36F6FC2C3FFA737
    codespace: ""
    code: 0
    data: ""
    rawlog: '[]'
    logs: []
    info: ""
    gaswanted: 0
    gasused: 0
    tx: null
    timestamp: ""
```

Check this tx:

```shell
root@3200b05c02b9:/stchaind# ./stchaincli query tx 0BFC71FFAFCB4554A95586E7C63042698F5E1D1BD5443B09C36F6FC2C3FFA737 --chain-id=stratos-testnet-3
    height: 9765
    txhash: 0BFC71FFAFCB4554A95586E7C63042698F5E1D1BD5443B09C36F6FC2C3FFA737
    codespace: ""
    code: 0
    data: ""
    rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"send"},{"key":"sender","value":"st1kuhyf59qvukk8r5manky062d6c66utvytm7az6"},{"key":"module","value":"bank"}]},{"type":"transfer","attributes":[{"key":"recipient","value":"st1m4f4hnyfhpaeqlcgv7lfhgzjwmrvfeggwnpygz"},{"key":"sender","value":"st1kuhyf59qvukk8r5manky062d6c66utvytm7az6"},{"key":"amount","value":"1000000ustos"}]}]}]'
    logs:
    - msgindex: 0
    log: ""
    events:
    - type: message
    attributes:
    - key: action
    value: send
    - key: sender
    value: st1kuhyf59qvukk8r5manky062d6c66utvytm7az6
    - key: module
    value: bank
    - type: transfer
    attributes:
    - key: recipient
    value: st1m4f4hnyfhpaeqlcgv7lfhgzjwmrvfeggwnpygz
    - key: sender
    value: st1kuhyf59qvukk8r5manky062d6c66utvytm7az6
    - key: amount
    value: 1000000ustos
    info: ""
    gaswanted: 200000
    gasused: 64559
    tx:
    msg:
    - from_address: st1kuhyf59qvukk8r5manky062d6c66utvytm7az6
    to_address: st1m4f4hnyfhpaeqlcgv7lfhgzjwmrvfeggwnpygz
    amount:
    - denom: ustos
    amount: "1000000"
    fee:
    amount:
    - denom: ustos
    amount: "100"
    gas: 200000
    signatures:
    - |
    pubkey: stpub1addwnpepq0dx083vc4gn3f5quc2znpt4qx39cyxg52lu28fp2r2nnky7yaxsur40qny
    signature: !!binary |
    v1E4ABuErs6lHP6mjLLyUkOa0SqyV1cICHLwdzjWORRLiA1XGD1fWgbweLUNmI/XNBoBYp
    YvodHGm3VRfg7C6A==
    memo: ""
    timestamp: "2021-07-13T17:42:14Z"
```
