Sui.

Пост

Поделитесь своими знаниями.

article banner.
D’versacy .
Aug 25, 2025
Статья

Getting started with the Sui SDK — Environment, first project, and common pitfalls 🚀

Problem: You want to start building on Sui quickly but don’t know which SDK to pick, how to set up your environment, or how to create your first Move-backed app with a working local dev loop.

Goal: Give a clear, minimal, reproducible local setup, walk through a first TypeScript + Move project, and point out common pitfalls — with fixes — so you can ship confidently. ✨


1) Choose an SDK & language 🧭

  • TypeScript / JavaScript — the go-to for dApp frontends and most tooling (RPC clients, transaction builders, wallet adapters).
  • Rust — good for native tooling, CLI helpers, or backend components that need low-level control.
  • Move — the smart-contract language used on Sui; you’ll write packages in Move and deploy them with the CLI.

Recommendation: If you’re building a user-facing dApp, start with TypeScript for the frontend and add Move modules for your on-chain logic. Use Rust only if you need native performance or tooling.


2) Pre-requisites (local machine) ✅

Make sure you have:

  1. Node.js LTS (≥ 18) and npm or yarn.
  2. Rust toolchain (rustup) — if you’ll compile Move packages or use Rust tooling.
  3. Sui CLI (optional but recommended) — for local devnet, account management, build & publish of Move packages.
  4. A code editor like VS Code with Move & TypeScript extensions for syntax highlighting and linting.

Quick tip: keep node, rust, and sui versions reasonably aligned — mismatched versions are a common source of friction.


3) Install Sui CLI (summary) ⚙️

On Unix-like systems (example pattern):

sh <(curl -sSL https://your-sui-install-script)
# then verify
sui --version

Use the official Sui repo install instructions when available. If the script doesn’t exist, follow the repo README to build from source.


4) Initialize a TypeScript dApp — minimal reproducible project 🧩

  1. Create project folder:
mkdir sui-dapp && cd sui-dapp
npm init -y
  1. Install the Sui TypeScript SDK:
npm i @mysten/sui.js

(Package name may vary with official registry — adjust if necessary.)

  1. Create index.ts:
import { JsonRpcProvider, devnetConnection } from "@mysten/sui.js";

const provider = new JsonRpcProvider(devnetConnection);

async function main(){
  const version = await provider.getRpcApiVersion();
  console.log("RPC version:", version);
}

main().catch(console.error);
  1. Run it with ts-node or compile with tsc then node.

5) Use a local Sui network for fast feedback 🧪

  • Start a local devnet with the Sui CLI (or use a community devnet). Local networks make iteration fast and deterministic.
  • Create funded dev accounts using CLI commands or faucet scripts so you can sign and submit transactions while developing.

Why local devnet? Faster feedback loops, deterministic tests, and safe experimentation without spending real assets.


6) Common pitfalls & fixes — the quick troubleshooting guide 🛠️

ProblemSymptomQuick Fix
Version mismatchTransactions fail or RPC calls errorAlign SDK & CLI versions; upgrade/downgrade to matching releases
CORS / wallet connectionWallet won’t connect in browserServe app on http://localhost; confirm wallet supports chosen network
Gas confusionsReverts with “insufficient gas”Include a gas coin object and set a sensible gas budget; simulate when possible
Object ownership errorsMove reverts, “object not found” or “not owner”Verify Move function signatures, input object refs, and ownership rules
Missing artifacts/ABI mismatchFrontend expects different typesAlways use the ABI from the exact sui move build output used in deploy

Extra troubleshooting tips

  • Simulate transactions before asking users to sign (where SDK supports it).
  • Emit events in Move to make runtime flows easier to debug from the frontend.
  • Keep a mapping of Move abort codes → user-friendly messages for better UX.

7) Next steps — what to build after this guide 🔭

  • Create a minimal UI that:

    • Connects to a wallet adapter,
    • Signs a transaction,
    • Displays owned objects and events.
  • Learn Move basics: modules, resources, moveCall semantics, and how to compile & publish with sui move build / sui move publish.

  • Add tests: sui move test for Move unit tests and Jest/Mocha integration tests using a local devnet.


Quick checklist before you commit code ✅

  • Node, Rust, and Sui CLI installed and versions checked
  • Local devnet running and seeded with dev accounts
  • Frontend using the ABI/artifacts from the exact build used in Move deployment
  • Transaction flows simulate successfully locally
  • Meaningful error messages mapped to Move aborts
  • SDKs and Developer Tools
1
Поделиться
Комментарии
.

Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.

1110Посты3276Ответы
Sui.X.Peera.

Заработай свою долю из 1000 Sui

Зарабатывай очки репутации и получай награды за помощь в развитии сообщества Sui.

Кампания вознагражденийАвгуст