sui-ts-transpiler
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
A CLI tool and SDK that converts TypeScript smart contracts to Sui Move language with full logic preservation (not just structural mapping). v1.0.0 targets Node >=16 and ships TypeScript declarations. It provides a `sui-ts` CLI for project scaffolding (`init`), transpilation (`transpile`), building (`build`), and sample generation. Key differentiators: complete logic conversion vs. syntax-only mappers, automatic Sui-specific type mapping (e.g., `constructor()` → `create_*()`), and programmatic SDK support via `SuiMoveTranspiler` class. Active development under @gsui-team.
Common errors
error Error: Cannot find module 'sui-ts-transpiler' ↓
cause Trying to require or import the package without installing it.
fix
Install globally:
npm install -g sui-ts-transpiler or locally: npm install --save-dev sui-ts-transpiler. error sui-ts: command not found ↓
cause Global installation missing or not on PATH.
fix
Install globally:
npm install -g sui-ts-transpiler. If still not found, check npm global bin directory or use npx: npx sui-ts-transpiler. error Error: Type 'string' is not assignable to type 'vector<u8>' ↓
cause Using TypeScript `string` type which maps to `vector<u8>` in Move, but the transpiler expects a specific format.
fix
Ensure string values are UTF-8 encoded. For complex strings, use
vector<u8> directly in TS with new Uint8Array([...]). error Error: Module 'contract' not found in package 'sui_contract' ↓
cause Output directory structure mismatch when publishing; Move expects specific package layout.
fix
Run
sui-ts build which generates a proper Move.toml and directory structure, then publish from out/. Warnings
gotcha CLI command is `sui-ts` not `sui-ts-transpiler`. Users often try `sui-ts-transpiler init` which fails. ↓
fix Use `sui-ts init <project>` or alias `npx sui-ts-transpiler` if needed.
breaking Global install may conflict with other Sui tooling if `sui-ts` is already used by another package. ↓
fix Use npx: `npx sui-ts-transpiler init <project>` or install locally as devDependency.
gotcha Number → u64, but Move's u64 is unsigned and 64-bit. Large numbers (>2^53-1) lose precision in JS; the compiler may silently truncate. ↓
fix Use `bigint` for values exceeding 2^53-1. The transpiler maps `bigint` to `u256`.
deprecated Package uses `-v` for verbose. Future versions may change to `--verbose` only. ↓
fix Prefer `--verbose` in scripts for forward compatibility.
gotcha Constructor transpiles to a create function named after the class (e.g., `create_counter`). If the class name is not a valid Move identifier (e.g., starts with underscore), the generated name may conflict. ↓
fix Use PascalCase class names that are also valid Move identifiers (no leading underscores).
Install
npm install sui-ts-transpiler yarn add sui-ts-transpiler pnpm add sui-ts-transpiler Imports
- SuiMoveTranspiler wrong
import SuiMoveTranspiler from 'sui-ts-transpiler'correctimport { SuiMoveTranspiler } from 'sui-ts-transpiler' - sui-ts CLI wrong
sui-ts-transpiler init my-projectcorrectsui-ts init my-project - MoveTranspilerOptions
import { MoveTranspilerOptions } from 'sui-ts-transpiler'
Quickstart
npm install -g sui-ts-transpiler
sui-ts init my-sui-project
cd my-sui-project
npm install
cat > src/contract.ts << 'EOF'
class Counter {
private value: number;
private owner: Address;
constructor(owner: Address) {
this.value = 0;
this.owner = owner;
}
public increment(): void {
this.value = this.value + 1;
}
public getValue(): number {
return this.value;
}
}
EOF
sui-ts transpile
ls out/