Learn Move - 10 Code Examples & CST Typing Practice Test
Move is a safe, resource-oriented programming language originally developed for the Libra (now Diem) blockchain. It focuses on correctness, security, and formal verification, particularly for digital assets and smart contracts.
Learn MOVE with Real Code Examples
Updated Nov 25, 2025
Code Sample Descriptions
Simple Move Counter Module
module 0x1::Counter {
resource struct Counter { value: u64 }
public fun create(): Counter {
Counter { value: 0 }
}
public fun increment(counter: &mut Counter) {
counter.value = counter.value + 1
}
public fun reset(counter: &mut Counter) {
counter.value = 0
}
}
Basic counter resource with increment and reset.
Move Bank Account Module
module 0x1::Bank {
resource struct Account { balance: u64 }
public fun create(): Account {
Account { balance: 0 }
}
public fun deposit(acc: &mut Account, amount: u64) {
acc.balance = acc.balance + amount
}
public fun withdraw(acc: &mut Account, amount: u64) {
acc.balance = acc.balance - amount
}
}
A simple bank account resource with deposit and withdraw.
Move Store Name Module
module 0x1::NameStore {
resource struct Name { value: vector<u8> }
public fun set_name(name: vector<u8>): Name {
Name { value: name }
}
public fun update(n: &mut Name, new_name: vector<u8>) {
n.value = new_name
}
}
A resource storing a user's name on-chain.
Move Owned Counter
module 0x1::OwnedCounter {
resource struct Counter { owner: address, value: u64 }
public fun create(owner: address): Counter {
Counter { owner, value: 0 }
}
public fun inc(c: &mut Counter, caller: address) {
assert!(caller == c.owner, 1)
c.value = c.value + 1
}
}
Adds ownership to a counter resource.
Move Points Reward Module
module 0x1::Points {
resource struct Score { value: u64 }
public fun new(): Score {
Score { value: 0 }
}
public fun add(score: &mut Score, pts: u64) {
score.value = score.value + pts
}
}
Simple reward points module.
Move Boolean Flag Module
module 0x1::Flag {
resource struct Flag { enabled: bool }
public fun new(): Flag {
Flag { enabled: false }
}
public fun toggle(f: &mut Flag) {
f.enabled = !f.enabled
}
}
Stores and toggles a boolean value.
Move Simple Map Module
module 0x1::PairStore {
resource struct Pair { a: u64, b: u64 }
public fun create(a: u64, b: u64): Pair {
Pair { a, b }
}
public fun update(p: &mut Pair, a: u64, b: u64) {
p.a = a
p.b = b
}
}
Stores a pair of u64 values.
Move Token Balance
module 0x1::Token {
resource struct Balance { amount: u64 }
public fun mint(): Balance {
Balance { amount: 100 }
}
public fun add(b: &mut Balance, amt: u64) {
b.amount = b.amount + amt
}
}
A minimal token balance resource.
Move Access Control Example
module 0x1::Access {
resource struct Data { owner: address, value: u64 }
public fun create(owner: address): Data {
Data { owner, value: 0 }
}
public fun set(d: &mut Data, caller: address, v: u64) {
assert!(caller == d.owner, 2)
d.value = v
}
}
Move module enforcing owner-only updates.
Move Event Emission Example
module 0x1::Events {
struct IncrementEvent has drop { amount: u64 }
resource struct Counter { value: u64, events: event::EventHandle<IncrementEvent> }
public fun create(): Counter {
Counter { value: 0, events: event::new_event_handle<IncrementEvent>(0x1) }
}
public fun inc(c: &mut Counter) {
c.value = c.value + 1
event::emit_event(&mut c.events, IncrementEvent { amount: c.value })
}
}
Module showing basic event emission.
Frequently Asked Questions about Move
What is Move?
Move is a safe, resource-oriented programming language originally developed for the Libra (now Diem) blockchain. It focuses on correctness, security, and formal verification, particularly for digital assets and smart contracts.
What are the primary use cases for Move?
Digital assets and token management. NFT minting and transfers. Safe financial transactions. Blockchain governance modules. Custom resource-oriented logic
What are the strengths of Move?
Safe resource handling. Formal verification friendly. Explicit ownership semantics. Predictable execution. Suitable for asset-heavy applications
What are the limitations of Move?
Smaller developer ecosystem than Solidity. Limited tooling and libraries. Ecosystem mainly centered on Aptos and Sui. Learning curve for resource-oriented programming. Less general-purpose than other languages
How can I practice Move typing speed?
CodeSpeedTest offers 10+ real Move code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.