Dive into Move on Sui
Sui
Agenda
Introduction
Writing Contracts with Move
Quick Tips

Web Evolution

"Human Evolution" by acidpix is licensed under CC BY 2.0 .
Digitals
To Read
To Write
To Own
Owner's manual

https://en.wikipedia.org/wiki/Owner%27s_manual
public domain image
Owner's manual
https://support.apple.com/en-asia/guide/iphone/welcome/ios

To Own
Should be easy
Object Model
32-byte global UID
8-byte version
32-byte tx digest
32-byte owner
https://docs.sui.io/concepts/object-model#object-metadata
Sui
Who is Sui ?
An Infrastructure for Gaming and more
SuiPlay0X1
Programmable Storage

How to use Sui?
Move
Expressive by nature
Intuitive by design
Secure by default
For the things we have to learn before we can do them, we learn by doing them.
- Aristotle
let's Move on
Move
Warranty Card

信君 劉's photo, licensed as CC BY-SA 2.0
-
Expiry date
-
Serial number
-
Stamp from issuer
-
Repairing records
Gororo Warranty

Structs

The global object knows who has owner's cap
The only cap for admin
The warranty cards
The records for reparing
Init Function

The global object knows who own this brand
The only cap for admin

The init exec only once when contract deploy
The share_object let the instance global
Entry Functions

The global object
The cap for admin only
entry functions can be called from the package on Sui
Use cap to do access control
Scenario Test

Set up accounts will use in the test
The admin begin the test, so he will have cap in the scenario
The init with scenario context
Scenario test

Use take_shared to get the global object
Use take_from_sender to get the object from the caller
Use return_shared and return_to_sender to return objecs
Scenario Test

The first buyer sells the gororo to the second buyer and transfers the warranty card to him
The lamp of gororo is broken, so second buyer puts the bike to shop and send warranty card to technician
The lamp of gororo is repaired, so technician add repairing record and send warranty card back
debug::print to check
let's Move on
Move

Coupon
-
Special discount
-
Claim in the web
-
Leveraging the power of Sui
Boba Coupon
git clone https://github.com/yanganto/BobaCoupon

Move.toml
Leverage other open source project on Sui
to build your campaign

Structs

A global object to know who claim the coupon, and which one isused
The coupons
Public Functions

reply on Card in gororo package
Use public function in_repairing from gororo package
Functions
Init fun
public entry fun
public fun
Who and When these fun called?
Scenario Test

Setup warranty to Alice for test
The init from gororo
The init from boba
Scenario Test

claim coupon
redeem it
Scenario Test

Expect the scenario will fail with specific error code
Scenario Test

Expect error because technician is not a real owner
It's your turn
POC quick with Template


Open PR & Use CI

-
Customized Sui for CI
-
Run test in sendbox
-
Ideal first, No wallet
-
Show test coverage


Repairing Service
-
User comment and repairing ranking
-
Check warranty do different service
-
Auto claim the Boba coupon before user in repairing
Tim Vrtiska's photo, licensed as CC BY-ND 2.0

Quick Tips When Build
Quick Tips When Build
Test and build locally
sui move new
sui move build
sui move test
curl --proto '=https' --tlsv1.2 -sSf \
https://sh.rustup.rs | sh
git clone https://github.com/MystenLabs/sui
cargo build
Binary in ./target/debug/sui
Install Rust & Build
How to stet up Display



Where is package ID


sui client publish
Move.lock
STDOUT
Programmable Transaction Blocks
- aka PTB
- 1,024 unique operations in a single execution
- cheaper gas fees

Thank you
Q & A

Materials
-
https://github.com/sui-foundation/2025-Sui-Hacker-House-template
From to Move
Move

Quick Tips
use test_with::env;

use std::net::TcpStream;
use std::net;
use sui::vec_sec::VecSec;
use sui::vec_sec::singleton;
use 0x2::vec_set;
Move
Move
use Crate::{module, fn, struct, trait, macro fn}...
use Package::module::{fun, struct}
Always the same layering namespace
Package is an address, alias set in Move.toml
struct Example {number: i32}
impl Example {
fn boo() { println!("boo! Example::boo() was called!"); }
fn answer(&mut self) { self.number += 42; }
fn get_number(&self) -> i32 { self.number }
}

Move
Move
Impl some functionality for a type.

Method Aliases
trait Animal {
fn new(name: &'static str) -> Self;
fn name(&self) -> &'static str;
fn talk(&self) { println!("{} says {}", self.name(), self.noise());}
fn eat(&mut self);
}
impl Animal for Sheep {
... // fn can be overwritten
}

Move
Move
Traits a collection of methods defined for an unknown type
4 abilities - copy, drop, key, store
Ability define how types behave
Drop is optional
- fn
- public fn
- async fn
- unsafe fn
- macro!

Move
Move
fun
init fun
entry fun
public fun
macro fun
There is no async, unsafe in Move, and we need focus on when and who to call the function
- Result<T, E>
- Option<T>
- Future<Output=T>
- T
- ()

Move
Move
Option<T>
T
u64
()
There is no Result, Future in Move, and we handle error as u64
- cargo new
- cargo build
- cargo test
- cargo publish

Move
Move
Storage package on chain coats Sui,
so a wallet need to setup before publish
sui move new
sui move build
sui move test
sui client publish
Sponsored PTBs

let's Move on
Move
CEO from
TW
Evan Cheng
Gororo Warranty

lord enfield's photo, licensed as CC BY 2.0
Dive Into Move on Sui
By Antonio Yang
Dive Into Move on Sui
- 199