@mysten/docs 0.1.27 → 0.1.28
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 +2 -2
- 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/plugins.md +4 -4
- package/dist/sui/transactions/basics.md +279 -0
- package/dist/sui/transactions/coins-and-balances.md +287 -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 +11 -10
- 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
|
|
|
@@ -437,5 +437,5 @@ const dAppKit = createDAppKit({
|
|
|
437
437
|
already configured
|
|
438
438
|
- [Sui Move documentation](https://docs.sui.io/concepts/sui-move-concepts)
|
|
439
439
|
- [BCS documentation](/bcs)
|
|
440
|
-
- [Transaction building](/sui/
|
|
440
|
+
- [Transaction building](/sui/transactions/basics)
|
|
441
441
|
- [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
|
```
|
package/dist/sui/plugins.md
CHANGED
|
@@ -148,7 +148,7 @@ Adding an intent is similar to adding any other command to a transaction:
|
|
|
148
148
|
const transaction = new Transaction();
|
|
149
149
|
|
|
150
150
|
transaction.add(
|
|
151
|
-
|
|
151
|
+
TransactionCommands.Intent({
|
|
152
152
|
name: 'TransferToSender',
|
|
153
153
|
inputs: {
|
|
154
154
|
objects: [transaction.object(someId)],
|
|
@@ -166,7 +166,7 @@ current transaction instance. This allows us to create a helper that automatical
|
|
|
166
166
|
function transferToSender(objects: TransactionObjectInput[]) {
|
|
167
167
|
return (tx: Transaction) => {
|
|
168
168
|
tx.add(
|
|
169
|
-
|
|
169
|
+
TransactionCommands.Intent({
|
|
170
170
|
name: 'TransferToSender',
|
|
171
171
|
inputs: {
|
|
172
172
|
objects: objects.map((obj) => tx.object(obj)),
|
|
@@ -214,7 +214,7 @@ async function resolveTransferToSender(
|
|
|
214
214
|
|
|
215
215
|
// This will replace the intent command with the correct TransferObjects command
|
|
216
216
|
transactionData.replaceCommand(index, [
|
|
217
|
-
|
|
217
|
+
TransactionCommands.TransferObjects(
|
|
218
218
|
// The inputs for intents are not currently typed, so we need to cast to the correct type here
|
|
219
219
|
transaction.$Intent.inputs.objects as Extract<
|
|
220
220
|
TransactionObjectArgument,
|
|
@@ -243,7 +243,7 @@ function transferToSender(objects: TransactionObjectInput[]) {
|
|
|
243
243
|
// As long as we are adding the same function reference, it will only be added once
|
|
244
244
|
tx.addIntentResolver('TransferToSender', resolveTransferToSender);
|
|
245
245
|
tx.add(
|
|
246
|
-
|
|
246
|
+
TransactionCommands.Intent({
|
|
247
247
|
name: 'TransferToSender',
|
|
248
248
|
inputs: {
|
|
249
249
|
objects: objects.map((obj) => tx.object(obj)),
|