@mysten/docs 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bcs/index.md +1 -1
- package/dist/codegen/index.md +68 -4
- package/dist/dapp-kit/dapp-kit-instance.md +1 -1
- package/dist/dapp-kit/getting-started/create-dapp.md +1 -1
- package/dist/dapp-kit/getting-started/next-js.md +1 -1
- package/dist/dapp-kit/getting-started/react.md +2 -2
- package/dist/dapp-kit/getting-started/vue.md +1 -1
- package/dist/dapp-kit/index.md +2 -2
- package/dist/kiosk/index.md +1 -1
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +1 -1
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +2 -2
- package/dist/llms-index.md +6 -9
- package/dist/sui/bcs.md +11 -6
- package/dist/sui/clients/core.md +10 -9
- package/dist/sui/clients/grpc.md +1 -1
- package/dist/sui/index.md +176 -22
- package/dist/sui/llms-index.md +6 -9
- package/dist/sui/migrations/0.38.md +2 -2
- package/dist/sui/migrations/sui-1.0.md +2 -2
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +76 -33
- package/dist/sui/plugins.md +29 -5
- package/dist/sui/transactions/basics.md +279 -0
- package/dist/sui/transactions/coins-and-balances.md +293 -0
- package/dist/sui/transactions/offline.md +192 -0
- package/dist/sui/transactions/reference.md +380 -0
- package/dist/sui/transactions/signing-and-execution.md +401 -0
- package/dist/zksend/index.md +1 -1
- package/package.json +41 -40
- package/dist/sui/faucet.md +0 -26
- package/dist/sui/hello-sui.md +0 -115
- package/dist/sui/install.md +0 -61
- package/dist/sui/transaction-building/basics.md +0 -299
- package/dist/sui/transaction-building/gas.md +0 -61
- package/dist/sui/transaction-building/intents.md +0 -62
- package/dist/sui/transaction-building/offline.md +0 -73
- package/dist/sui/transaction-building/sponsored-transactions.md +0 -22
package/dist/bcs/index.md
CHANGED
package/dist/codegen/index.md
CHANGED
|
@@ -19,7 +19,7 @@ packages, enabling seamless interaction with your smart contracts from TypeScrip
|
|
|
19
19
|
|
|
20
20
|
Install the codegen package as a dev dependency:
|
|
21
21
|
|
|
22
|
-
```
|
|
22
|
+
```npm
|
|
23
23
|
npm install -D @mysten/codegen
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -296,8 +296,9 @@ they don't affect serialization. The generated type is a constant rather than a
|
|
|
296
296
|
This works correctly for parsing onchain data because phantom types don't change the binary layout.
|
|
297
297
|
|
|
298
298
|
> **Note:** With the default behavior, phantom parameters appear as literals in the type name (for example,
|
|
299
|
-
> `Balance<phantom T>`). These names are useful for debugging but are not valid onchain type tags.
|
|
300
|
-
>
|
|
299
|
+
> `Balance<phantom T>`). These names are useful for debugging but are not valid onchain type tags. Use
|
|
300
|
+
> the [`typeTag` method](#getting-type-tags) to build valid type tags with the phantom parameters
|
|
301
|
+
> filled in.
|
|
301
302
|
|
|
302
303
|
### Including phantom type parameters
|
|
303
304
|
|
|
@@ -372,6 +373,69 @@ async function readCounter(client: ClientWithCoreApi, id: string) {
|
|
|
372
373
|
> contains a full object envelope with additional metadata that will cause parsing to fail. See the
|
|
373
374
|
> [Core API docs](/sui/clients/core#objectbcs) for details.
|
|
374
375
|
|
|
376
|
+
### Getting type tags
|
|
377
|
+
|
|
378
|
+
Generated types build their own type tag strings with the `typeTag` method, so you don't hand-write
|
|
379
|
+
strings like `` `${packageId}::module::Name<${coinType}>` ``. By default the tag uses the package
|
|
380
|
+
the type was generated from — a real address for framework types, or the configured name for a local
|
|
381
|
+
or MVR package:
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
|
|
385
|
+
Balance.typeTag({ typeArguments: ['0x2::sui::SUI'] });
|
|
386
|
+
// '0x2::balance::Balance<0x2::sui::SUI>'
|
|
387
|
+
|
|
388
|
+
Counter.typeTag();
|
|
389
|
+
// '@local-pkg/counter::counter::Counter'
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Types with phantom type parameters require `typeArguments`; types without them take none. This is
|
|
393
|
+
enforced at compile time:
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
Counter.typeTag(); // ok — no type parameters
|
|
397
|
+
Balance.typeTag({ typeArguments: ['0x2::sui::SUI'] }); // ok
|
|
398
|
+
|
|
399
|
+
// @ts-expect-error — Balance has a phantom parameter, typeArguments is required
|
|
400
|
+
Balance.typeTag();
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
`typeArguments` is the full positional list, in Move declaration order. Each entry is a type tag
|
|
404
|
+
string, another `typeTag()` result, or a BCS type (its `name` is used):
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
|
|
408
|
+
Balance.typeTag({ typeArguments: [bcs.u64()] });
|
|
409
|
+
// '0x2::balance::Balance<u64>'
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
To override the package identifier — for example, to pin a specific published address — pass
|
|
413
|
+
`package`:
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
Counter.typeTag({ package: '0xPACKAGE_ID' });
|
|
417
|
+
// '0xPACKAGE_ID::counter::Counter'
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Resolving type tags
|
|
421
|
+
|
|
422
|
+
For a local or MVR package, `typeTag` returns the configured name (`@local-pkg/counter::…`). That is
|
|
423
|
+
valid in transaction `typeArguments` — it resolves automatically when the transaction is built — but
|
|
424
|
+
query filters and comparisons against onchain data need a resolved, address-only tag.
|
|
425
|
+
`resolveTypeTag` takes the same options as `typeTag` plus a `client`, resolves any names through it,
|
|
426
|
+
and normalizes the result:
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
const counterType = await Counter.resolveTypeTag({ client });
|
|
430
|
+
// '0x0000…0123::counter::Counter'
|
|
431
|
+
|
|
432
|
+
const balanceType = await Balance.resolveTypeTag({
|
|
433
|
+
client,
|
|
434
|
+
typeArguments: ['0x2::sui::SUI'],
|
|
435
|
+
});
|
|
436
|
+
// '0x0000…0002::balance::Balance<0x0000…0002::sui::SUI>'
|
|
437
|
+
```
|
|
438
|
+
|
|
375
439
|
## Client configuration
|
|
376
440
|
|
|
377
441
|
### Using with MVR (Move Version Registry)
|
|
@@ -437,5 +501,5 @@ const dAppKit = createDAppKit({
|
|
|
437
501
|
already configured
|
|
438
502
|
- [Sui Move documentation](https://docs.sui.io/concepts/sui-move-concepts)
|
|
439
503
|
- [BCS documentation](/bcs)
|
|
440
|
-
- [Transaction building](/sui/
|
|
504
|
+
- [Transaction building](/sui/transactions/basics)
|
|
441
505
|
- [dApp Kit](/dapp-kit)
|
|
@@ -23,7 +23,7 @@ const GRPC_URLS = {
|
|
|
23
23
|
|
|
24
24
|
> **Note:** If you use the React bindings, there are two ways to ensure type safety with hooks:
|
|
25
25
|
>
|
|
26
|
-
> 1. [Register the global dAppKit type](./getting-started/react#1-create-a-dapp-kit-instance) once, and all hooks will be properly typed
|
|
26
|
+
> 1. [Register the global dAppKit type](./getting-started/react#step-1-create-a-dapp-kit-instance) once, and all hooks will be properly typed
|
|
27
27
|
> 2. Pass the dAppKit instance explicitly to each hook: `useWalletConnection({ dAppKit })`
|
|
28
28
|
|
|
29
29
|
This instance provides:
|
|
@@ -8,7 +8,7 @@ This guide walks you through integrating dApp Kit into a React application.
|
|
|
8
8
|
|
|
9
9
|
The fastest way to get started is using our CLI tool:
|
|
10
10
|
|
|
11
|
-
```
|
|
11
|
+
```npm
|
|
12
12
|
npm create @mysten/dapp
|
|
13
13
|
```
|
|
14
14
|
|
|
@@ -30,7 +30,7 @@ See the [create-dapp guide](/dapp-kit/getting-started/create-dapp) for more deta
|
|
|
30
30
|
|
|
31
31
|
## Manual installation
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```npm
|
|
34
34
|
npm i @mysten/dapp-kit-react @mysten/sui
|
|
35
35
|
```
|
|
36
36
|
|
package/dist/dapp-kit/index.md
CHANGED
|
@@ -34,13 +34,13 @@ Choose the installation method based on your framework:
|
|
|
34
34
|
|
|
35
35
|
### For React applications
|
|
36
36
|
|
|
37
|
-
```
|
|
37
|
+
```npm
|
|
38
38
|
npm i @mysten/dapp-kit-react @mysten/sui
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
### Vanilla JavaScript and other frameworks
|
|
42
42
|
|
|
43
|
-
```
|
|
43
|
+
```npm
|
|
44
44
|
npm i @mysten/dapp-kit-core @mysten/sui
|
|
45
45
|
```
|
|
46
46
|
|
package/dist/kiosk/index.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The kiosk extension (`client.kiosk`) helps in managing a kiosk.
|
|
6
6
|
|
|
7
|
-
You need to follow the steps explained in the [Kiosk Transaction section](
|
|
7
|
+
You need to follow the steps explained in the [Kiosk Transaction section](./kiosk-transaction) to
|
|
8
8
|
create a `KioskTransaction`.
|
|
9
9
|
|
|
10
10
|
## Available functions
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
One of the base functionalities of the SDK is a seamless purchasing flow, allowing for ease of rules
|
|
6
6
|
resolving (hiding away the calls). The SDK supports all four rules by default, and works for
|
|
7
|
-
`TESTNET` and `MAINNET`.
|
|
8
|
-
[
|
|
7
|
+
`TESTNET` and `MAINNET`. For other networks, see the
|
|
8
|
+
[kiosk extension setup section](../introduction) of the introduction.
|
|
9
9
|
|
|
10
10
|
## How to purchase
|
|
11
11
|
|
package/dist/llms-index.md
CHANGED
|
@@ -84,21 +84,18 @@
|
|
|
84
84
|
## Sui SDK
|
|
85
85
|
> TypeScript interfaces for Sui
|
|
86
86
|
|
|
87
|
-
- [Sui TypeScript SDK
|
|
88
|
-
- [Install Sui TypeScript SDK](./sui/install.md): Install the @mysten/sui package and configure your project.
|
|
87
|
+
- [Sui TypeScript SDK](./sui.md): TypeScript SDK for building on the Sui blockchain
|
|
89
88
|
- [LLM Documentation](./sui/llm-docs.md): Give AI agents access to Sui SDK documentation in your project.
|
|
90
|
-
- [Hello Sui](./sui/hello-sui.md): Build your first Sui application with the TypeScript SDK.
|
|
91
|
-
- [Faucet](./sui/faucet.md): Request test SUI tokens from the faucet on Devnet, Testnet, or local networks.
|
|
92
89
|
- [Sui Clients](./sui/clients.md): Choose and configure gRPC, GraphQL, or JSON-RPC clients for the Sui network.
|
|
93
90
|
- [Core API](./sui/clients/core.md): Transport-agnostic Core API shared by all Sui clients.
|
|
94
91
|
- [SuiGrpcClient](./sui/clients/grpc.md): Connect to Sui through gRPC with SuiGrpcClient.
|
|
95
92
|
- [SuiGraphQLClient](./sui/clients/graphql.md): Connect to Sui through GraphQL with SuiGraphQLClient.
|
|
96
93
|
- [SuiJsonRpcClient](./sui/clients/json-rpc.md): Connect to Sui through JSON-RPC with SuiJsonRpcClient.
|
|
97
|
-
- [
|
|
98
|
-
- [
|
|
99
|
-
- [
|
|
100
|
-
- [
|
|
101
|
-
- [
|
|
94
|
+
- [Building Transactions](./sui/transactions/basics.md): Construct programmable transaction blocks with the Transaction API
|
|
95
|
+
- [Signing and Execution](./sui/transactions/signing-and-execution.md): Sign transactions and execute them on the Sui network
|
|
96
|
+
- [Coins and Balances](./sui/transactions/coins-and-balances.md): Work with coin objects and address balances in transactions
|
|
97
|
+
- [Commands and Inputs Reference](./sui/transactions/reference.md): Complete reference for transaction commands and input types
|
|
98
|
+
- [Building Offline](./sui/transactions/offline.md): Build transactions without a network connection
|
|
102
99
|
- [Key pairs](./sui/cryptography/keypairs.md): Create and manage Ed25519, Secp256k1, and Secp256r1 keypairs for Sui transaction signing.
|
|
103
100
|
- [Multi-Signature Transactions](./sui/cryptography/multisig.md): Create multi-signature transactions with multiple signers on Sui.
|
|
104
101
|
- [Passkey](./sui/cryptography/passkey.md): Use WebAuthn passkeys for Sui transaction signing.
|
package/dist/sui/bcs.md
CHANGED
|
@@ -35,7 +35,6 @@ the following pre-defined schemes:
|
|
|
35
35
|
- `SharedObjectRef`
|
|
36
36
|
- `StructTag`
|
|
37
37
|
- `SuiObjectRef`
|
|
38
|
-
- `Transaction`
|
|
39
38
|
- `TransactionData`
|
|
40
39
|
- `TransactionDataV1`
|
|
41
40
|
- `TransactionExpiration`
|
|
@@ -85,12 +84,18 @@ object response, so you typically only need `content`.
|
|
|
85
84
|
|
|
86
85
|
```typescript
|
|
87
86
|
|
|
88
|
-
// Parse a
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
// Parse a BCS-encoded object
|
|
88
|
+
const { objects } = await grpcClient.getObjects({
|
|
89
|
+
objectIds: [objectId],
|
|
90
|
+
include: { objectBcs: true },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const parsed = bcs.Object.parse(objects[0].objectBcs);
|
|
94
|
+
console.log('Owner:', parsed.owner);
|
|
95
|
+
console.log('Previous Transaction:', parsed.previousTransaction);
|
|
96
|
+
console.log('Storage Rebate:', parsed.storageRebate);
|
|
92
97
|
|
|
93
|
-
// Serialize
|
|
98
|
+
// Serialize an object
|
|
94
99
|
const serialized = bcs.Object.serialize({
|
|
95
100
|
data: {
|
|
96
101
|
Move: {
|
package/dist/sui/clients/core.md
CHANGED
|
@@ -178,13 +178,14 @@ The `display` field is `null` when the object's type has no registered Display t
|
|
|
178
178
|
Get the balance of a specific coin type for an owner.
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
|
-
const balance = await client.core.getBalance({
|
|
181
|
+
const { balance } = await client.core.getBalance({
|
|
182
182
|
owner: '0xabc...',
|
|
183
183
|
coinType: '0x2::sui::SUI', // Optional, defaults to SUI
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
console.log(balance.
|
|
187
|
-
console.log(balance.
|
|
186
|
+
console.log(balance.balance); // Total balance (coin objects + address balance)
|
|
187
|
+
console.log(balance.coinBalance); // Balance from coin objects only
|
|
188
|
+
console.log(balance.addressBalance); // Balance from address balance only
|
|
188
189
|
```
|
|
189
190
|
|
|
190
191
|
### `listBalances`
|
|
@@ -197,7 +198,7 @@ const { balances } = await client.core.listBalances({
|
|
|
197
198
|
});
|
|
198
199
|
|
|
199
200
|
for (const balance of balances) {
|
|
200
|
-
console.log(balance.coinType, balance.
|
|
201
|
+
console.log(balance.coinType, balance.balance);
|
|
201
202
|
}
|
|
202
203
|
```
|
|
203
204
|
|
|
@@ -212,7 +213,7 @@ const result = await client.core.listCoins({
|
|
|
212
213
|
limit: 10,
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
for (const coin of result.
|
|
216
|
+
for (const coin of result.objects) {
|
|
216
217
|
console.log(coin.objectId, coin.balance);
|
|
217
218
|
}
|
|
218
219
|
```
|
|
@@ -454,7 +455,7 @@ console.log(referenceGasPrice); // bigint
|
|
|
454
455
|
Get the current system state including epoch information.
|
|
455
456
|
|
|
456
457
|
```typescript
|
|
457
|
-
const systemState = await client.core.getCurrentSystemState();
|
|
458
|
+
const { systemState } = await client.core.getCurrentSystemState();
|
|
458
459
|
console.log(systemState.epoch);
|
|
459
460
|
console.log(systemState.systemStateVersion);
|
|
460
461
|
```
|
|
@@ -478,7 +479,7 @@ Get information about a Move function.
|
|
|
478
479
|
const { function: fn } = await client.core.getMoveFunction({
|
|
479
480
|
packageId: '0x2',
|
|
480
481
|
moduleName: 'coin',
|
|
481
|
-
name: '
|
|
482
|
+
name: 'value',
|
|
482
483
|
});
|
|
483
484
|
|
|
484
485
|
console.log(fn.name);
|
|
@@ -566,7 +567,7 @@ function processObject(obj: SuiClientTypes.Object<{ content: true }>) {
|
|
|
566
567
|
async function fetchBalance(
|
|
567
568
|
client: ClientWithCoreApi,
|
|
568
569
|
owner: string,
|
|
569
|
-
): Promise<SuiClientTypes.
|
|
570
|
+
): Promise<SuiClientTypes.Balance> {
|
|
570
571
|
const { balance } = await client.core.getBalance({ owner });
|
|
571
572
|
return balance;
|
|
572
573
|
}
|
|
@@ -584,7 +585,7 @@ const options: SuiClientTypes.GetObjectOptions<{ content: true }> = {
|
|
|
584
585
|
| ---------------------- | ------------------------------------------- |
|
|
585
586
|
| `Object<Include>` | Fetched object with optional included data |
|
|
586
587
|
| `Coin` | Coin object with balance |
|
|
587
|
-
| `
|
|
588
|
+
| `Balance` | Balance summary for a coin type |
|
|
588
589
|
| `CoinMetadata` | Metadata for a coin type |
|
|
589
590
|
| `Transaction<Include>` | Executed transaction with optional data |
|
|
590
591
|
| `TransactionResult` | Success or failure result from execution |
|
package/dist/sui/clients/grpc.md
CHANGED
|
@@ -179,7 +179,7 @@ const { response: fields } = await grpcClient.stateService.listDynamicFields({
|
|
|
179
179
|
const { response } = await grpcClient.movePackageService.getFunction({
|
|
180
180
|
packageId: '0x2',
|
|
181
181
|
moduleName: 'coin',
|
|
182
|
-
name: '
|
|
182
|
+
name: 'value',
|
|
183
183
|
});
|
|
184
184
|
```
|
|
185
185
|
|
package/dist/sui/index.md
CHANGED
|
@@ -1,22 +1,55 @@
|
|
|
1
|
-
# Sui TypeScript SDK
|
|
1
|
+
# Sui TypeScript SDK
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> TypeScript SDK for building on the Sui blockchain
|
|
4
4
|
|
|
5
5
|
The Sui TypeScript SDK is a modular library of tools for interacting with the Sui blockchain. Use it
|
|
6
6
|
to send queries to RPC nodes, build and sign transactions, and interact with a Sui or local network.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```npm
|
|
11
11
|
npm i @mysten/sui
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
The SDK is published as an ESM only package. Make sure your `package.json` includes
|
|
15
|
+
`"type": "module"`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"type": "module"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If you are using TypeScript, your `tsconfig.json` should use a compatible `moduleResolution` setting
|
|
24
|
+
such as `"NodeNext"`, `"Node16"`, or `"Bundler"`.
|
|
25
|
+
|
|
26
|
+
## Module packages
|
|
27
|
+
|
|
28
|
+
The SDK contains a set of modular packages that you can use independently or together. Import just
|
|
29
|
+
what you need to keep your code light and compact.
|
|
30
|
+
|
|
31
|
+
- [`@mysten/sui/client`](/sui/clients): A client for interacting with Sui RPC nodes.
|
|
32
|
+
- [`@mysten/sui/bcs`](/sui/bcs): A BCS builder with pre-defined types for Sui.
|
|
33
|
+
- [`@mysten/sui/transactions`](/sui/transactions/basics): Utilities for building and interacting
|
|
34
|
+
with transactions.
|
|
35
|
+
- [`@mysten/sui/keypairs/*`](/sui/cryptography/keypairs): Modular exports for specific KeyPair
|
|
36
|
+
implementations.
|
|
37
|
+
- [`@mysten/sui/verify`](/sui/cryptography/keypairs#verifying-signatures-without-a-key-pair):
|
|
38
|
+
Methods for verifying transactions and messages.
|
|
39
|
+
- [`@mysten/sui/cryptography`](/sui/cryptography/keypairs): Shared types and classes for
|
|
40
|
+
cryptography.
|
|
41
|
+
- [`@mysten/sui/multisig`](/sui/cryptography/multisig): Utilities for working with multisig
|
|
42
|
+
signatures.
|
|
43
|
+
- [`@mysten/sui/utils`](/sui/utils): Utilities for formatting and parsing various Sui types.
|
|
44
|
+
- [`@mysten/sui/faucet`](#faucet): Methods for requesting SUI from a faucet.
|
|
45
|
+
- [`@mysten/sui/zklogin`](/sui/zklogin): Utilities for working with zkLogin.
|
|
46
|
+
|
|
14
47
|
## Network locations
|
|
15
48
|
|
|
16
49
|
The following table lists the locations for Sui networks.
|
|
17
50
|
|
|
18
51
|
| Network | Full node | faucet |
|
|
19
|
-
|
|
|
52
|
+
| ------- | ------------------------------------- | ---------------------------------------- |
|
|
20
53
|
| local | `http://127.0.0.1:9000` (default) | `http://127.0.0.1:9123/v2/gas` (default) |
|
|
21
54
|
| Devnet | `https://fullnode.devnet.sui.io:443` | `https://faucet.devnet.sui.io/v2/gas` |
|
|
22
55
|
| Testnet | `https://fullnode.testnet.sui.io:443` | `https://faucet.testnet.sui.io/v2/gas` |
|
|
@@ -31,23 +64,144 @@ The following table lists the locations for Sui networks.
|
|
|
31
64
|
> (preferred for apps that have high traffic). You can find a list of reliable RPC endpoint providers
|
|
32
65
|
> for Sui on the [Sui Dev Portal](https://sui.io/developers#dev-tools) using the **Node Service** tab.
|
|
33
66
|
|
|
34
|
-
##
|
|
67
|
+
## Quick start
|
|
35
68
|
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
Get started in a few minutes. This guide walks you through creating a keypair, funding it from a
|
|
70
|
+
faucet, and checking your balance.
|
|
38
71
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
### Create a project
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
mkdir hello-sui
|
|
76
|
+
cd hello-sui
|
|
77
|
+
npm init -y
|
|
78
|
+
npm pkg set type=module
|
|
79
|
+
npm i @mysten/sui
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Step 1: Create a keypair and get SUI
|
|
83
|
+
|
|
84
|
+
Create a `setup.ts` file that generates a new keypair, requests SUI from the faucet, and prints your
|
|
85
|
+
secret key for later use:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
|
|
89
|
+
// Generate a new keypair
|
|
90
|
+
const keypair = new Ed25519Keypair();
|
|
91
|
+
|
|
92
|
+
console.log('Address:', keypair.toSuiAddress());
|
|
93
|
+
console.log('Secret key:', keypair.getSecretKey());
|
|
94
|
+
|
|
95
|
+
// Request SUI from the devnet faucet
|
|
96
|
+
await requestSuiFromFaucetV2({
|
|
97
|
+
host: getFaucetHost('devnet'),
|
|
98
|
+
recipient: keypair.toSuiAddress(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log('Faucet request sent! Save the secret key above for the next step.');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run it:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
node setup.ts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Save the secret key that gets printed; you'll use it in the next step.
|
|
111
|
+
|
|
112
|
+
> **Warning:** Logging secret keys to the console is only appropriate for quick demos like this. In real
|
|
113
|
+
> applications, never log or expose secret keys. Store them securely using environment variables,
|
|
114
|
+
> encrypted keystores, or a secrets manager.
|
|
115
|
+
|
|
116
|
+
### Step 2: Check your balance
|
|
117
|
+
|
|
118
|
+
Create a `balance.ts` file that imports your keypair from the secret key and checks the balance:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
|
|
122
|
+
// Import the keypair using the secret key from step 1
|
|
123
|
+
const keypair = Ed25519Keypair.fromSecretKey('suiprivkey1...'); // paste your secret key here
|
|
124
|
+
|
|
125
|
+
const grpcClient = new SuiGrpcClient({
|
|
126
|
+
network: 'devnet',
|
|
127
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { balance } = await grpcClient.core.getBalance({
|
|
131
|
+
owner: keypair.toSuiAddress(),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const sui = Number(balance.balance) / Number(MIST_PER_SUI);
|
|
135
|
+
console.log(`Address: ${keypair.toSuiAddress()}`);
|
|
136
|
+
console.log(`Balance: ${sui} SUI`);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Run it:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
node balance.ts
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Step 3: Transfer SUI
|
|
146
|
+
|
|
147
|
+
Create a `transfer.ts` file that sends SUI to another address and logs the transaction effects:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
|
|
151
|
+
const keypair = Ed25519Keypair.fromSecretKey('suiprivkey1...'); // paste your secret key here
|
|
152
|
+
const grpcClient = new SuiGrpcClient({
|
|
153
|
+
network: 'devnet',
|
|
154
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const tx = new Transaction();
|
|
158
|
+
|
|
159
|
+
tx.transferObjects(
|
|
160
|
+
[coinWithBalance({ balance: BigInt(0.1 * Number(MIST_PER_SUI)) })],
|
|
161
|
+
'0xRecipientAddress', // replace with the recipient's address
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const result = await keypair.signAndExecuteTransaction({
|
|
165
|
+
transaction: tx,
|
|
166
|
+
client: grpcClient,
|
|
167
|
+
include: { effects: true, balanceChanges: true },
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (result.$kind === 'FailedTransaction') {
|
|
171
|
+
console.error('Transaction failed:', result.FailedTransaction.status.error?.message);
|
|
172
|
+
} else {
|
|
173
|
+
console.log('Transaction digest:', result.Transaction.digest);
|
|
174
|
+
console.log('Effects:', JSON.stringify(result.Transaction.effects, null, 2));
|
|
175
|
+
console.log('Balance changes:', JSON.stringify(result.Transaction.balanceChanges, null, 2));
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Run it:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
node transfer.ts
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Faucet
|
|
186
|
+
|
|
187
|
+
Devnet, Testnet, and local networks include faucets that mint SUI. Use `requestSuiFromFaucetV2` to
|
|
188
|
+
request SUI programmatically:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
|
|
192
|
+
await requestSuiFromFaucetV2({
|
|
193
|
+
host: getFaucetHost('testnet'),
|
|
194
|
+
recipient: '0xYourAddress',
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
> **Note:** Faucets on Devnet and Testnet are rate limited. If you hit the limit, wait before trying again.
|
|
199
|
+
> For Testnet, you can also get SUI through the web UI at `faucet.sui.io` or through the [Sui
|
|
200
|
+
> Discord](https://discord.gg/sui) faucet channels.
|
|
201
|
+
|
|
202
|
+
## Next steps
|
|
203
|
+
|
|
204
|
+
- [Building Transactions](/sui/transactions/basics): create and compose transactions
|
|
205
|
+
- [Signing and Execution](/sui/transactions/signing-and-execution): sign and submit transactions
|
|
206
|
+
- [Coins and Balances](/sui/transactions/coins-and-balances): work with tokens
|
|
207
|
+
- [Client Setup](/sui/clients): configure clients for different networks
|
package/dist/sui/llms-index.md
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
# Sui SDK
|
|
2
2
|
> TypeScript interfaces for Sui
|
|
3
3
|
|
|
4
|
-
- [Sui TypeScript SDK
|
|
5
|
-
- [Install Sui TypeScript SDK](./install.md): Install the @mysten/sui package and configure your project.
|
|
4
|
+
- [Sui TypeScript SDK](..md): TypeScript SDK for building on the Sui blockchain
|
|
6
5
|
- [LLM Documentation](./llm-docs.md): Give AI agents access to Sui SDK documentation in your project.
|
|
7
|
-
- [Hello Sui](./hello-sui.md): Build your first Sui application with the TypeScript SDK.
|
|
8
|
-
- [Faucet](./faucet.md): Request test SUI tokens from the faucet on Devnet, Testnet, or local networks.
|
|
9
6
|
- [Sui Clients](./clients.md): Choose and configure gRPC, GraphQL, or JSON-RPC clients for the Sui network.
|
|
10
7
|
- [Core API](./clients/core.md): Transport-agnostic Core API shared by all Sui clients.
|
|
11
8
|
- [SuiGrpcClient](./clients/grpc.md): Connect to Sui through gRPC with SuiGrpcClient.
|
|
12
9
|
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui through GraphQL with SuiGraphQLClient.
|
|
13
10
|
- [SuiJsonRpcClient](./clients/json-rpc.md): Connect to Sui through JSON-RPC with SuiJsonRpcClient.
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
11
|
+
- [Building Transactions](./transactions/basics.md): Construct programmable transaction blocks with the Transaction API
|
|
12
|
+
- [Signing and Execution](./transactions/signing-and-execution.md): Sign transactions and execute them on the Sui network
|
|
13
|
+
- [Coins and Balances](./transactions/coins-and-balances.md): Work with coin objects and address balances in transactions
|
|
14
|
+
- [Commands and Inputs Reference](./transactions/reference.md): Complete reference for transaction commands and input types
|
|
15
|
+
- [Building Offline](./transactions/offline.md): Build transactions without a network connection
|
|
19
16
|
- [Key pairs](./cryptography/keypairs.md): Create and manage Ed25519, Secp256k1, and Secp256r1 keypairs for Sui transaction signing.
|
|
20
17
|
- [Multi-Signature Transactions](./cryptography/multisig.md): Create multi-signature transactions with multiple signers on Sui.
|
|
21
18
|
- [Passkey](./cryptography/passkey.md): Use WebAuthn passkeys for Sui transaction signing.
|
|
@@ -13,7 +13,7 @@ earlier version of the SDK, there are some changes you should consider when upda
|
|
|
13
13
|
|
|
14
14
|
The Sui TypeScript SDK is now divided into modular components. Before version 0.38.0, you imported
|
|
15
15
|
the complete SDK module. Now, you upload the individual packages of the SDK module instead. See the
|
|
16
|
-
[Module
|
|
16
|
+
[Module Structure section](#module-structure) for the list of packages.
|
|
17
17
|
|
|
18
18
|
### Deprecated classes
|
|
19
19
|
|
|
@@ -40,7 +40,7 @@ The Sui TypeScript SDK deprecates the following classes with version 0.38.0:
|
|
|
40
40
|
|
|
41
41
|
Signing and sending transactions changes slightly with the deprecation of the `Signer` pattern. For
|
|
42
42
|
an example of transaction signing, see the
|
|
43
|
-
[Sui Programmable Transaction
|
|
43
|
+
[Sui Programmable Transaction Block Basics](/sui/transactions/basics) topic.
|
|
44
44
|
|
|
45
45
|
### Faucet requests
|
|
46
46
|
|
|
@@ -11,7 +11,7 @@ highlights:
|
|
|
11
11
|
|
|
12
12
|
- [A new GraphQL Client for the newly released Sui GraphQL API](/sui/clients/graphql)
|
|
13
13
|
- [New Transaction Executor classes for efficient Transaction execution](../executors)
|
|
14
|
-
- [New Transaction Intents to simplify common transaction patterns](../
|
|
14
|
+
- [New Transaction Intents to simplify common transaction patterns](../transactions/coins-and-balances)
|
|
15
15
|
- [A new Plugin system for Extending Transaction Building](../plugins)
|
|
16
16
|
|
|
17
17
|
The majority of changes in this release are in the `@mysten/sui` package, but the changes to API
|
|
@@ -24,7 +24,7 @@ As part of the 1.0 release the `@mysten/sui.js` package has been renamed to `@my
|
|
|
24
24
|
|
|
25
25
|
To upgrade to the new version, uninstall the old package and install the new one:
|
|
26
26
|
|
|
27
|
-
```
|
|
27
|
+
```npm
|
|
28
28
|
npm uninstall @mysten/sui.js
|
|
29
29
|
npm install @mysten/sui
|
|
30
30
|
```
|