You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements a time-locked escrow system for Fungible Assets (FAs). A lockup creator sets up an escrow, users deposit funds with optional time locks, and funds can be claimed by the creator, returned to users, or withdrawn by users after the lock period expires. Demonstrates Move 2 enum types, pattern matching, and dispatchable FA transfers.
Difficulty
Advanced
Concepts Demonstrated
Enum types (Move 2): Lockup and Escrow use enum variants for different lockup strategies
Pattern matching (Move 2): match expressions to handle different escrow types
Dispatchable fungible assets: dispatchable_fungible_asset::transfer for FA-agnostic transfers
Fungible stores: Creating standalone FungibleStore objects for escrow
SmartTable: Mapping EscrowKey to escrow object addresses
Object lifecycle: Creating, using, and deleting objects with storage deposit recovery
Time-based conditions: Using timestamp::now_seconds() for lockup enforcement
Key Types
Type
Kind
Purpose
LockupRef
struct
Stored in creator's account; points to the Lockup object
Lockup
enum (ST variant)
Holds escrow mappings, creator info, and control refs
EscrowKey
enum (FAPerUser variant)
Composite key: FA metadata + user address
Escrow
enum (Simple, TimeUnlock)
Per-user escrow with optional time lock
Key Functions
Function
Visibility
Description
initialize_lockup
public entry
Creates a new lockup for the caller
escrow_funds_with_no_lockup
public entry
Deposits funds without a time lock
escrow_funds_with_time
public entry
Deposits funds with a time lock
claim_escrow
public entry
Creator claims escrowed funds
return_user_funds
public entry
Creator returns funds to a user
return_my_funds
public entry
User withdraws their own funds (after lock expires)