1. Home
  2. /
  3. Move
  4. /
  5. Event Emission Example

Event Emission Example - Move Typing CST Test

Loading…

Event Emission Example — Move Code

Module showing basic event emission.

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 })
	}
}

Move Language Guide

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.

Primary Use Cases

  • ▸Digital assets and token management
  • ▸NFT minting and transfers
  • ▸Safe financial transactions
  • ▸Blockchain governance modules
  • ▸Custom resource-oriented logic

Notable Features

  • ▸Resource types prevent accidental duplication or loss
  • ▸Module-based architecture for composability
  • ▸Formal verification support
  • ▸Strong static typing
  • ▸Explicit transaction scripts

Origin & Creator

Move was created by the Libra (Diem) team at Facebook around 2019. It evolved to provide safe resource management for blockchain assets and has been adopted by several new-generation blockchains.

Industrial Note

Move is highly focused on financial and asset management applications in blockchains, especially where strict ownership rules and resource safety are required. It’s ideal for token systems, NFT platforms, and DeFi primitives.

Quick Explain

  • ▸Move enforces resource types - assets cannot be copied or lost unintentionally.
  • ▸It has strong static typing and a formal verification model.
  • ▸Designed to manage digital assets safely on blockchain networks.
  • ▸Supports modules and scripts for reusable and composable logic.
  • ▸Used by Diem, Aptos, Sui, and other blockchain ecosystems.

Core Features

  • ▸Modules and scripts
  • ▸Structs as first-class resources
  • ▸Typed references and borrowing
  • ▸Access control for resources
  • ▸Compatibility with Move Virtual Machine (MVM)

Learning Path

  • ▸Learn Rust basics
  • ▸Understand blockchain & VM concepts
  • ▸Learn Move syntax and modules
  • ▸Write and test resource modules
  • ▸Practice formal verification and transactions

Practical Examples

  • ▸Simple token module
  • ▸NFT minting and transfer
  • ▸Payment channels
  • ▸Multi-signature wallets
  • ▸Resource-based DeFi primitives

Comparisons

  • ▸Move vs Solidity: Move is resource-safe; Solidity is feature-rich
  • ▸Move vs Vyper: Move has ownership semantics; Vyper emphasizes simplicity
  • ▸Move vs Rust: Move is resource-focused for blockchain; Rust is general-purpose
  • ▸Move vs Cairo: Move targets asset-safe chains; Cairo targets STARK proofs
  • ▸Move vs JavaScript: Move is strongly typed and blockchain-safe

Strengths

  • ▸Safe resource handling
  • ▸Formal verification friendly
  • ▸Explicit ownership semantics
  • ▸Predictable execution
  • ▸Suitable for asset-heavy applications

Limitations

  • ▸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

When NOT to Use

  • ▸General-purpose programming outside blockchain
  • ▸Projects without resource/asset management
  • ▸Ecosystems not supporting Move VM
  • ▸Highly interactive front-end logic
  • ▸Complex multi-chain systems not using Aptos/Sui

Cheat Sheet

  • ▸resource struct Coin { ... }
  • ▸module Token { ... }
  • ▸public(script) fun transfer(...) { ... }
  • ▸let r = &mut resource_var;
  • ▸move_to(account, resource_var)

FAQ

  • ▸Is Move safe for digital assets?
  • ▸Yes - ownership semantics prevent accidental loss.
  • ▸Can Move be used outside Aptos/Sui?
  • ▸Limited - requires Move VM-compatible chain.
  • ▸Does Move support inheritance?
  • ▸No - uses modules and resource composition.
  • ▸Is Move faster than Solidity?
  • ▸Execution is predictable; speed depends on VM.
  • ▸Can Move interact with Solidity contracts?
  • ▸Directly no; requires cross-chain bridges or wrappers.

30-Day Skill Plan

  • ▸Week 1: Move syntax & types
  • ▸Week 2: Modules & scripts
  • ▸Week 3: Resources & references
  • ▸Week 4: Testing & prover
  • ▸Week 5: Deploy and integrate on Aptos/Sui

Final Summary

  • ▸Move is a resource-oriented blockchain language.
  • ▸Safe, formal-verifiable, and asset-focused.
  • ▸Modules and scripts encapsulate logic.
  • ▸Strong static typing and ownership rules.
  • ▸Ideal for token, NFT, and DeFi applications.

Project Structure

  • ▸sources/ - Move modules
  • ▸tests/ - unit and prover tests
  • ▸scripts/ - transaction scripts
  • ▸build/ - compiled bytecode
  • ▸Move.toml - project config

Monetization

  • ▸Deploy token modules
  • ▸Build NFT platforms
  • ▸Offer Move auditing services
  • ▸Consult on DeFi Move designs
  • ▸Sell resource-safe smart contracts

Productivity Tips

  • ▸Keep modules small
  • ▸Use Move Prover frequently
  • ▸Write composable scripts
  • ▸Document ownership flows
  • ▸Leverage testnet sandboxes

Basic Concepts

  • ▸Resources - cannot be copied or discarded
  • ▸Modules - reusable code units
  • ▸Scripts - executable transactions
  • ▸Structs with resource semantics
  • ▸Functions with strict type safety

Official Docs

  • ▸https://move-lang.dev
  • ▸https://github.com/move-language/move

More Move Typing Exercises

Simple Move Counter ModuleMove Bank Account ModuleMove Store Name ModuleMove Owned CounterMove Points Reward ModuleMove Boolean Flag ModuleMove Simple Map ModuleMove Token BalanceMove Access Control Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher