Sui Project Structure

Sui Module and Package

  • A Sui module is a set of functions and types packed together which the developer publishes under a specific address

  • The Sui standard library is published under the 0x2 address, while user-deployed modules are published under a pseudorandom address assigned by the Sui Move VM

  • Module starts with the module keyword, which is followed by the module name and curly braces - inside them, module contents are placed:

    #![allow(unused)]
    fn main() {
    module hello_world::hello_world {
        // module contents
    }
    }
  • Published modules are immutable objects in Sui; an immutable object is an object that can never be mutated, transferred, or deleted. Because of this immutability, the object is not owned by anyone, and hence it can be used by anyone

  • A Move package is just a collection of modules with a manifest file called Move.toml

Initializing a Sui Move Package

Use the following Sui CLI command to start a skeleton Sui package:

sui move new <PACKAGE NAME>

For our example in this unit, we will start a Hello World project:

sui move new hello_world

This creates:

  • the project root folder hello_world
  • the Move.toml manifest file
  • the sources subfolder, which will contain Sui Move smart contract source files

Move.toml Manifest Structure

Move.toml is the manifest file of a package and is automatically generated in the project root folder.

Move.toml consists of three sections:

  • [package] Defines the name and version number of the package
  • [dependencies] Defines other packages that this package depends on, such as the Sui standard library; other third-party dependencies should be added here as well
  • [addresses] Defines aliases for addresses in the package source code

Sample Move.toml File

This is the Move.toml generated by the Sui CLI with the package name hello_world:

#![allow(unused)]
fn main() {
[package]
name = "hello_world"
version = "0.0.1"
edition = "2024.beta"


[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }


[addresses]
hello_world =  "0x0"
}

We see that the Sui standard library dependency here is defined using a GitHub repo, but it can also point to a local binary using its relative or absolute file path, for example:

#![allow(unused)]
fn main() {
[dependencies]
Sui = { local = "../sui/crates/sui-framework/packages/sui-framework" } 
}

Sui Module and Package Naming

  • Sui Move module and package naming convention use snake casing, i.e. this_is_snake_casing.

  • A Sui module name uses the Rust path separator :: to divide the package name and the module name, examples:

    1. unit_one::hello_world - hello_world module in unit_one package
    2. capy::capy - capy module in capy package
  • For more information on Move naming conventions, please check the style section of the Move book.