@mysten/docs 0.1.26 → 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 +7 -6
- 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
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# Signing and Execution
|
|
2
|
+
|
|
3
|
+
> Sign transactions and execute them on the Sui network
|
|
4
|
+
|
|
5
|
+
Once you've built a transaction, you need to sign it and submit it to the network. For background on
|
|
6
|
+
how transaction signing and finality work at the protocol level, see the Sui documentation on
|
|
7
|
+
[transaction lifecycle](https://docs.sui.io/concepts/transactions/transaction-lifecycle) and
|
|
8
|
+
[transaction auth](https://docs.sui.io/concepts/transactions/transaction-auth).
|
|
9
|
+
|
|
10
|
+
## Simulating transactions
|
|
11
|
+
|
|
12
|
+
Use `simulateTransaction` to dry-run a transaction without executing it. This is useful for
|
|
13
|
+
estimating gas costs, checking return values, and validating transactions before executing.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
|
|
17
|
+
const grpcClient = new SuiGrpcClient({
|
|
18
|
+
network: 'mainnet',
|
|
19
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const result = await grpcClient.simulateTransaction({
|
|
23
|
+
transaction: tx,
|
|
24
|
+
include: {
|
|
25
|
+
effects: true,
|
|
26
|
+
balanceChanges: true,
|
|
27
|
+
commandResults: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (result.$kind === 'FailedTransaction') {
|
|
32
|
+
console.error('Simulation failed:', result.FailedTransaction.status.error?.message);
|
|
33
|
+
} else {
|
|
34
|
+
console.log('Balance changes:', result.Transaction.balanceChanges);
|
|
35
|
+
console.log('Command results:', result.commandResults);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### `include` options
|
|
40
|
+
|
|
41
|
+
The `include` parameter controls what data is returned from the simulation. All fields are optional
|
|
42
|
+
and default to `false`:
|
|
43
|
+
|
|
44
|
+
| Field | Description |
|
|
45
|
+
| ---------------- | -------------------------------------------------------------------------------------- |
|
|
46
|
+
| `effects` | Execution effects: created, mutated, and deleted objects, gas usage |
|
|
47
|
+
| `events` | Move events emitted during execution |
|
|
48
|
+
| `balanceChanges` | Token balance changes for each affected address and coin type |
|
|
49
|
+
| `objectTypes` | Map of object ID to type string for all changed objects |
|
|
50
|
+
| `transaction` | The full transaction data (sender, commands, gas config) |
|
|
51
|
+
| `bcs` | Raw BCS-encoded transaction bytes |
|
|
52
|
+
| `commandResults` | BCS-encoded return values and mutated references from each command _(simulation only)_ |
|
|
53
|
+
|
|
54
|
+
The `commandResults` field is unique to simulation. It is not available on `executeTransaction`.
|
|
55
|
+
Each entry contains `returnValues` and `mutatedReferences`, both as BCS-encoded `Uint8Array` values
|
|
56
|
+
that you can decode with the [BCS library](/bcs).
|
|
57
|
+
|
|
58
|
+
## With a keypair (backend or scripts)
|
|
59
|
+
|
|
60
|
+
The simplest approach. The keypair signs the transaction and submits it to the network in one call:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
|
|
64
|
+
const keypair = Ed25519Keypair.fromSecretKey('suiprivkey1...');
|
|
65
|
+
const grpcClient = new SuiGrpcClient({
|
|
66
|
+
network: 'mainnet',
|
|
67
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = await keypair.signAndExecuteTransaction({
|
|
71
|
+
transaction: tx,
|
|
72
|
+
client: grpcClient,
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`fromSecretKey` accepts a Bech32-encoded private key (`suiprivkey1...`) or a raw 32-byte
|
|
77
|
+
`Uint8Array`. You can also use `Ed25519Keypair.deriveKeypair(mnemonic)` to derive from a mnemonic
|
|
78
|
+
phrase.
|
|
79
|
+
|
|
80
|
+
This method automatically sets the sender to the keypair's address, builds the transaction, signs
|
|
81
|
+
it, and executes it. The result includes the transaction data and effects by default.
|
|
82
|
+
|
|
83
|
+
Available keypair types:
|
|
84
|
+
|
|
85
|
+
- `Ed25519Keypair` from `@mysten/sui/keypairs/ed25519`
|
|
86
|
+
- `Secp256k1Keypair` from `@mysten/sui/keypairs/secp256k1`
|
|
87
|
+
- `Secp256r1Keypair` from `@mysten/sui/keypairs/secp256r1`
|
|
88
|
+
- `PasskeyKeypair` from `@mysten/sui/keypairs/passkey`
|
|
89
|
+
|
|
90
|
+
## With dapp-kit (React frontend)
|
|
91
|
+
|
|
92
|
+
In a React app, use the `useSignAndExecuteTransaction` hook. The user's connected wallet signs and
|
|
93
|
+
submits the transaction:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
|
|
97
|
+
function SendButton() {
|
|
98
|
+
const { mutate: signAndExecute } = useSignAndExecuteTransaction();
|
|
99
|
+
|
|
100
|
+
function handleClick() {
|
|
101
|
+
const tx = new Transaction();
|
|
102
|
+
// ... build your transaction ...
|
|
103
|
+
|
|
104
|
+
signAndExecute(
|
|
105
|
+
{ transaction: tx },
|
|
106
|
+
{
|
|
107
|
+
onSuccess: (result) => {
|
|
108
|
+
console.log('Transaction digest:', result.digest);
|
|
109
|
+
},
|
|
110
|
+
onError: (error) => {
|
|
111
|
+
console.error('Transaction failed:', error);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return <button onClick={handleClick}>Send</button>;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See the [dapp-kit documentation](/dapp-kit) for full setup instructions.
|
|
122
|
+
|
|
123
|
+
## Sign without executing
|
|
124
|
+
|
|
125
|
+
Sometimes you need the signature without immediately executing, such as for multi-sig, sponsored
|
|
126
|
+
transactions, or delayed execution.
|
|
127
|
+
|
|
128
|
+
### With a keypair
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Build the transaction bytes first
|
|
132
|
+
tx.setSender(keypair.toSuiAddress());
|
|
133
|
+
const bytes = await tx.build({ client: grpcClient });
|
|
134
|
+
|
|
135
|
+
// Sign the bytes
|
|
136
|
+
const { signature } = await keypair.signTransaction(bytes);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### With dapp-kit
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
|
|
143
|
+
function SignButton() {
|
|
144
|
+
const { mutate: signTransaction } = useSignTransaction();
|
|
145
|
+
|
|
146
|
+
function handleClick() {
|
|
147
|
+
const tx = new Transaction();
|
|
148
|
+
// ... build your transaction ...
|
|
149
|
+
|
|
150
|
+
signTransaction(
|
|
151
|
+
{ transaction: tx },
|
|
152
|
+
{
|
|
153
|
+
onSuccess: ({ bytes, signature }) => {
|
|
154
|
+
// Send bytes + signature to your backend, sponsor, etc.
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return <button onClick={handleClick}>Sign</button>;
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Manual execution
|
|
165
|
+
|
|
166
|
+
When you already have the transaction bytes and signature(s), execute directly through the client:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const result = await grpcClient.executeTransaction({
|
|
170
|
+
transaction: bytes, // Uint8Array
|
|
171
|
+
signatures: [signature], // string[]
|
|
172
|
+
include: {
|
|
173
|
+
effects: true,
|
|
174
|
+
events: true,
|
|
175
|
+
balanceChanges: true,
|
|
176
|
+
objectTypes: true,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The `include` parameter controls what data is returned with the result:
|
|
182
|
+
|
|
183
|
+
| Field | Description |
|
|
184
|
+
| ---------------- | -------------------------------------------------------- |
|
|
185
|
+
| `transaction` | The full transaction data (sender, commands, gas) |
|
|
186
|
+
| `effects` | Execution effects (created, mutated, or deleted objects) |
|
|
187
|
+
| `events` | Move events emitted during execution |
|
|
188
|
+
| `balanceChanges` | Token balance changes for each affected address |
|
|
189
|
+
| `objectTypes` | Map of object ID to type for changed objects |
|
|
190
|
+
| `bcs` | Raw BCS bytes of the transaction |
|
|
191
|
+
|
|
192
|
+
## Observing results
|
|
193
|
+
|
|
194
|
+
### Checking success or failure
|
|
195
|
+
|
|
196
|
+
Every transaction result is a discriminated union. Always check which variant you received:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const result = await keypair.signAndExecuteTransaction({
|
|
200
|
+
transaction: tx,
|
|
201
|
+
client: grpcClient,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (result.$kind === 'FailedTransaction') {
|
|
205
|
+
const { status } = result.FailedTransaction;
|
|
206
|
+
console.error('Transaction failed:', status.error?.message);
|
|
207
|
+
} else {
|
|
208
|
+
console.log('Transaction succeeded:', result.Transaction.digest);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
You can also use the shorthand:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
const tx = result.Transaction ?? result.FailedTransaction;
|
|
216
|
+
if (!tx.status.success) {
|
|
217
|
+
throw new Error(`Failed: ${tx.status.error?.message}`);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Waiting for indexing
|
|
222
|
+
|
|
223
|
+
After a transaction executes, read APIs (like `getBalance` or `getObject`) might not immediately
|
|
224
|
+
show the effects. You must also wait before executing a subsequent transaction that depends on
|
|
225
|
+
objects created or modified by the first one. Use `waitForTransaction` to ensure consistency:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const result = await keypair.signAndExecuteTransaction({
|
|
229
|
+
transaction: tx,
|
|
230
|
+
client: grpcClient,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Wait for the transaction to be indexed
|
|
234
|
+
await grpcClient.waitForTransaction({ result });
|
|
235
|
+
|
|
236
|
+
// Now reads will reflect the transaction's effects
|
|
237
|
+
const { balance } = await grpcClient.getBalance({ owner: myAddress });
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
You can also wait by digest:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
await grpcClient.waitForTransaction({ digest: result.Transaction.digest });
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Gas configuration
|
|
247
|
+
|
|
248
|
+
Every Sui transaction costs gas. The SDK handles gas automatically in most cases. It sets the gas
|
|
249
|
+
price, estimates the budget, and selects how to pay. You only need to configure gas explicitly for
|
|
250
|
+
special cases.
|
|
251
|
+
|
|
252
|
+
### Defaults
|
|
253
|
+
|
|
254
|
+
When you don't configure gas explicitly, the SDK:
|
|
255
|
+
|
|
256
|
+
1. **Gas price**: Uses the network's reference gas price
|
|
257
|
+
2. **Gas budget**: Simulates the transaction and uses the result to set an appropriate budget
|
|
258
|
+
3. **Gas payment**: Uses address balances, falling back to coin objects when the balance is below
|
|
259
|
+
the budget
|
|
260
|
+
|
|
261
|
+
For most transactions, the defaults work well and you don't need to change anything.
|
|
262
|
+
|
|
263
|
+
### Explicit gas settings
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// Override the reference gas price
|
|
267
|
+
tx.setGasPrice(1500);
|
|
268
|
+
|
|
269
|
+
// Override the simulated budget (in MIST)
|
|
270
|
+
tx.setGasBudget(50_000_000);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Gas payment with coin objects
|
|
274
|
+
|
|
275
|
+
Specify exactly which coins to use for gas. The system merges these coins into a single gas coin
|
|
276
|
+
before execution:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
tx.setGasPayment([
|
|
280
|
+
{ objectId: '0xCoin1', version: '1', digest: 'abc...' },
|
|
281
|
+
{ objectId: '0xCoin2', version: '2', digest: 'def...' },
|
|
282
|
+
]);
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
The coins you provide must not overlap with any object inputs in your transaction.
|
|
286
|
+
|
|
287
|
+
### Gas payment with address balance
|
|
288
|
+
|
|
289
|
+
To pay gas from your address balance instead of coin objects, pass an empty array:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
tx.setGasPayment([]);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
This is particularly useful for [offline building](./offline) and
|
|
296
|
+
[sponsored transactions](#sponsored-transactions), because there are no coin object versions to look
|
|
297
|
+
up or coordinate.
|
|
298
|
+
|
|
299
|
+
### The gas coin (`tx.gas`)
|
|
300
|
+
|
|
301
|
+
`tx.gas` references the coin used for gas payment. You can split SUI from it, merge coins into it,
|
|
302
|
+
or transfer it to another address:
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
const [coin] = tx.splitCoins(tx.gas, [1_000_000_000]);
|
|
306
|
+
tx.transferObjects([coin], '0xRecipientAddress');
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
> **Warning:** `tx.gas` only works when gas is paid from coin objects. If gas is paid from address balances
|
|
310
|
+
> (through `setGasPayment([])`), `tx.gas` is not available. Use [`tx.coin()`](./coins-and-balances)
|
|
311
|
+
> instead, which works in both cases.
|
|
312
|
+
|
|
313
|
+
## Sponsored transactions
|
|
314
|
+
|
|
315
|
+
In a sponsored transaction, someone other than the sender pays for gas. There are two flows
|
|
316
|
+
depending on whether gas is paid from coin objects or address balances.
|
|
317
|
+
|
|
318
|
+
### Coin-based sponsorship
|
|
319
|
+
|
|
320
|
+
The traditional flow where the sponsor provides specific gas coin objects:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// 1. User builds transaction kind bytes (no gas info)
|
|
324
|
+
const tx = new Transaction();
|
|
325
|
+
// ... add commands ...
|
|
326
|
+
const kindBytes = await tx.build({ client: grpcClient, onlyTransactionKind: true });
|
|
327
|
+
|
|
328
|
+
// 2. Sponsor wraps with gas info
|
|
329
|
+
const sponsoredTx = Transaction.fromKind(kindBytes);
|
|
330
|
+
sponsoredTx.setSender(userAddress);
|
|
331
|
+
sponsoredTx.setGasOwner(sponsorAddress);
|
|
332
|
+
sponsoredTx.setGasPayment(sponsorGasCoins);
|
|
333
|
+
|
|
334
|
+
// 3. Build the full transaction
|
|
335
|
+
const fullBytes = await sponsoredTx.build({ client: grpcClient });
|
|
336
|
+
|
|
337
|
+
// 4. Both parties sign
|
|
338
|
+
const { signature: userSignature } = await userKeypair.signTransaction(fullBytes);
|
|
339
|
+
const { signature: sponsorSignature } = await sponsorKeypair.signTransaction(fullBytes);
|
|
340
|
+
|
|
341
|
+
// 5. Execute with both signatures
|
|
342
|
+
const result = await grpcClient.executeTransaction({
|
|
343
|
+
transaction: fullBytes,
|
|
344
|
+
signatures: [userSignature, sponsorSignature],
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
> **Warning:** The user must wait for the sponsor to set gas coins before signing, because gas coins are part of
|
|
349
|
+
> the signed transaction data.
|
|
350
|
+
|
|
351
|
+
### Address balance sponsorship
|
|
352
|
+
|
|
353
|
+
When the sponsor pays from their address balance instead of specific coins, the flow is simpler
|
|
354
|
+
because there are no coin object references to coordinate:
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
// 1. User builds and signs the transaction first
|
|
358
|
+
const tx = new Transaction();
|
|
359
|
+
tx.setSender(userAddress);
|
|
360
|
+
tx.setGasOwner(sponsorAddress);
|
|
361
|
+
tx.setGasPayment([]); // empty array = use address balance for gas
|
|
362
|
+
// ... add commands ...
|
|
363
|
+
|
|
364
|
+
const bytes = await tx.build({ client: grpcClient });
|
|
365
|
+
const { signature: userSignature } = await userKeypair.signTransaction(bytes);
|
|
366
|
+
|
|
367
|
+
// 2. Sponsor signs (can happen asynchronously)
|
|
368
|
+
const { signature: sponsorSignature } = await sponsorKeypair.signTransaction(bytes);
|
|
369
|
+
|
|
370
|
+
// 3. Either party executes
|
|
371
|
+
const result = await grpcClient.executeTransaction({
|
|
372
|
+
transaction: bytes,
|
|
373
|
+
signatures: [userSignature, sponsorSignature],
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
The key advantage: the sender can sign before the sponsor, enabling simpler async flows. No need to
|
|
378
|
+
coordinate gas coin selection.
|
|
379
|
+
|
|
380
|
+
### Sending tokens in sponsored transactions
|
|
381
|
+
|
|
382
|
+
When building sponsored transactions, set `useGasCoin: false` so the SDK doesn't try to split the
|
|
383
|
+
gas coin (which belongs to the sponsor):
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
|
|
387
|
+
const tx = new Transaction();
|
|
388
|
+
|
|
389
|
+
// Send to address balance (preferred)
|
|
390
|
+
tx.moveCall({
|
|
391
|
+
target: '0x2::balance::send_funds',
|
|
392
|
+
typeArguments: ['0x2::sui::SUI'],
|
|
393
|
+
arguments: [
|
|
394
|
+
tx.balance({ balance: 1_000_000_000n, useGasCoin: false }),
|
|
395
|
+
tx.pure.address('0xRecipientAddress'),
|
|
396
|
+
],
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// Or send as a coin object
|
|
400
|
+
tx.transferObjects([tx.coin({ balance: 1_000_000_000, useGasCoin: false })], '0xRecipientAddress');
|
|
401
|
+
```
|
package/dist/zksend/index.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten/docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "LLM-friendly documentation for the Sui TypeScript SDK ecosystem",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
"react": "^19.2.3",
|
|
30
30
|
"react-dom": "^19.2.3",
|
|
31
31
|
"@mysten/aws-kms-signer": "0.1.2",
|
|
32
|
+
"@mysten/bcs": "2.0.5",
|
|
32
33
|
"@mysten/dapp-kit": "1.0.6",
|
|
33
34
|
"@mysten/dapp-kit-core": "1.3.2",
|
|
34
35
|
"@mysten/dapp-kit-react": "2.0.3",
|
|
35
|
-
"@mysten/bcs": "2.0.5",
|
|
36
|
-
"@mysten/deepbook-v3": "1.3.6",
|
|
37
36
|
"@mysten/enoki-connect": "1.0.4",
|
|
38
37
|
"@mysten/enoki": "1.0.8",
|
|
38
|
+
"@mysten/deepbook-v3": "1.4.1",
|
|
39
39
|
"@mysten/gcp-kms-signer": "0.1.2",
|
|
40
|
-
"@mysten/ledger-signer": "0.1.2",
|
|
41
40
|
"@mysten/kiosk": "1.2.6",
|
|
42
41
|
"@mysten/payment-kit": "0.1.11",
|
|
43
42
|
"@mysten/seal": "1.1.3",
|
|
44
|
-
"@mysten/signers": "1.0.5",
|
|
45
43
|
"@mysten/slush-wallet": "1.0.5",
|
|
44
|
+
"@mysten/ledger-signer": "0.1.2",
|
|
45
|
+
"@mysten/signers": "1.0.5",
|
|
46
46
|
"@mysten/sui": "2.17.0",
|
|
47
47
|
"@mysten/utils": "0.3.3",
|
|
48
|
-
"@mysten/walrus": "1.1.7",
|
|
49
48
|
"@mysten/wallet-standard": "0.20.3",
|
|
49
|
+
"@mysten/walrus": "1.1.7",
|
|
50
50
|
"@mysten/webcrypto-signer": "0.1.2",
|
|
51
51
|
"@mysten/zksend": "1.1.2",
|
|
52
52
|
"@mysten/suins": "1.1.4"
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"dev": "next dev",
|
|
70
70
|
"start": "next start",
|
|
71
71
|
"postinstall": "fumadocs-mdx",
|
|
72
|
+
"test": "node scripts/validate-llm-docs.ts",
|
|
72
73
|
"validate-docs": "node scripts/validate-llm-docs.ts",
|
|
73
74
|
"prettier:check": "prettier -c --ignore-unknown .",
|
|
74
75
|
"prettier:fix": "prettier -w --ignore-unknown .",
|
package/dist/sui/faucet.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Faucet
|
|
2
|
-
|
|
3
|
-
> Request test SUI tokens from the faucet on Devnet, Testnet, or local networks.
|
|
4
|
-
|
|
5
|
-
Devnet, Testnet, and local networks include faucets that mint SUI. You can use the Sui TypeScript
|
|
6
|
-
SDK to call a network's faucet and provide SUI to the address you provide.
|
|
7
|
-
|
|
8
|
-
To request SUI from a faucet, import the `requestSuiFromFaucetV2` function from the
|
|
9
|
-
`@mysten/sui/faucet` package to your project.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Use `requestSuiFromFaucetV2` in your TypeScript code to request SUI from the network's faucet.
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
await requestSuiFromFaucetV2({
|
|
19
|
-
host: getFaucetHost('testnet'),
|
|
20
|
-
recipient: <RECIPIENT_ADDRESS>,
|
|
21
|
-
});
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
> **Note:** Faucets on Devnet and Testnet are rate limited. If you run the script too many times, you surpass
|
|
25
|
-
> the limit and must wait to successfully run it again. For Testnet, the best way to get SUI is
|
|
26
|
-
> through the Web UI: `faucet.sui.io`.
|
package/dist/sui/hello-sui.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Hello Sui
|
|
2
|
-
|
|
3
|
-
> Build your first Sui application with the TypeScript SDK.
|
|
4
|
-
|
|
5
|
-
This basic example introduces you to the Sui TypeScript SDK. The Node.js example mints SUI on a Sui
|
|
6
|
-
network and then queries the address to get a sum for the owned SUI. You don't need to use an IDE to
|
|
7
|
-
complete the example, but one like Microsoft Visual Studio Code helps centralize more advanced
|
|
8
|
-
projects.
|
|
9
|
-
|
|
10
|
-
## Before you begin
|
|
11
|
-
|
|
12
|
-
You need an address on a Sui development network (Devnet, Testnet, or local). If you don't already
|
|
13
|
-
have an address, use the [Sui Client CLI](https://docs.sui.io/references/cli/client) or the
|
|
14
|
-
[Sui Wallet browser extension](https://docs.mystenlabs.com) to create one.
|
|
15
|
-
|
|
16
|
-
You also need [Node.js](https://nodejs.org/en/download/current) and a package manager like
|
|
17
|
-
[pnpm](https://pnpm.io/installation) to follow this example, so install them on your system if you
|
|
18
|
-
haven't already.
|
|
19
|
-
|
|
20
|
-
## Start a project
|
|
21
|
-
|
|
22
|
-
Using a Terminal or Console, create a folder on your system (`hello-sui` in this example) and make
|
|
23
|
-
it the working directory.
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
mkdir hello-sui
|
|
27
|
-
cd hello-sui
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
When you use a package manager to install the necessary packages, it downloads the modules to your
|
|
31
|
-
`node_modules` folder and adds the references to your `package.json` file, creating the file if it
|
|
32
|
-
doesn't already exist. For this example, you need only the Sui TypeScript SDK:
|
|
33
|
-
|
|
34
|
-
```sh npm2yarn
|
|
35
|
-
npm i -D @mysten/sui
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
The SDK is published as an ESM only package, so you also need to set `"type": "module"` in your
|
|
39
|
-
`package.json`. Your `package.json` file should look like this:
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"type": "module",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@mysten/sui": "^<VERSION_NUMBER>"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Get some SUI for your account
|
|
51
|
-
|
|
52
|
-
Instead of a 'Hello World' output to your console, this example introduces some SUI to your wallet
|
|
53
|
-
address. You must be on Devnet, Testnet, or a local network to use a faucet for minting SUI.
|
|
54
|
-
|
|
55
|
-
Create a new `index.js` file in the root of your project with the following code.
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
|
|
59
|
-
// replace <YOUR_SUI_ADDRESS> with your actual address, which is in the form 0x123...
|
|
60
|
-
const MY_ADDRESS = '<YOUR_SUI_ADDRESS>';
|
|
61
|
-
|
|
62
|
-
// create a new SuiGrpcClient object pointing to the network you want to use
|
|
63
|
-
const suiClient = new SuiGrpcClient({
|
|
64
|
-
network: 'devnet',
|
|
65
|
-
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Convert MIST to Sui
|
|
69
|
-
const balance = (balance) => {
|
|
70
|
-
return Number.parseInt(balance.totalBalance) / Number(MIST_PER_SUI);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// store the JSON representation for the SUI the address owns before using faucet
|
|
74
|
-
const suiBefore = await suiClient.getBalance({
|
|
75
|
-
owner: MY_ADDRESS,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
await requestSuiFromFaucetV2({
|
|
79
|
-
// use getFaucetHost to make sure you're using correct faucet address
|
|
80
|
-
// you can also just use the address (see Sui TypeScript SDK Quick Start for values)
|
|
81
|
-
host: getFaucetHost('devnet'),
|
|
82
|
-
recipient: MY_ADDRESS,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// store the JSON representation for the SUI the address owns after using faucet
|
|
86
|
-
const suiAfter = await suiClient.getBalance({
|
|
87
|
-
owner: MY_ADDRESS,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// Output result to console.
|
|
91
|
-
console.log(
|
|
92
|
-
`Balance before faucet: ${balance(suiBefore)} SUI. Balance after: ${balance(
|
|
93
|
-
suiAfter,
|
|
94
|
-
)} SUI. Hello, SUI!`,
|
|
95
|
-
);
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Save the file, then use Node.js to run it in your Console or Terminal:
|
|
99
|
-
|
|
100
|
-
```sh
|
|
101
|
-
node index.js
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
The code imports the `requestSuiFromFaucetV2` function from the SDK and calls it to mint SUI for the
|
|
105
|
-
provided address. The code also imports `SuiGrpcClient` to create a new client on the Sui network
|
|
106
|
-
that it uses to query the address and output the amount of SUI the address owns before and after
|
|
107
|
-
using the faucet. You can check the total SUI for your address using the Sui Wallet or Sui Client
|
|
108
|
-
CLI.
|
|
109
|
-
|
|
110
|
-
> **Note:** Faucets on Devnet and Testnet are rate limited. If you run the script too many times, you surpass
|
|
111
|
-
> the limit and must wait to successfully run it again. For Testnet, the best way to get SUI is
|
|
112
|
-
> through the Web UI: `faucet.sui.io`.
|
|
113
|
-
|
|
114
|
-
You can also use the [Sui Client CLI](https://docs.sui.io/references/cli/client) to perform client
|
|
115
|
-
calls on a Sui network.
|
package/dist/sui/install.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# Install Sui TypeScript SDK
|
|
2
|
-
|
|
3
|
-
> Install the @mysten/sui package and configure your project.
|
|
4
|
-
|
|
5
|
-
The Sui TypeScript SDK is available in the
|
|
6
|
-
[Sui TS SDK monorepo](https://github.com/MystenLabs/ts-sdks) and NPM.
|
|
7
|
-
|
|
8
|
-
## Install from NPM
|
|
9
|
-
|
|
10
|
-
To use the Sui TypeScript SDK in your project, run the following command in your project root:
|
|
11
|
-
|
|
12
|
-
```sh npm2yarn
|
|
13
|
-
npm i @mysten/sui
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
The SDK is published as an ESM only package. Make sure your `package.json` includes
|
|
17
|
-
`"type": "module"`:
|
|
18
|
-
|
|
19
|
-
```json
|
|
20
|
-
{
|
|
21
|
-
"type": "module"
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
If you are using TypeScript, your `tsconfig.json` should use a compatible `moduleResolution` setting
|
|
26
|
-
such as `"NodeNext"`, `"Node16"`, or `"Bundler"`. See the
|
|
27
|
-
[2.0 migration guide](/sui/migrations/sui-2.0#esm-migration) for more details.
|
|
28
|
-
|
|
29
|
-
## Experimental tag for use with a local Sui network
|
|
30
|
-
|
|
31
|
-
Projects developing against one of the onchain Sui networks (Devnet, Testnet, Mainnet) should use
|
|
32
|
-
the base SDK published in the NPM registry (previous section) because the code aligns with the
|
|
33
|
-
relevant JSON-RPC. If you are developing against a
|
|
34
|
-
[local network](https://docs.sui.io/guides/developer/getting-started/local-network) built from the
|
|
35
|
-
`main` branch of the Sui monorepo, however, you should use the `experimental`-tagged SDK package as
|
|
36
|
-
it contains the latest features (or a local build detailed in the section that follows).
|
|
37
|
-
|
|
38
|
-
```sh npm2yarn
|
|
39
|
-
npm i @mysten/sui@experimental
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Install from local build
|
|
43
|
-
|
|
44
|
-
To build the SDK from the Sui monorepo, you must use [pnpm](https://pnpm.io/). With pnpm installed,
|
|
45
|
-
run the following command from the `sui` root directory:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# Install all dependencies
|
|
49
|
-
pnpm install
|
|
50
|
-
# Run the build for the TypeScript SDK
|
|
51
|
-
pnpm sdk build
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
With the SDK built, you can import the library from your `sui` project. To do so, use a path to the
|
|
55
|
-
`ts-sdks/packages/sui` directory that is relative to your project. For example, if you created a
|
|
56
|
-
folder `my-sui-project` at the same level as `sui`, use the following to import the locally built
|
|
57
|
-
Sui TypeScript package:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pnpm add ../ts-sdks/packages/sui
|
|
61
|
-
```
|