# subsembly compile

### Overview

Compiles current **`Subsembly`** project. More specifically it installs the dependencies and generates the required files for the Runtime to support the `metadata` interface used by PolkadotJS. Lastly, it compiles the **`Subsembly`** Runtime into the hex encoded `wasm` binary file (WASM blob).

### Workflow&#x20;

The workflow of the compile command is following:

1. Make sure the dependencies are installed by checking **`node_modules`** folder.
2. &#x20;Generate metadata of the project&#x20;
   1. Parse system and other modules inside **`assembly/pallets`** directory to extract storage entries, calls and constants.&#x20;
   2. Generate files:&#x20;
      1. **`metadata.ts`**&#x20;

         Contains a function that returns SCALE encoded metadata of the project
      2. **`dispatcher.ts`**

         Contains a function that is used to dispatch extrinsic calls of corresponding modules&#x20;
   3. Build **`wasm`** file:&#x20;

      Compile AS project into **`.wasm`** file, hex encode the binary and save it in build directory.

### Build folder

AssemblyScript places compiled **`wasm`** files inside the build folder in the root directory. The hex encoded **`wasm`** bytecode of **`Subsembly`** runtime is also placed in the same folder.

### Syntax

```
subsembly compile
```

### Examples

```
# creates new compiled wasm of the runtime in /build directory
subsembly compile
```

And the result of this command is reflected in build folder:

![Picture 2. Build folder files](https://3486155078-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVLPB3fCkGpKnqkQwlo%2F-MW9DHcmYVMfFre4pFkp%2F-MW9RQ7jtlZlpLx6YSuN%2Fimage.png?alt=media\&token=0acd8d8b-68a1-4a5e-8b3d-fcfbe5fddf5a)


---

# 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://subsembly.gitbook.io/subsembly/getting-started/cli/subsembly-compile.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.
