> For the complete documentation index, see [llms.txt](https://docs.endless.link/endless/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.endless.link/endless/devbuild/build/learn-the-move-language/advanced-move-guides/move-scripts/compiling-move-scripts.md).

# Compiling Move Scripts

## How can I compile Move Scripts?

Move scripts can be compiled with the already existing Endless Move compiler in the Endless CLI. For more on how to install and use the Endless CLI with Move contracts, go to the Working With Move Contracts page.

Once you have the Endless CLI installed, you can compile a script by running the following command from within the script package:

```shell
endless move compile
```

There will then be compiled bytecode files under `build/` with the same name as the function in Move.

For example this script in package `transfer_half`, would compile to `build/transfer_half/bytecode_scripts/transfer_half.mv`

```move
script {
  use std::signer;
  use endless_framework::coin;
  use endless_framework::endless_account;

  fun transfer_half<Coin>(caller: &signer, receiver_address: address) {
    // Retrieve the balance of the caller
    let caller_address: address = signer::address_of(caller);
    let balance: u64 = coin::balance<Coin>(caller_address);

    // Send half to the receiver
    let half = balance / 2;
    endless_account::transfer_coins<Coin>(caller, receiver_address, half);
  }
}
```

Additionally, there is a convenience function for a package with exactly one script with the below command:

```shell
endless move compile-script
```

Providing output like below returning the exact location of the script and a hash for convenience

```shell
Compiling, may take a little while to download git dependencies...
UPDATING GIT DEPENDENCY https://github.com/endless-labs/endless.git
INCLUDING DEPENDENCY EndlessFramework
INCLUDING DEPENDENCY EndlessStdlib
INCLUDING DEPENDENCY MoveStdlib
BUILDING transfer_half
{
  "Result": {
    "script_location": "/opt/git/developer-docs/apps/docusaurus/static/move-examples/scripts/transfer_half/script.mv",
    "script_hash": "9b57ffa952da2a35438e2cf7e941ef2120bb6c2e4674d4fcefb51d5e8431a148"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.endless.link/endless/devbuild/build/learn-the-move-language/advanced-move-guides/move-scripts/compiling-move-scripts.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.
