Skip to main content
This comprehensive guide walks you through the complete process of creating, compiling, deploying, and interacting with a Move module from scratch. You’ll build a simple “Hello World” module that demonstrates core Move concepts and deployment workflows.
Before starting, ensure you have set up your development environment, created an account, and funded it with testnet tokens. Follow the Setting Up Your Development Environment guide if you haven’t completed these prerequisites.

Overview

In this tutorial, you’ll learn to:
  • Create a new Move project and module structure
  • Compile Move source code into bytecode
  • Deploy your module to the blockchain
  • Interact with your deployed module through transactions and queries
This guide supports both Initia L1 and Move rollup development. Code examples are provided for CLI tools and InitiaJS SDK to accommodate different development preferences.

What You’ll Build

You’ll create a simple message storage module with two functions:
  • save_message: Store a string message in the user’s account
  • view_message: Retrieve the stored message from an account
1

Set Up Environment Variables

Configure your development environment with the necessary network parameters.

Network Parameters Reference

Find network-specific values in our Networks Documentation for Initia L1, or the Initia Registry for Move rollups.
2

Create Your Project Structure

Start by creating a new directory and initializing it as a Move project.

Create Project Directory

Initialize Move Package

Initialize your directory as a Move package, which creates the necessary project structure.

Understanding the Project Structure

Your project now contains these essential components:
The Move.toml file serves as your package’s configuration center, containing:
  • Package metadata: name, version, and description
  • Dependencies: external packages your project requires
  • Address mappings: logical names mapped to blockchain addresses
  • Build settings: compilation options and flags
The sources directory is where you’ll write your Move smart contracts:
  • Contains all .move source files
  • Organizes your module implementations
  • Houses the core business logic of your application
3

Write Your Move Module

Create your first Move module with message storage functionality.

Create the Module File

Create a new file called hello_world.move in the sources directory:
hello_world.move

Understanding the Code

Declares a module named hello_world under the hello address namespace. This establishes the module’s identity on the blockchain.
Defines a Message resource with the key ability, allowing it to be stored in account storage. Resources are Move’s way of representing owned data.
Entry functions can be called directly via transactions. The &signer parameter represents the transaction sender’s authority.
View functions are read-only operations marked with #[view]. The acquires clause indicates this function accesses the Message resource.
4

Configure and Compile Your Module

Set up your module’s deployment address and compile the source code.

Get Your Deployment Address

First, retrieve your account’s hexadecimal address for the Move.toml configuration:
Expected output:

Configure Move.toml

Update your Move.toml file with the deployment address and dependencies:
Move.toml
Address Configuration Ensure you add the “0x” prefix to your address and replace the example address with your actual deployment address. This determines where your module will be deployed on the blockchain.

Compile Your Module

Build your Move module into deployable bytecode:
Successful compilation output:

Verify Build Output

After compilation, you’ll find a new build/ directory containing:
  • Compiled bytecode modules
  • Dependency information
  • Build artifacts and metadata
5

Deploy Your Module

Deploy your compiled module to the blockchain network.

Understanding Deployment Options

The --upgrade-policy flag controls future module updates:
  • COMPATIBLE: Allows backward-compatible upgrades that don’t break existing functionality
  • IMMUTABLE: Prevents any future modifications to the deployed module
Select based on whether you anticipate needing to update your module after deployment.
Gas settings control transaction costs:
  • --gas auto: Automatically estimates required gas
  • --gas-adjustment 1.5: Adds 50% buffer to gas estimate
  • --gas-prices: Sets the price per unit of gas
These settings help ensure your transaction succeeds while managing costs.
Successful Deployment Once deployed successfully, your module will be stored at the address specified in your Move.toml file and can be interacted with by any user on the network.
6

Interact with Your Deployed Module

Test your module by executing transactions and querying stored data.

Execute Transactions

Call your module’s save_message function to store data on-chain:

Query Stored Data

Retrieve the message you just saved using the view_message function:

Expected Results

If both operations succeed, your query should return:
Success! You’ve successfully created, deployed, and interacted with your first Move module. The message is now permanently stored on the blockchain and can be retrieved by anyone.