| name | sui-client |
| description | Interact with Sui blockchain using @mysten/sui SDK. Use when building transactions, reading chain data, or managing staking positions on Sui. |
SuiClient Skill
Use this skill when working with Sui blockchain. JSON-RPC is deprecated - use gRPC or GraphQL.
Quick Start
import { SuiGrpcClient } from "@mysten/sui/grpc";
const client = new SuiGrpcClient({ network: "mainnet" });
import { SuiGraphQLClient } from "@mysten/sui/graphql";
const client = new SuiGraphQLClient({
network: "mainnet",
url: "https://your-graphql-endpoint/graphql",
});
Key Imports
| Feature | Import Path |
|---|
| gRPC Client | @mysten/sui/grpc |
| GraphQL Client | @mysten/sui/graphql |
| Transaction | @mysten/sui/transactions |
| Keypairs | @mysten/sui/keypairs/ed25519 |
| JSON-RPC (deprecated) | @mysten/sui/jsonRpc |
API Methods
Objects
const obj = await client.getObject({
id: "0x...",
options: { showType: true, showContent: true },
});
const objs = await client.multiGetObjects({
ids: ["0x...", "0x..."],
options: { showType: true },
});
const owned = await client.listOwnedObjects({
owner: "0x...",
filter: { StructType: "0x2::coin::Coin" },
});
const field = await client.getDynamicField({
parentId: "0x...",
name: { type: "...", value: "..." },
});
const fields = await client.listDynamicFields({
parentId: "0x...",
limit: 50,
});
Coins & Balances
const coins = await client.listCoins({
owner: "0x...",
coinType: "0x2::sui::SUI",
limit: 100,
cursor: "...",
});
const balance = await client.getBalance({
owner: "0x...",
coinType: "0x2::sui::SUI",
});
const balances = await client.listBalances({ owner: "0x..." });
const meta = await client.getCoinMetadata({
coinType: "0x2::sui::SUI",
});
Transactions
import { Transaction } from "@mysten/sui/transactions";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
const keypair = Ed25519Keypair.fromSecretKey("...");
const tx = new Transaction();
tx.moveCall({ target: "0x...::module::function" });
const result = await client.signAndExecuteTransaction({
transaction: tx,
signer: keypair,
options: { showEffects: true },
});
const confirmed = await client.waitForTransaction({
digest: result.digest,
options: { showEffects: true },
});
const simulated = await client.simulateTransaction({
transaction: tx,
signer: keypair.getPublicKey(),
});
const txResult = await client.getTransaction({
digest: "...",
options: { showEffects: true, showObjectChanges: true },
});
Network Info
const gasPrice = await client.getReferenceGasPrice();
const state = await client.getCurrentSystemState();
const chainId = await client.getChainIdentifier();
const config = await client.getProtocolConfig();
const epoch = await client.getCurrentEpoch();
Move Package
const func = await client.getMoveFunction({
package: "0x...",
module: "...",
function: "...",
});
Name Service
const name = await client.defaultNameServiceName({
address: "0x...",
});
zkLogin
const result = await client.verifyZkLoginSignature({
bytes: "...",
signature: "...",
intentScope: "TransactionData",
address: "0x...",
});
gRPC-Specific Features
const client = new SuiGrpcClient({ network: "mainnet" });
client.transactionExecutionService;
client.ledgerService;
client.stateService;
client.subscriptionService;
client.movePackageService;
client.signatureVerificationService;
client.nameService;
client.mvr.resolvePackage({ package: "0x..." });
client.mvr.resolveType({ type: "0x..." });
client.mvr.resolve({ packages: ["0x..."] });
GraphQL-Specific Features
import { graphql } from '@mysten/sui/graphql/schema';
const client = new SuiGraphQLClient({
network: 'mainnet',
url: 'https://.../graphql',
queries: {
myQuery: graphql(`
query getBalance($owner: SuiAddress!) {
address(owner: $owner) {
balance { totalBalance }
}
}
`)
}
});
const result = await client.execute('myQuery', {
variables: { owner: '0x...' }
});
const inline = await client.query({
query: graphql(`query { ... }`),
variables: { ... }
});
NOT Available in gRPC/GraphQL (use JSON-RPC for now)
getStakes / getStakesByIds - Staking queries
queryEvents / subscribeEvent - Event queries
getCoins - Use listCoins instead
Network Endpoints
Contact your RPC provider for current endpoints. JSON-RPC (deprecated):
- mainnet:
https://fullnode.mainnet.sui.io:443
- testnet:
https://fullnode.testnet.sui.io:443
- devnet:
https://fullnode.devnet.sui.io:443
Dependencies
bun add @mysten/sui