# Example

{% hint style="info" %}
The current document is based on v0.3.5-patch. Documentation for the v0.4.0 upgrade will be prepared soon.
{% endhint %}

The purpose of this document is to inform the users on how to upgrade the chain to v0.3.5 using `cosmovisor`. All processes mentioned in this document must be conducted on the binary v0.3.3 preconfigured chain server.

## Cosmovisor download & setup

**1. Download Cosmovisor**

```bash
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
```

**2. Using the command below**

```bash
sudo mv ~/go/bin/cosmovisor /usr/local/bin/cosmovisor
```

**3. Setup environment**

```bash
echo "# [FirmaChain] Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=firmachaind" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.firmachain" >> ~/.profile
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=false" >> ~/.profile
echo "export DAEMON_RESTART_AFTER_UPGRADE=true" >> ~/.profile
echo "export UNSAFE_SKIP_BACKUP=false" >> ~/.profile
echo "export DAEMON_PREUPGRADE_MAX_RETRIES=0" >> ~/.profile
```

Once you've applied all environment variables, please reload the .profile file by running the command provided below.

```bash
source ~/.profile
```

If all environment variables have been registered successfully, you can input the command provided below to get an output on the registered variables.

```bash
echo $DAEMON_NAME
=> firmachaind
```

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*<mark style="color:red;">**※ In case of 1.0.0 version.**</mark>*

* Please execute the command below.\
  If you don't execute this command, you can't run **`cosmovisor`**.

```bash
echo "{}" >> /home/firma/.firmachain/cosmovisor/current/upgrade-info.json
```

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

In order to launch **`cosmovisor`**, please enter the command provided below.

```bash
$ cosmovisor run start
7:44AM INF running app args=["start"] module=cosmovisor path=/home/firma/.firmachain/cosmovisor/genesis/bin/firmachaind
7:44AM INF starting ABCI with Tendermint
7:44AM INF Starting multiAppConn service impl=multiAppConn module=proxy
7:44AM INF Starting localClient service connection=query impl=localClient module=abci-client
7:44AM INF Starting localClient service connection=snapshot impl=localClient module=abci-client
7:44AM INF Starting localClient service connection=mempool impl=localClient module=abci-client
7:44AM INF Starting localClient service connection=consensus impl=localClient module=abci-client
7:44AM INF Starting EventBus service impl=EventBus module=events
7:44AM INF Starting PubSub service impl=PubSub module=pubsub
7:44AM INF Starting IndexerService service impl=IndexerService module=txindex
7:44AM INF ABCI Handshake App Info hash= height=0 module=consensus protocol-version=0 software-version=0.3.3
7:44AM INF ABCI Replay Blocks appHeight=0 module=consensus stateHeight=0 storeHeight=0
7:44AM INF asserting crisis invariants inv=0/11 module=x/crisis name=gov/module-account
7:44AM INF asserting crisis invariants inv=1/11 module=x/crisis name=distribution/nonnegative-outstanding
7:44AM INF asserting crisis invariants inv=2/11 module=x/crisis name=distribution/can-withdraw
7:44AM INF asserting crisis invariants inv=3/11 module=x/crisis name=distribution/reference-count
7:44AM INF asserting crisis invariants inv=4/11 module=x/crisis name=distribution/module-account
7:44AM INF asserting crisis invariants inv=5/11 module=x/crisis name=bank/nonnegative-outstanding
7:44AM INF asserting crisis invariants inv=6/11 module=x/crisis name=bank/total-supply
7:44AM INF asserting crisis invariants inv=7/11 module=x/crisis name=staking/module-accounts
7:44AM INF asserting crisis invariants inv=8/11 module=x/crisis name=staking/nonnegative-power
7:44AM INF asserting crisis invariants inv=9/11 module=x/crisis name=staking/positive-delegation
7:44AM INF asserting crisis invariants inv=10/11 module=x/crisis name=staking/delegator-shares
...
12:55PM INF ABCI Replay Blocks appHeight=1 module=consensus stateHeight=1 storeHeight=1
```

Now, Cosmovisor is up and running.

## Upgrade version binary download & setup

The user must already be running FirmaChain v0.3.3 and this process illustrates the necessary preparations to upgrade the chain to v0.3.5 using Software Proposal.

#### 1. Folder Structure Setting

```bash
mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin
mkdir -p $DAEMON_HOME/cosmovisor/upgrades/v0.3.5/bin
```

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*<mark style="color:red;">**※ In case of 1.0.0 version.**</mark>*

* Please execute the command below.\
  If you don't execute this command, you can't run **`cosmovisor`**.

```bash
echo "{}" >> /home/firma/.firmachain/cosmovisor/current/upgrade-info.json
```

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

**2. Prepare firmachaind binary**

```bash
git clone https://github.com/firmachain/firmachain.git
cd firmachain
git pull or git checkout v0.3.5-patch
make install
```

**3. Copy and Paste the Binary File to the Cosmovisor Upgrade Folder Directory**

```bash
mv go/bin/firmachaind $DAEMON_HOME/cosmovisor/upgrades/v0.3.5/bin/firmachaind
```

## Post-Upgrade

`cosmovisor` should be up and running using the upgraded file in v0.3.5/bin folder. Please use the command provided below to check the upgraded binary version.

```bash
$ cosmovisor run version
8:02AM INF running app args=["version"] module=cosmovisor path=/home/firma/.firmachain/cosmovisor/upgrades/v0.3.5/bin/firmachaind
0.3.5-beta3-1-g4a1ba1c
```


---

# 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.firmachain.org/master/node-and-validators-guide/run-a-full-node/run-a-cosmovisor/example.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.
