Skip to main content
Move packages are the fundamental unit of code organization on Sui. Understanding their structure is essential for building well-organized smart contracts.

Package Anatomy

A typical Move package has this structure:

Move.toml Manifest

The Move.toml file defines package metadata, dependencies, and addresses.

Basic Structure

From the coin example in the Sui codebase:

Package Section

Dependencies

Local dependencies

Git dependencies

Address Aliases

Define named addresses for your package:
In your code:

Module Structure

Modules are the building blocks of Move packages.

Basic Module

Module Initializer

The init function runs once when the package is published:

Organizing Code

Single vs Multiple Modules

Single module - Simple packages:
Multiple modules - Complex packages:

Module Visibility

Public modules

Expose functionality to other packages:

Internal modules

Keep implementation details private:

Friend Declarations

Allow specific modules to access package-private functions:

Code Organization Patterns

Pattern 1: Core + Extensions

Pattern 2: Feature-Based

Pattern 3: Layer-Based

Real Example: Coin Package

From examples/move/coin:

my_coin.move

Building Packages

Build command

Build with docs

Check dependencies

Publishing Packages

Publish to network

Publish with custom addresses

Update Move.toml:
Then publish:

Package Upgrades

Sui supports package upgrades. See the Upgrade Packages guide for details.

Upgrade policies

  • Compatible: Only add new functions/structs
  • Additive: Can add abilities to structs
  • Incompatible: Breaking changes

Best Practices

1. One concern per module

Keep modules focused:

2. Use clear naming

3. Organize imports

4. Document public APIs

5. Version your packages

Next Steps