Server Script

The script described here provides the back-end of our plugin

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 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 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

  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)

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 available in the HollaEx Kit.

The most important library of all is the HollaEx Tools Library which has all the main features you need.

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 example on GitHub to see how plugin structure should be organized.

Run the Script

Ensure you have executed npm install before running the command below.

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

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

npm start --plugin=<PLUGIN_NAME>

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

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

Last updated