Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

sui-ts-sdk

БесплатноЗапускает вложенные скриптыНе проверен

Sui TypeScript SDK — PTB construction, client setup, transaction execution, and on-chain queries. Use when writing code that interacts with the Sui blockchain…

jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Об этом скилле

Sui TypeScript SDK Skill

You are writing TypeScript code that interacts with the Sui blockchain using the @mysten/sui SDK (v2+). Follow these rules precisely. This skill covers PTB (Programmable Transaction Block) construction, client setup, transaction execution, and on-chain queries. These patterns apply equally in backend scripts and frontend apps. If you are building a frontend, use the sui-frontend skill first (or alongside this one) for dApp Kit setup, wallet connection, and React integration — then apply the PTB and client patterns from this skill.


1. Package & Imports

The SDK package is @mysten/sui. The old package name @mysten/sui.js was renamed at v1.0 and must not be used.

# ✅
npm install @mysten/sui

# ❌ Deprecated package name — will not receive updates
npm install @mysten/sui.js

All imports use subpath exports from @mysten/sui:

// ✅ Correct subpath imports
import { Transaction } from '@mysten/sui/transactions';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
import { SuiGrpcClient } from '@mysten/sui/grpc';

// ❌ Old package name
import { TransactionBlock } from '@mysten/sui.js';

// ❌ Importing from package root
import { Transaction } from '@mysten/sui';

2. Client Setup

The SDK provides three client types. Use SuiGrpcClient for new code — it is the recommended client with the best performance. The JSON-RPC API is deprecated.

// ✅ Recommended — gRPC client (best performance, type-safe protobuf)
import { SuiGrpcClient } from '@mysten/sui/grpc';

const client = new SuiGrpcClient({
  network: 'testnet',
  baseUrl: 'https://fullnode.testnet.sui.io:443',
});
// ⚠️ Legacy — JSON-RPC client (deprecated API, still widely used)
// In v2, SuiClient was removed from @mysten/sui/client. Use SuiJsonRpcClient instead.
import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';

const client = new SuiJsonRpcClient({
  url: getJsonRpcFullnodeUrl('testnet'),
  network: 'testnet', // required in v2
});
// ⚠️ GraphQL client — for advanced query use cases
import { SuiGraphQLClient } from '@mysten/sui/graphql';

const gqlClient = new SuiGraphQLClient({
  url: 'https://graphql.testnet.sui.io/graphql',
  network: 'testnet', // required in v2
});

Network URLs

Network gRPC base URL GraphQL URL JSON-RPC URL
Mainnet https://fullnode.mainnet.sui.io:443 https://graphql.mainnet.sui.io/graphql getJsonRpcFullnodeUrl('mainnet')
Testnet https://fullnode.testnet.sui.io:443 https://graphql.testnet.sui.io/graphql getJsonRpcFullnodeUrl('testnet')
Devnet https://fullnode.devnet.sui.io:443 https://graphql.devnet.sui.io/graphql getJsonRpcFullnodeUrl('devnet')

gRPC service clients

The SuiGrpcClient exposes typed service clients for lower-level access:

// Transaction execution
await client.transactionExecutionService.executeTransaction({ ... });

// Ledger queries
await client.ledgerService.getObject({ objectId: '0x...' });

// Move package introspection
await client.movePackageService.getFunction({
  packageId: '0x2',
  moduleName: 'coin',
  name: 'transfer',
});

// Name service (SuiNS)
await client.nameService.reverseLookupName({ address: '0x...' });

3. Transaction Construction

A Programmable Transaction Block (PTB) is built using the Transaction class. The class was renamed from TransactionBlock at v1.0:

// ✅
import { Transaction } from '@mysten/sui/transactions';
const tx = new Transaction();

// ❌ Old class name (pre-1.0)
import { TransactionBlock } from '@mysten/sui.js/transactions';
const txb = new TransactionBlock();

Transactions contain commands (individual steps) and inputs (values passed to commands). Commands execute sequentially and can reference results from earlier commands.

Cloning a transaction

// ✅ v1.0+
const newTx = Transaction.from(existingTx);

// ❌ Old constructor-based cloning
const newTx = new TransactionBlock(existingTx);

Serialization

// ✅ v1.0+ — async, runs serialization plugins
const json = await tx.toJSON();

// Deserialize
const restored = Transaction.from(json);

// ❌ Deprecated
const bytes = tx.serialize();

4. Pure Value Inputs

Use tx.pure.<type>() helpers for non-object inputs. These handle BCS serialization automatically. Never manually BCS-encode values when a tx.pure helper exists.

// ✅ Typed pure helpers
tx.pure.u8(255);
tx.pure.u16(65535);
tx.pure.u32(4294967295);
tx.pure.u64(1000000n);              // accepts bigint or number
tx.pure.u128(1000000n);
tx.pure.u256(1000000n);
tx.pure.bool(true);
tx.pure.string('hello');
tx.pure.address('0xSomeAddress');
tx.pure.id('0xSomeObjectId');       // equivalent to address, for object IDs as values

// Vectors
tx.pure.vector('u64',
Полный SKILL.md на GitHub

Установить sui-ts-sdk в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

README.mdevals/evals.jsonevals/files/pool.moveevals/files/v1_script.ts

FAQ

Что делает скилл sui-ts-sdk?

Sui TypeScript SDK — PTB construction, client setup, transaction execution, and on-chain queries. Use when writing code that interacts with the Sui blockchain via @mysten/sui. These patterns apply in both backend scripts and frontend apps. For frontend-specific setup (dApp Kit, wallet adapters, React hooks), use the sui-frontend skill first or alongside this one.

Как установить скилл sui-ts-sdk?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл sui-ts-sdk запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить sui-ts-sdk с