# Run Dev Mode

{% hint style="info" %}
Dev mode is for development purposes to allow easier debugging and testing. If you have built your exchange using CLI commands running on your machine, you need to stop and start the process fresh with the following instructions.
{% endhint %}

Clone the HollaEx Kit Github repo: <https://github.com/hollaex/hollaex-kit>

```
git clone https://github.com/hollaex/hollaex-kit.git
```

{% hint style="info" %}
HollaEx Kit `/web` is the front-end project built in ReactJS that connects to the HollaEx Kit `server` which is accessible in the `/server` folder.
{% endhint %}

## Server

In order to start the server in dev mode you need to run the following:

{% hint style="info" %}
You need to download a new Kit in order to follow the guide. Following the guide below with the existing Kit exchange could cause unexpected issues. Please make sure to proceed with a new fresh HollaEx Kit.
{% endhint %}

{% hint style="warning" %}
Before you proceed, please set up a new exchange on the HollaEx Dashboard. Please visit [dash.hollaex.com](http://dash.hollaex.com) for the mainnet connection or [dash.testnet.hollaex.com](http://dash.testnet.hollaex.com) for the testnet connection.

You need to get 2 things here.

* Exchange Keys (**API Key** and API **Secret**)
  * Mainnet - <https://dash.hollaex.com/mypage/apikey>
  * Testnet - <https://dash.testnet.hollaex.com/mypage/apikey>
* **Activation Code**
  * Mainnet - <https://dash.hollaex.com/general>
  * Testnet - <https://dash.testnet.hollaex.com/general>

Please save them somewhere safe. You'll need those very soon.
{% endhint %}

{% hint style="info" %}
If you have your own custom HollaEx Network, you should set the following value in the env file, and go through the exchange creation flow above on your own network.

* `NETWORK_URL=https://<YOUR_CUSTOM_HOLLAEX_NETWORK_API_URL>`
  {% endhint %}

1. Enter the HollaEx Kit folder with `cd hollaex-kit/`
2. `cd server/`
3. make a new env file `mv tools/hollaex-kit.env.local.example tools/hollaex-kit.env.local`
   1. Open the new `tools/hollaex-kit.env.local` file with a text editor/ IDE.
   2. Fill up `API_KEY`, `API_SECRET`, and `ACTIVATION_CODE` values you got from the HollaEx Dashboard.
      1. `API_KEY` and `API_SECRET` are for the exchange keys.
      2. `ACTIVATION_CODE` is for the activation code.
4. Run `docker-compose up` to start the server.
5. Once docker is all set, open a new terminal window, and check the status of the containers with `docker ps` . There should be 4 containers for `nginx` `redis` `postgresql` and the kit `server`<br>
6. Go inside the Docker container, by running `docker exec -it server_hollaex-kit-server_1 /bin/bash`<br>

   <figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2F4AjliPOdvwlb0fhqZbc6%2Fimage.png?alt=media&#x26;token=a9ae355a-d7c7-452f-82f3-e17aa0d3cbcc" alt=""><figcaption></figcaption></figure>
7. Once you are successfully  inside the docker container you should run the following commands:

   * Run database migrations: `sequelize db:migrate`
   * Run database seed: `sequelize db:seed:all`
   * Run database triggers: `node tools/dbs/runTriggers.js`
   * Run activation to activate the exchange: `node tools/dbs/setActivationCode.js`

   <figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FVVJzEit82mIetvuvKVxn%2Fimage.png?alt=media&#x26;token=cff84c03-fc4a-4ef5-80af-47c04cf0ca66" alt=""><figcaption></figcaption></figure>
8. On the terminal that you ran `docker-compose up`, press ctrl + c to stop the process, then run `docker-compose up` again to apply the new settings.

## Checking Dev Mode is working

One thing we can do to see dev mode in action is run the pre-existing '*hello-exchange*' plugin. This will have been downloaded as part of the cloning process above and can be found at:&#x20;

*hollaex-kit/plugins/src/plugins/hello-exchange* <br>

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FDmbQPXeA8mzuw7vOcPUx%2Fimage.png?alt=media&#x26;token=d34812fe-e80c-4417-b024-090468d73ae3" alt=""><figcaption><p>hello-exchange and its location</p></figcaption></figure>

Whilst `docker-compose up` is running in one terminal, in another terminal, enter the *hollaex-kit\_server* docker container with:

`docker exec -it server_hollaex-kit-server_1 /bin/bash` (just as in step 7 above).

Once in the container run:

`node plugins/dev.js --plugin=hello-exchange`

Give it a little time (until 'i*nfo: HELLO-EXCHANGE PLUGIN initializing...*' is printed) and from your browser access:

[`http://localhost:10013/plugins/hello-exchange/info`](http://localhost:10013/plugins/hello-exchange/info)

You should see the output in the image below.

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FyetiTbKlH05cYDI1n4qW%2Fimage.png?alt=media&#x26;token=551719ca-fbe9-4da4-a58a-b0e496a4a1a4" alt=""><figcaption><p>In Google Chrome</p></figcaption></figure>

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FOCEtfs1vJ8B9tAnf1LOi%2Fimage.png?alt=media&#x26;token=6e5ec9f7-3580-4bbe-adcb-155ce41b3a9d" alt=""><figcaption><p>In Firefox</p></figcaption></figure>

### Editing a File While in Dev Mode

Now let's edit the *hello-exchange* plugin, access the following file (I will be in my IDE):

*hollaex-kit/plugins/src/plugins/hello-exchange/server/script.js*

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FiRlHOZftRRkpfcPnijUp%2Fimage.png?alt=media&#x26;token=50a49c4f-a67d-499a-8811-f2e4662ecf31" alt=""><figcaption></figcaption></figure>

Edit the returned JSON object highlighted in the image above. Here the message has been altered from retrieving values from the config file, and elsewhere, to the string "Something new!"

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2Fcpt0XuGtzFT9tySNlMWG%2Fimage.png?alt=media&#x26;token=d750385a-5f31-4849-aad7-d2b156a7b226" alt=""><figcaption><p>Something is new, for sure</p></figcaption></figure>

Now go back to the  terminal where we built the plugin (where the node command was run) and **stop the process, and rerun it** (`node plugins/dev.js --plugin=hello-exchange).` Refresh the *localhost* browser page, and we will see that a new message is now displayed.

<figure><img src="https://3965312054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP899VqAdyGFgLTy9SY%2Fuploads%2FAuljBKe3Jui0AAikYC5K%2Fimage.png?alt=media&#x26;token=83dd1598-f4b7-4c58-a6c3-cc462b2f7caf" alt=""><figcaption><p>On the fly editing!</p></figcaption></figure>

From this very quick example, you can see the benefit of dev mode, rather than needing to completely rebuild the codebase, we have been able to quickly make a change, rebuild it in seconds and see that change reflected.

## Accessing Dev Mode After Initial Setup

Once you have completed all the above, and either come out of dev mode or rebooted your machine, fortunately, to get back into dev mode the only command required to run is `docker-compose up` in the /server directory. Easy peasy.

## Web

`/web` folder in HollaEx Kit is a ReactJS project that contains all the front-end code.

{% hint style="info" %}
Use **node.js v14** for the best compatibility since some latest version of node.js might fail to run.&#x20;
{% endhint %}

To run it locally in development mode, you need to run: `npm start` which installs all the dependencies and starts the browser on `http://localhost:3000` .&#x20;

Changes are applied and updated live on the site.

By default, it connects to the default HollaEx Kit which is HollaEx Sandbox <https://api.sandbox.hollaex.com>

You can change this value in `/web/src/config/index.js`

Change `DEVELOPMENT_ENDPOINT` to your custom HollaEx Kit server API.


---

# 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.hollaex.com/developers/run-dev-mode.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.
