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

# Running Move Scripts

## How can I run Move Scripts?

Move scripts are supported in the Endless TypeScript SDK, Endless Wallet Adapter, and in the Endless CLI.

### Running scripts with the TypeScript SDK

To use a script with the TypeScript SDK, add the `bytecode` directly to the transaction in place of an entry function name.

```ts
import { readFileSync } from "fs";
import { Endless, Account, AccountAddress } from "@endless-labs/ts-sdk";

// Setup client, and account to sign
const endless = new Endless();
const account = Account.generate();

// Load script bytecode
const buffer = readFileSync("./transfer_half.mv", "buffer");
const bytecode = new Uint8Array.from(buffer);

// Build a transaction with the bytecode of the script
const transaction = await endless.transaction.build.simple({
  sender: account.accountAddress,
  data: {
    bytecode,
    typeArguments: ["0x1::endless_coin::EndlessCoin"],
    functionArguments: ["0x1"],
  },
});

// Submit and wait for the transaction to complete
const pendingTxn = await endless.signAndSubmitTransaction({
  signer: account,
  transaction,
});
await endless.waitForTransaction({ transactionHash: pendingTxn.hash });
```

### Running scripts with the Endless Wallet Adapter

:::warning Not all wallets support scripts, but when the wallet supports scripts, it can be provided as below :::

Similar to the TypeScript SDK, the same inputs are accepted as a transaction type on the wallet adapter. Just simply load the bytecode as a hex `string` or a `uint8array`.

```ts
import { useWallet } from "@endless-labs/wallet-adapter-react";

//...

// Load the bytecode either as a uint8array or a hex encoded string
const BYTECODE_IN_HEX = "0xa11ceb0b...78979";

export default function App() {
  const { signAndSubmitTransaction } = useWallet();

  function submitScript() {
    signAndSubmitTransaction({
      data: {
        bytecode: BYTECODE_IN_HEX,
        typeArguments: ["0x1::endless_coin::EndlessCoin"],
        functionArguments: ["0x1"],
      },
    });
  }

  // ...
}
```

### Running scripts with the CLI

Running scripts with the CLI can be run with the command

```shell
endless move run-script
```

There are two ways to run it, with a pre-compiled script, or it will compile the script in-place similar to the compile step.

If you already have a compiled script, you can run it with `--compiled-script-path` like the example below:

```shell
endless move run-script --compiled-script-path /opt/git/developer-docs/apps/docusaurus/static/move-examples/scripts/transfer_half/script.mv
```

Similarly, if it's not compiled, just use `--script-path`

```shell
endless move run-script --script-path ./sources/transfer_half.move
```


---

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