<commit_before>---
title: "Your First Move Module"
slug: "first-move-module"
sidebar_position: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Your First Move Module

This tutorial details how to compile, test, publish and interact with Move Modules on the Aptos Blockchain. The steps are:

1. [Install the CLI from Git][install_cli]
2. Compile and test a Move module
3. Publish a Move module to the Aptos Blockchain
4. Interact with a Move Module
5. Understand the code


## Prepare the CLI environment

After installing the CLI from Git, prepare your environment for interacting with Aptos by creating and funding an account. Begin by starting a new terminal.

1. Initialize a new local account: `aptos init`. This will output:
```
Enter your rest endpoint [Current: None | No input: https://fullnode.devnet.aptoslabs.com/v1]

No rest url given, using https://fullnode.devnet.aptoslabs.com/v1...
Enter your faucet endpoint [Current: None | No input: https://faucet.devnet.aptoslabs.com | 'skip' to not use a faucet]

No faucet url given, using https://faucet.devnet.aptoslabs.com...
Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)]

No key given, generating key...
Account a345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a doesn't exist, creating it and funding it with 10000 coins
Aptos is now set up for account <KEY>!  Run `aptos help` for more information about commands
{
  "Result": "Success"
}
```
2. Now fund this account: `aptos account fund-with-faucet --account <KEY>`
```
{
  "Result": "Added 10000 coins to account <KEY>"
}
```

## Compile and test the module

There are many example Move modules in the [aptos-core/aptos-move/move-examples](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples) directory.

Load a terminal and change directories into the `hello_blockchain` directory: `cd aptos-core/aptos-move/move-examples`.

To build the module run: `aptos move build --named-addresses hello_blockchain=0xa345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a`.
To test the module run: `aptos move test --named-addresses hello_blockchain=0xa345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a`.

The CLI entry must contain `--named-addresses` because the `Move.toml` file leaves this as undefined:

```toml
[addresses]
hello_blockchain = "_"
```<commit_msg>Update first-move-module.md<commit_after>---
title: "Your First Move Module"
slug: "first-move-module"
sidebar_position: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Your First Move Module

This tutorial details how to compile, test, publish and interact with Move Modules on the Aptos Blockchain. The steps are:

1. [Install the CLI from Git][install_cli]
2. Compile and test a Move module
3. Publish a Move module to the Aptos Blockchain
4. Interact with a Move Module
5. Understand the code


## Prepare the CLI environment

After installing the CLI from Git, prepare your environment for interacting with Aptos by creating and funding an account. Begin by starting a new terminal.

1. Initialize a new local account: `aptos init`. This will output:
```
Enter your rest endpoint [Current: None | No input: https://fullnode.devnet.aptoslabs.com/v1]

No rest url given, using https://fullnode.devnet.aptoslabs.com/v1...
Enter your faucet endpoint [Current: None | No input: https://faucet.devnet.aptoslabs.com | 'skip' to not use a faucet]

No faucet url given, using https://faucet.devnet.aptoslabs.com...
Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)]

No key given, generating key...
Account a345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a doesn't exist, creating it and funding it with 10000 coins
Aptos is now set up for account <KEY>!  Run `aptos help` for more information about commands
{
  "Result": "Success"
}
```
2. Now fund this account: `aptos account fund-with-faucet --account <KEY>`
```
{
  "Result": "Added 10000 coins to account <KEY>"
}
```

## Compile and test the module

There are many example Move modules in the [aptos-core/aptos-move/move-examples](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples) directory.

Load a terminal and change directories into the `hello_blockchain` directory: `cd aptos-core/aptos-move/move-examples`.

To compile the module run: `aptos move compile --named-addresses hello_blockchain=0xa345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a`.
To test the module run: `aptos move test --named-addresses hello_blockchain=0xa345dbfb0c94416589721360f207dcc92ecfe4f06d8ddc1c286f569d59721e5a`.

The CLI entry must contain `--named-addresses` because the `Move.toml` file leaves this as undefined:

```toml
[addresses]
hello_blockchain = "_"
```
{'fraction_non_alphanumeric': 0.09627964022894522, 'fraction_numerical': 0.05846279640228945, 'mean_word_length': 4.749706227967097, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5559678', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1595, 'n_words': 575}