What You’ll Build
You’ll create a simple package that defines aSword object with magical properties - a common starting point for understanding Sui’s object model.
Prerequisites
- Set up your development environment
- Basic understanding of programming concepts
Create a New Package
Build Your Package
Compile the Move code:Add Tests
Createsources/sword_tests.move:
sword.move for testing:
Run Tests
Execute the test suite:Publish to Testnet
Interact with Your Package
Call thenew_sword function:
Understanding Key Concepts
Abilities
key: Object can be used as a key in global storage (has UID)store: Object can be stored inside other objectscopy: Object can be copieddrop: Object can be dropped/destroyed implicitly
Module Initializer
Theinit function runs once when the package is published:
Object Creation
All objects on Sui have a unique ID:Next Steps
- Learn about testing Move code
- Understand Move package structure
- Create custom objects
- Explore more examples
Common Issues
Build errors
If you see “unresolved import” errors, ensure dependencies inMove.toml are correct.
Test failures
Usesui move test --verbose for detailed output.