# Server Script

The server script, `script.js` defines what libraries are imported and is what will get us to our end goal

## Before You Start - **Dev Mode**

Before you start, make sure you have an exchange running in [dev mode](/developers/run-dev-mode.md) on your machine. It is important to have the exchange running in dev mode instead of a standard production CLI setup.

Dev mode exchange has live code updates and any changes in the code will get immediately applied which will make your development experience much better as a developer.

## Create the Script

Looking inside the `plugins/src/plugins/<YOUR_PLUGIN>` you will see that the [initialization](/plugins/develop-plugins/advanced/initialization.md) created a server folder for us. This is the folder where the `config.json` was made.

1. Create a new file in this server folder called `script.js`&#x20;
2. Code `script.js` to whatever goal you have in mind for the plugin (I recommended here looking below at the hello-exchange walkthrough to get an idea of how a script can look)&#x20;

`script.js` is the server-side code that runs during runtime into the server's plugin container. The server script has access to many [libraries](#plugin-libraries) available in the HollaEx Kit.&#x20;

The most important library of all is the [HollaEx Tools Library](https://github.com/hollaex/hollaex-kit/tree/master/server/utils/hollaex-tools-lib) which has all the main features you need.

{% hint style="info" %}
If at any point, you become unsure of the structure of either your plugin's folders or the code within the files themselves, take a look at the [*hello-exchange*](https://github.com/hollaex/hollaex-kit/tree/master/plugins/src/plugins/hello-exchange) example on GitHub to see how plugin structure should be organized.
{% endhint %}

## Run the Script

{% hint style="warning" %}
Ensure you have executed `npm install` before running the command below.&#x20;

You may also need to add `sudo` at the beginning of the command above depending on your OS.

**In addition**, make sure **CORS has been disabled** on your browser (this can be tricky in Firefox, so Chrome may be easier to work with).command

Finally, for the run comand to work, you will need python 2 on your machine, this can be installed for Linux with sudo apt install python
{% endhint %}

To run the script on your dev mode exchange, you need to go to `/plugins` and run:

```
npm start --plugin=<PLUGIN_NAME>
```

{% hint style="info" %}
Remember this will need to be done in a **new** **terminal** as dev mode will block any input on the terminal it was started on
{% endhint %}

To see if this has worked try accessing localhost:8080/config.json, and you will see the config file of the plugin


---

# 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/plugins/develop-plugins/advanced/server-script.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.
