Package Anatomy
A typical Move package has this structure:Move.toml Manifest
TheMove.toml file defines package metadata, dependencies, and addresses.
Basic Structure
From thecoin example in the Sui codebase:
Package Section
Dependencies
Local dependencies
Git dependencies
Address Aliases
Define named addresses for your package:Module Structure
Modules are the building blocks of Move packages.Basic Module
Module Initializer
Theinit function runs once when the package is published:
Organizing Code
Single vs Multiple Modules
Single module - Simple 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
Fromexamples/move/coin:
my_coin.move
Building Packages
Build command
Build with docs
Check dependencies
Publishing Packages
Publish to network
Publish with custom addresses
UpdateMove.toml:
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