Getting Started with Sui Move
An introduction to the Move programming language and smart contract development on Sui blockchain.
•6 min read
const{Fragment:e,jsx:n,jsxs:t}=arguments[0];function _createMdxContent(r){const c={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...r.components};return t(e,{children:[n(c.h1,{children:"Why Move?"}),"\n",n(c.p,{children:"Move is a platform-agnostic blockchain language inspired by Rust. It treats tokens and assets as first-class resources, which makes it incredibly safe for DeFi applications."}),"\n",n(c.h2,{children:"Key Concepts"}),"\n",n(c.h3,{children:"Resources"}),"\n",n(c.p,{children:"In Move, a struct cannot be copied or dropped by default. This linear type system ensures that assets aren't accidentally duplicated or destroyed."}),"\n",n(c.pre,{children:n(c.code,{className:"language-move",children:"module 0x1::BasicCoin {\n struct Coin has key, store {\n id: UID,\n value: u64,\n }\n\n public fun transfer(coin: Coin, recipient: address) {\n transfer::public_transfer(coin, recipient);\n }\n}\n"})}),"\n",n(c.h3,{children:"Objects in Sui"}),"\n",n(c.p,{children:"Sui takes Move's object-centric model further. Everything on Sui is an object with a unique ID. This allows for parallel transaction execution, making Sui incredibly fast."}),"\n",t(c.ol,{children:["\n",t(c.li,{children:[n(c.strong,{children:"Owned Objects"}),": Owned by a specific address."]}),"\n",t(c.li,{children:[n(c.strong,{children:"Shared Objects"}),": Can be accessed by multiple transactions."]}),"\n",t(c.li,{children:[n(c.strong,{children:"Immutable Objects"}),": Cannot be changed once created."]}),"\n"]}),"\n",n(c.h2,{children:"Your First Contract"}),"\n",n(c.p,{children:"Let's build a simple counter."}),"\n",n(c.pre,{children:n(c.code,{className:"language-move",children:"module examples::counter {\n use sui::object::{Self, UID};\n use sui::transfer;\n use sui::tx_context::{Self, TxContext};\n\n struct Counter has key {\n id: UID,\n value: u64\n }\n\n public entry fun create(ctx: &mut TxContext) {\n let counter = Counter {\n id: object::new(ctx),\n value: 0\n };\n transfer::share_object(counter);\n }\n\n public entry fun increment(counter: &mut Counter) {\n counter.value = counter.value + 1;\n }\n}\n"})}),"\n",n(c.h2,{children:"Next Steps"}),"\n",t(c.p,{children:["To get started, install the Sui CLI and try the ",n(c.a,{href:"https://github.com/sui-foundation/sui-move-intro-course",children:"Sui Move Intro Course"}),"."]})]})}return{default:function(e={}){const{wrapper:t}=e.components||{};return t?n(t,{...e,children:n(_createMdxContent,{...e})}):_createMdxContent(e)}};
Web3SuiMoveSmart Contracts
Subscribe to Newsletter
Get the latest updates on AI, Web3, and Tech.