Skip to main content

Move Basics

Master the fundamentals of the Move programming language.

Module Structure

Every Move file defines a module:
  • my_package - Package name (from Move.toml)
  • my_module - Module name (matches filename)

Basic Types

Primitive Types

Vectors

Functions

Basic Function

Public Functions

Entry Functions

Entry functions can be called directly from transactions:

Structs

Define custom types with structs:

Creating Structs

Abilities

Structs can have special abilities:

References

Immutable References

Mutable References

Control Flow

If Expressions

While Loops

Error Handling

Use assert! for validation:

Common Patterns

Option Type

Generics

Complete Example

Here’s a complete module showcasing basic concepts:

Next Steps

You’ve covered the Move basics. Next, build a frontend that interacts with your contracts.

Frontend Workshop

Build a React dApp with the Sui dApp Kit