Skip to main content
This guide walks you through creating, building, testing, and publishing your first Move package on Sui.

What You’ll Build

You’ll create a simple package that defines a Sword object with magical properties - a common starting point for understanding Sui’s object model.

Prerequisites

Create a New Package

Build Your Package

Compile the Move code:
Successful output:

Add Tests

Create sources/sword_tests.move:
Note: Add this helper to sword.move for testing:

Run Tests

Execute the test suite:
Expected output:

Publish to Testnet

Interact with Your Package

Call the new_sword function:
This creates a sword with magic=42 and strength=7.

Understanding Key Concepts

Abilities

  • key: Object can be used as a key in global storage (has UID)
  • store: Object can be stored inside other objects
  • copy: Object can be copied
  • drop: Object can be dropped/destroyed implicitly

Module Initializer

The init function runs once when the package is published:

Object Creation

All objects on Sui have a unique ID:

Next Steps

Common Issues

Build errors

If you see “unresolved import” errors, ensure dependencies in Move.toml are correct.

Test failures

Use sui move test --verbose for detailed output.

Publication fails

Check you have sufficient gas: