> 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/writing-move-scripts.md).

# Writing Move Scripts

## How can I write Move Scripts?

Move scripts can be written in tandem with Move contracts, but it's highly suggested to use a separate Move package for it. This will make it easier for you to determine which bytecode file comes from the script.

### Package layout

The package needs a Move.toml and a sources directory, similar to code modules.

For example, we may have a directory layout like:

```
my_project/
├── Move.toml
└── sources/
    └── my_script.move

```

### Script syntax

Scripts can be written exactly the same as modules on Endless. Imports can be used for any dependencies in the Move.toml file, and all public functions, including entry functions, can be called from the contract. There are a few limitations:

* There must be only one function in the contract, it will compile to that name.
* Input arguments can only be one of \[`u8`, `u16`, `u32`, `u64`, `u256`, `address`, `bool`, `signer`, `&signer`, `vector<u8>`]. There is no support for vectors of other types, or structs.

An example below:

```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);
  }
}
```

For more specific details see: Move Book on Scripts


---

# 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/writing-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.
