# CLI Reference

### CLI Commands Overview

<table data-header-hidden><thead><tr><th width="219"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Command</strong></td><td><strong>Options</strong></td><td><strong>Description</strong></td><td>Default</td></tr><tr><td><strong><code>fxhash create</code></strong><br> <br>Creates a blank fx(hash) project. Allows you to choose between several starting templates.</td><td><code>—</code></td><td><code>—</code></td><td><code>—</code></td></tr><tr><td><strong><code>fxhash dev [options]</code></strong><br> <br>Runs your project inside fxlens, the fxhash development environment.<br></td><td><code>--portStudio</code></td><td>The port fxlens is served on.</td><td><code>3300</code></td></tr><tr><td></td><td><code>--portProject</code></td><td>The port the project is served on. </td><td><code>3301</code></td></tr><tr><td></td><td><code>--srcPath</code></td><td>The path to the source of the project. This is just relevant for ejected projects that actually have a nested structure.</td><td><code>/src</code></td></tr><tr><td><strong><code>fxhash build [options]</code></strong><br> <br>Creates a bundled version of the project directory. The output file will be called <code>upload.zip</code> and can be uploaded as it is on fxhash.xyz.</td><td><code>--minify</code></td><td>Enable minification when creating the bundle. </td><td><code>false</code></td></tr><tr><td></td><td><code>--noZip</code></td><td>Disable the zip file creation.</td><td><code>false</code></td></tr><tr><td></td><td><code>--srcPath</code></td><td>The path to the source of the project. This is just relevant for ejected projects that actually have a nested structure.</td><td><code>/src</code></td></tr><tr><td><strong><code>fxhash update [options]</code></strong><br> <br>Will update the whole fxhash environment. It will download the latest version of fxlens and the fxhash-snippet. Optionally you can inject the latest snippet into your html file.</td><td><code>--srcPath</code></td><td>The path to the source of the project. This is just relevant for ejected projects that actually have a nested structure.</td><td><code>/src</code></td></tr><tr><td><strong><code>fxhash eject</code></strong><br>  <br>Will eject your project into a nested structure. It will copy all your code into a <code>srcPath</code> (Default: <code>/src</code>) and create a <code>package.json</code>file in the root of your project. This will allow you to configure any custom tooling you like while still being able to use the <code>@fxhash/cli</code> in your ejected project.</td><td><code>--srcPath</code></td><td>The path to eject the code into. If you set a custom path here you also must specify this path to the other commands.</td><td></td></tr><tr><td><strong><code>fxhash add &#x3C;package@version></code></strong><br>  <br>Installs existing libraries. Beside being a convenience feature. This ensure that you are reusing existing libraries from the ONCHFS, which reduces the costs of storing your project on-chain 😎.</td><td><code>--list</code></td><td>Lists all existing libraries that can be imported</td><td><code>—</code></td></tr><tr><td></td><td><code>--inject</code></td><td>Will also inject a <code>&#x3C;script /></code> tag into your projects html entry point pointing to the downloaded library</td><td></td></tr><tr><td><code>fxhash capture [options]</code><br>  <br>With the capture command you can test your bundled project agains the fx(hash) capture module. For params token you currently <strong>must</strong> provide the inputBytes yourself. You can copy the inputBytes from the url when you are running the <code>fxhash dev</code> command.</td><td><code>--zip</code></td><td>The path (absolute or relative) to the project's zip file you want to create the capture of. </td><td><code>upload.zip</code></td></tr><tr><td></td><td><code>--hash</code></td><td>The hash that is injected when the capture is taken.</td><td>random hash</td></tr><tr><td></td><td><code>--minter</code></td><td>The minter address that is injected when the capture is taken.</td><td>random address</td></tr><tr><td></td><td><code>--iteration</code></td><td>The iteration number that is injeted when the capture is taken.</td><td>1</td></tr><tr><td></td><td><code>--inputBytes</code></td><td>The inputBytes that are injected when the capture is taken.</td><td><code>undefined</code></td></tr><tr><td></td><td><code>--x</code></td><td>The width in pixels. Capped at 2560.</td><td><code>800</code></td></tr><tr><td></td><td><code>--y</code></td><td>The height in pixels. Capped at 2550,</td><td><code>800</code></td></tr><tr><td></td><td><code>--trigger</code></td><td>The trigger mode. Either DELAY or FN_TRIGGER.</td><td><code>delay</code></td></tr><tr><td></td><td><code>--delay</code></td><td>The delay in ms for the trigger mode DELAY.</td><td><code>3000</code></td></tr><tr><td></td><td><code>--selector</code></td><td>The id of the canvas element to capture.</td><td><code>—</code></td></tr></tbody></table>

### **`fx(hash) create`**

{% hint style="info" %}
**Creates a new project directory that contains the fxhash template.**
{% endhint %}

Once you've installed the CLI, you can conveniently create a new and blank fxhash project with the `fxhash create` command. Running the command will spawn a new folder in the current terminal directory. This folder will essentially contain the boilerplate files.

<figure><img src="https://3455566235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMgz5PcqIbAPWwLF7xWn%2Fuploads%2FL521FbWubMXJLCU9AIlN%2Fimage.png?alt=media&#x26;token=196514aa-3a04-407a-938c-db770055f081" alt=""><figcaption><p>Running the <code>fxhash create</code> command in the terminal + the files that it spawns</p></figcaption></figure>

The command will ask you to provide a name for your project and additionally ask you to choose a template—currently there are two of them:

* **Simple Template:** If you are new to the platform and/or don't need any special customization, we recommend starting with the simple template.
* **The Ejected Template:** Needs an explanation of the ejected template

The `fxhash create` command has no options.

### **`fxhash dev`**

{% hint style="info" %}
**Runs your project inside fxlens, the fxhash development environment.**
{% endhint %}

The `fxhash dev` command can be used when you navigate into the directory that is created with the `fxhash create` command. This will launch your project inside the fxhash's fxlens development environment and automatically opens up a new tab in your default browser.&#x20;

If you haven’t already written some code for your artwork in the `index.js`, it will show the following default screen:

<figure><img src="https://3455566235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMgz5PcqIbAPWwLF7xWn%2Fuploads%2FQ5J17c2jt3U1yUUGxgrt%2Fimage.png?alt=media&#x26;token=00f5159f-2b8b-4389-a69d-4a78e3b07869" alt=""><figcaption><p>The default boilerplate will display a bunch of text in the main area of the browser window that represent some default debug information.</p></figcaption></figure>

The panel on the left-hand side is fxlens, fx(hash)’s interactive project viewer that comes out of the box with the CLI. [fx(lens) is explained in more detail here](https://www.notion.so/fx-lens-8ab5e856c9054621a0796fde107aac80?pvs=21), it provides a number of functionalities for testing the determinism of your generative artwork and is an important tool for building fx(params) pieces.

The `fxhash dev` command runs two local servers, one for the project itself, and another for the development environment that displays the project in a nested manner. The options let you set the ports on which these local servers run:

* `--portStudio`:&#x20;
* `--portProject`:&#x20;
* `--srcPath`:&#x20;

{% hint style="warning" %}
`fxhash dev` automatically checks and updates itself when it is run.
{% endhint %}

### **`fxhash build`**

When your artwork is ready for being minted it should be uploaded to fx(hash) in the form of a `.zip` file. The CLI provides the `fxhash build` command that bundles all of your project files as such a `.zip`. This will create an `upload.zip` file in your project directory, that can later be drag-n-dropped into the fx(hash) minting interface.

{% hint style="warning" %}
Before you upload a project to fx(hash) however make sure to read the rest of the artist guides to ensure that your project works correctly and is properly configured to be compatible with the platform. fx(hash) can not check this for you.&#x20;
{% endhint %}

### `fxhash capture`

The CLI also lets you test the appearance of your project once it’s iterations have been collected on fx(hash). For this you’ll first have to bundle your project with the `fxhash build` command, to then subsequently run the `fxhash capture` command which will then generate a jpg of the artwork, here’s what this would look like:

<figure><img src="https://3455566235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMgz5PcqIbAPWwLF7xWn%2Fuploads%2Fc9ITss2YnQerlPLnHCke%2Fimage.png?alt=media&#x26;token=5618e07e-cb14-4d90-8f5a-59be5c526c4e" alt=""><figcaption></figcaption></figure>

The capture command provides a number of options to specify some of the information that needs to be fed into the token to generate specific captures, and to control how the capture should be taken. They are detailed in the overview table above.

### **`fxhash update`**

{% hint style="info" %}
`fxhash update` command updates the CLI and all of it’s features to the latest version, in case that there is a newer version.
{% endhint %}

<figure><img src="https://3455566235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMgz5PcqIbAPWwLF7xWn%2Fuploads%2FxakYKlWEnaDQ6kBl0SkB%2Fimage.png?alt=media&#x26;token=bd70a368-ff8c-4033-b0a2-b3e7717ebe0f" alt=""><figcaption></figcaption></figure>

### **Configuring Default Options with `.env`**

When you run the CLI commands, it checks for a `.env` file inside the current difrectory. The `.env` file allows you to overwrite the default options of the various commands—for example if you want to run fxlens and your project on different ports:

```html
PORT_PROJECT=3301
PORT_STUDIO=3300
SRC_PATH=/src
MINIFY=false
```

This way you can customize how the CLI behaves for different projects.

{% hint style="info" %}
**Options passed in manually to commands still always override what's set in the \`.env\` file.**
{% endhint %}
