@mysten/sui 2.16.3 → 2.18.0

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.
Files changed (138) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/graphql/generated/queries.d.mts.map +1 -1
  5. package/dist/graphql/generated/queries.mjs.map +1 -1
  6. package/dist/graphql/generated/tada-env.d.mts +82 -1
  7. package/dist/grpc/client.d.mts +2 -0
  8. package/dist/grpc/client.d.mts.map +1 -1
  9. package/dist/grpc/client.mjs +2 -0
  10. package/dist/grpc/client.mjs.map +1 -1
  11. package/dist/grpc/proto/google/protobuf/struct.mjs +1 -1
  12. package/dist/grpc/proto/google/protobuf/struct.mjs.map +1 -1
  13. package/dist/grpc/proto/google/rpc/status.mjs +1 -1
  14. package/dist/grpc/proto/google/rpc/status.mjs.map +1 -1
  15. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +66 -0
  16. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts.map +1 -0
  17. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.mjs +48 -0
  18. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.mjs.map +1 -0
  19. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.d.mts +135 -0
  20. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.d.mts.map +1 -0
  21. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.mjs +144 -0
  22. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.mjs.map +1 -0
  23. package/dist/grpc/proto/sui/rpc/v2/checkpoint.mjs +1 -1
  24. package/dist/grpc/proto/sui/rpc/v2/checkpoint.mjs.map +1 -1
  25. package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.mjs +3 -3
  26. package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.mjs.map +1 -1
  27. package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.mjs +3 -3
  28. package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.mjs.map +1 -1
  29. package/dist/grpc/proto/sui/rpc/v2/effects.d.mts +71 -3
  30. package/dist/grpc/proto/sui/rpc/v2/effects.d.mts.map +1 -1
  31. package/dist/grpc/proto/sui/rpc/v2/effects.mjs +71 -5
  32. package/dist/grpc/proto/sui/rpc/v2/effects.mjs.map +1 -1
  33. package/dist/grpc/proto/sui/rpc/v2/event.mjs +1 -1
  34. package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
  35. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +2 -2
  36. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
  37. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  38. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +3 -3
  39. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  40. package/dist/grpc/proto/sui/rpc/v2/move_package.d.mts.map +1 -1
  41. package/dist/grpc/proto/sui/rpc/v2/move_package.mjs +13 -13
  42. package/dist/grpc/proto/sui/rpc/v2/move_package.mjs.map +1 -1
  43. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  44. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +1 -1
  45. package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
  46. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  47. package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
  48. package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
  49. package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
  50. package/dist/grpc/proto/sui/rpc/v2/signature.mjs +3 -3
  51. package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
  52. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  53. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
  54. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +1 -1
  55. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
  56. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  57. package/dist/grpc/proto/sui/rpc/v2/state_service.d.mts.map +1 -1
  58. package/dist/grpc/proto/sui/rpc/v2/state_service.mjs +3 -3
  59. package/dist/grpc/proto/sui/rpc/v2/state_service.mjs.map +1 -1
  60. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  61. package/dist/grpc/proto/sui/rpc/v2/system_state.mjs +2 -2
  62. package/dist/grpc/proto/sui/rpc/v2/system_state.mjs.map +1 -1
  63. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  64. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +16 -16
  65. package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
  66. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +4 -4
  67. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  68. package/dist/grpc/proto/types.d.mts +3 -2
  69. package/dist/grpc/proto/types.mjs +11 -1
  70. package/dist/grpc/proto/types.mjs.map +1 -1
  71. package/dist/jsonRpc/types/params.d.mts +5 -5
  72. package/dist/transactions/Transaction.d.mts +25 -11
  73. package/dist/transactions/Transaction.d.mts.map +1 -1
  74. package/dist/transactions/Transaction.mjs +8 -3
  75. package/dist/transactions/Transaction.mjs.map +1 -1
  76. package/dist/transactions/index.d.mts +2 -2
  77. package/dist/version.mjs +1 -1
  78. package/dist/version.mjs.map +1 -1
  79. package/dist/zklogin/jwt-utils.d.mts.map +1 -1
  80. package/dist/zklogin/jwt-utils.mjs.map +1 -1
  81. package/dist/zklogin/utils.d.mts.map +1 -1
  82. package/dist/zklogin/utils.mjs +9 -0
  83. package/dist/zklogin/utils.mjs.map +1 -1
  84. package/docs/bcs.md +11 -6
  85. package/docs/clients/core.md +10 -9
  86. package/docs/clients/grpc.md +1 -1
  87. package/docs/index.md +176 -22
  88. package/docs/llms-index.md +6 -9
  89. package/docs/migrations/0.38.md +2 -2
  90. package/docs/migrations/sui-1.0.md +2 -2
  91. package/docs/migrations/sui-2.0/json-rpc-migration.md +76 -33
  92. package/docs/plugins.md +29 -5
  93. package/docs/transactions/basics.md +279 -0
  94. package/docs/transactions/coins-and-balances.md +293 -0
  95. package/docs/transactions/offline.md +192 -0
  96. package/docs/transactions/reference.md +380 -0
  97. package/docs/transactions/signing-and-execution.md +401 -0
  98. package/package.json +27 -27
  99. package/src/graphql/generated/queries.ts +46 -1
  100. package/src/graphql/generated/schema.graphql +49 -3
  101. package/src/graphql/generated/tada-env.ts +97 -1
  102. package/src/grpc/client.ts +3 -0
  103. package/src/grpc/proto/google/protobuf/struct.ts +1 -1
  104. package/src/grpc/proto/google/rpc/error_details.ts +4 -4
  105. package/src/grpc/proto/google/rpc/status.ts +1 -1
  106. package/src/grpc/proto/sui/forking/v1alpha/forking_service.client.ts +125 -0
  107. package/src/grpc/proto/sui/forking/v1alpha/forking_service.ts +230 -0
  108. package/src/grpc/proto/sui/rpc/v2/checkpoint.ts +1 -1
  109. package/src/grpc/proto/sui/rpc/v2/checkpoint_contents.ts +3 -3
  110. package/src/grpc/proto/sui/rpc/v2/checkpoint_summary.ts +3 -3
  111. package/src/grpc/proto/sui/rpc/v2/effects.ts +112 -6
  112. package/src/grpc/proto/sui/rpc/v2/event.ts +1 -1
  113. package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +2 -2
  114. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +3 -3
  115. package/src/grpc/proto/sui/rpc/v2/move_package.ts +19 -13
  116. package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +1 -1
  117. package/src/grpc/proto/sui/rpc/v2/object.ts +7 -1
  118. package/src/grpc/proto/sui/rpc/v2/signature.ts +3 -3
  119. package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +7 -1
  120. package/src/grpc/proto/sui/rpc/v2/state_service.ts +9 -3
  121. package/src/grpc/proto/sui/rpc/v2/system_state.ts +2 -2
  122. package/src/grpc/proto/sui/rpc/v2/transaction.ts +22 -16
  123. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +4 -4
  124. package/src/grpc/proto/types.ts +1 -0
  125. package/src/jsonRpc/types/params.ts +5 -5
  126. package/src/transactions/Transaction.ts +36 -5
  127. package/src/transactions/index.ts +1 -0
  128. package/src/version.ts +1 -1
  129. package/src/zklogin/jwt-utils.ts +3 -0
  130. package/src/zklogin/utils.ts +17 -0
  131. package/docs/faucet.md +0 -26
  132. package/docs/hello-sui.md +0 -115
  133. package/docs/install.md +0 -61
  134. package/docs/transaction-building/basics.md +0 -299
  135. package/docs/transaction-building/gas.md +0 -61
  136. package/docs/transaction-building/intents.md +0 -62
  137. package/docs/transaction-building/offline.md +0 -73
  138. package/docs/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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.16.3",
6
+ "version": "2.18.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -131,45 +131,45 @@
131
131
  "access": "public"
132
132
  },
133
133
  "devDependencies": {
134
- "@0no-co/graphqlsp": "^1.15.2",
135
- "@graphql-codegen/add": "^6.0.0",
136
- "@graphql-codegen/cli": "^6.1.1",
137
- "@graphql-codegen/typed-document-node": "^6.1.5",
138
- "@graphql-codegen/typescript": "5.0.7",
139
- "@graphql-codegen/typescript-document-nodes": "5.0.7",
140
- "@graphql-codegen/typescript-operations": "^5.0.7",
141
- "@grpc/grpc-js": "^1.13.3",
134
+ "@0no-co/graphqlsp": "^1.17.0",
135
+ "@graphql-codegen/add": "^7.0.1",
136
+ "@graphql-codegen/cli": "^7.1.2",
137
+ "@graphql-codegen/typed-document-node": "^7.0.3",
138
+ "@graphql-codegen/typescript": "6.0.2",
139
+ "@graphql-codegen/typescript-document-nodes": "6.0.1",
140
+ "@graphql-codegen/typescript-operations": "^6.0.3",
141
+ "@grpc/grpc-js": ">=1.14.4",
142
142
  "@parcel/watcher": "^2.5.4",
143
143
  "@protobuf-ts/grpc-transport": "^2.11.1",
144
- "@types/node": "^25.0.8",
144
+ "@types/node": "^25.9.3",
145
145
  "@types/tmp": "^0.2.6",
146
146
  "cross-env": "^10.1.0",
147
147
  "graphql-config": "^5.1.5",
148
- "msw": "^2.12.7",
149
- "tmp": "^0.2.5",
148
+ "msw": "^2.14.6",
149
+ "tmp": "^0.2.7",
150
150
  "ts-retry-promise": "^0.8.1",
151
- "typescript": "^5.9.3",
152
- "vite": "^8.0.5",
151
+ "typescript": "^6.0.3",
152
+ "vite": "^8.0.16",
153
153
  "vite-tsconfig-paths": "^6.0.4",
154
- "vitest": "^4.0.17",
155
- "wait-on": "^9.0.3"
154
+ "vitest": "^4.1.8",
155
+ "wait-on": "^9.0.10"
156
156
  },
157
157
  "dependencies": {
158
158
  "@graphql-typed-document-node/core": "^3.2.0",
159
- "@noble/curves": "^2.0.1",
160
- "@noble/hashes": "^2.0.1",
159
+ "@noble/curves": "^2.2.0",
160
+ "@noble/hashes": "^2.2.0",
161
161
  "@protobuf-ts/grpcweb-transport": "^2.11.1",
162
162
  "@protobuf-ts/runtime": "^2.11.1",
163
163
  "@protobuf-ts/runtime-rpc": "^2.11.1",
164
- "@scure/base": "^2.0.0",
165
- "@scure/bip32": "^2.0.1",
166
- "@scure/bip39": "^2.0.1",
167
- "gql.tada": "^1.9.0",
168
- "graphql": "^16.12.0",
164
+ "@scure/base": "^2.2.0",
165
+ "@scure/bip32": "^2.2.0",
166
+ "@scure/bip39": "^2.2.0",
167
+ "gql.tada": "^1.10.1",
168
+ "graphql": "^16.14.2",
169
169
  "poseidon-lite": "0.2.1",
170
- "valibot": "^1.2.0",
171
- "@mysten/bcs": "^2.0.5",
172
- "@mysten/utils": "^0.3.3"
170
+ "valibot": "^1.4.1",
171
+ "@mysten/utils": "^0.4.0",
172
+ "@mysten/bcs": "^2.1.0"
173
173
  },
174
174
  "scripts": {
175
175
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -178,7 +178,7 @@
178
178
  "codegen:version": "node genversion.mjs",
179
179
  "codegen:grpc": "rm -rf src/grpc/proto && mkdir src/grpc/proto && pnpm codegen:grpc-protoc && pnpm codegen:grpc-header && pnpm codegen:grpc-extensions && pnpm codegen:grpc-types",
180
180
  "codegen:grpc-types": "tsx scripts/generate-grpc-types.ts",
181
- "codegen:grpc-protoc": "protoc --ts_out ./src/grpc/proto --ts_opt force_server_none --ts_opt optimize_code_size --ts_opt ts_nocheck -I ../../../sui-apis/proto -I ../../../sui-apis/proto ../../../sui-apis/proto/sui/rpc/v2/*.proto ../../../sui-apis/proto/google/*/*.proto",
181
+ "codegen:grpc-protoc": "protoc --ts_out ./src/grpc/proto --ts_opt force_server_none --ts_opt optimize_code_size --ts_opt ts_nocheck -I ../../../sui-apis/proto -I ../../../sui/crates/sui-fork/proto ../../../sui-apis/proto/sui/rpc/v2/*.proto ../../../sui-apis/proto/google/*/*.proto ../../../sui/crates/sui-fork/proto/sui/forking/v1alpha/*.proto",
182
182
  "codegen:grpc-header": "find src/grpc/proto -type f -exec sh -c 'echo \"// Copyright (c) Mysten Labs, Inc.\\n// SPDX-License-Identifier: Apache-2.0\\n\" | cat - {} > temp && mv temp {}' \\;",
183
183
  "codegen:grpc-extensions": "find src/grpc/proto -name '*.ts' | xargs sed -i '' -E 's/from \"(\\.[^\"]+)\"/from \"\\1.js\"/g'",
184
184
  "build": "rm -rf dist && node genversion.mjs && tsc --noEmit && tsdown",
@@ -1991,6 +1991,14 @@ export type Input = {
1991
1991
  ix?: Maybe<Scalars['Int']['output']>;
1992
1992
  };
1993
1993
 
1994
+ /** An enum that specifies the intent scope for signature verification. */
1995
+ export enum IntentScope {
1996
+ /** Indicates that the bytes are to be parsed as a personal message. */
1997
+ PersonalMessage = 'PERSONAL_MESSAGE',
1998
+ /** Indicates that the bytes are to be parsed as transaction data bytes. */
1999
+ TransactionData = 'TRANSACTION_DATA'
2000
+ }
2001
+
1994
2002
  /** Information used by a package to link to a specific version of its dependency. */
1995
2003
  export type Linkage = {
1996
2004
  __typename?: 'Linkage';
@@ -3706,7 +3714,9 @@ export type Query = {
3706
3714
  /** The network's genesis checkpoint digest (uniquely identifies the network), Base58-encoded. */
3707
3715
  chainIdentifier: Scalars['String']['output'];
3708
3716
  /**
3709
- * Fetch a checkpoint by its sequence number, or the latest checkpoint if no sequence number is provided.
3717
+ * Fetch a checkpoint by its sequence number or digest, or the latest checkpoint if neither is provided.
3718
+ *
3719
+ * It is an error to specify both `sequenceNumber` and `digest`.
3710
3720
  *
3711
3721
  * Returns `null` if the checkpoint does not exist in the store, either because it never existed or because it was pruned.
3712
3722
  */
@@ -3882,6 +3892,22 @@ export type Query = {
3882
3892
  * Fails if the type is malformed, returns `null` if a type mentioned does not exist.
3883
3893
  */
3884
3894
  type?: Maybe<MoveType>;
3895
+ /**
3896
+ * Verify a signature is from the given `author`.
3897
+ *
3898
+ * Supports all signature types: Ed25519, Secp256k1, Secp256r1, MultiSig, ZkLogin, and
3899
+ * Passkey.
3900
+ *
3901
+ * Returns successfully if the signature is valid. If the signature is invalid, returns an
3902
+ * error with the reason for the failure.
3903
+ *
3904
+ * - `message` is either a serialized personal message or `TransactionData`, Base64-encoded.
3905
+ * - `signature` is a serialized signature, also Base64-encoded.
3906
+ * - `intentScope` indicates whether `message` is to be parsed as a personal message or
3907
+ * `TransactionData`.
3908
+ * - `author` is the signer's address.
3909
+ */
3910
+ verifySignature?: Maybe<SignatureVerifyResult>;
3885
3911
  /**
3886
3912
  * Verify a zkLogin signature is from the given `author`.
3887
3913
  *
@@ -3891,6 +3917,7 @@ export type Query = {
3891
3917
  * - `signature` is a serialized zkLogin signature, also Base64-encoded.
3892
3918
  * - `intentScope` indicates whether `bytes` are to be parsed as a personal message or `TransactionData`.
3893
3919
  * - `author` is the signer's address.
3920
+ * @deprecated Use `verifySignature` instead, which supports all signature types.
3894
3921
  */
3895
3922
  verifyZkLoginSignature?: Maybe<ZkLoginVerifyResult>;
3896
3923
  };
@@ -3905,6 +3932,7 @@ export type QueryAddressArgs = {
3905
3932
 
3906
3933
 
3907
3934
  export type QueryCheckpointArgs = {
3935
+ digest?: InputMaybe<Scalars['String']['input']>;
3908
3936
  sequenceNumber?: InputMaybe<Scalars['UInt53']['input']>;
3909
3937
  };
3910
3938
 
@@ -4084,6 +4112,14 @@ export type QueryTypeArgs = {
4084
4112
  };
4085
4113
 
4086
4114
 
4115
+ export type QueryVerifySignatureArgs = {
4116
+ author: Scalars['SuiAddress']['input'];
4117
+ intentScope: IntentScope;
4118
+ message: Scalars['Base64']['input'];
4119
+ signature: Scalars['Base64']['input'];
4120
+ };
4121
+
4122
+
4087
4123
  export type QueryVerifyZkLoginSignatureArgs = {
4088
4124
  author: Scalars['SuiAddress']['input'];
4089
4125
  bytes: Scalars['Base64']['input'];
@@ -4308,6 +4344,13 @@ export type SharedInput = {
4308
4344
  /** The structured details of a signature, varying by scheme. */
4309
4345
  export type SignatureScheme = Ed25519Signature | MultisigSignature | PasskeySignature | Secp256K1Signature | Secp256R1Signature | ZkLoginSignature;
4310
4346
 
4347
+ /** The result of signature verification. */
4348
+ export type SignatureVerifyResult = {
4349
+ __typename?: 'SignatureVerifyResult';
4350
+ /** Whether the signature was verified successfully. */
4351
+ success?: Maybe<Scalars['Boolean']['output']>;
4352
+ };
4353
+
4311
4354
  /** The result of simulating a transaction, including the predicted effects. */
4312
4355
  export type SimulationResult = {
4313
4356
  __typename?: 'SimulationResult';
@@ -4435,6 +4478,8 @@ export type TransactionEffects = {
4435
4478
  transaction?: Maybe<Transaction>;
4436
4479
  /** The unchanged consensus-managed objects that were referenced by this transaction. */
4437
4480
  unchangedConsensusObjects?: Maybe<UnchangedConsensusObjectConnection>;
4481
+ /** The schema version of the effects struct. */
4482
+ version?: Maybe<Scalars['Int']['output']>;
4438
4483
  };
4439
4484
 
4440
4485
 
@@ -1808,6 +1808,20 @@ type Input {
1808
1808
  }
1809
1809
 
1810
1810
 
1811
+ """
1812
+ An enum that specifies the intent scope for signature verification.
1813
+ """
1814
+ enum IntentScope {
1815
+ """
1816
+ Indicates that the bytes are to be parsed as transaction data bytes.
1817
+ """
1818
+ TRANSACTION_DATA
1819
+ """
1820
+ Indicates that the bytes are to be parsed as a personal message.
1821
+ """
1822
+ PERSONAL_MESSAGE
1823
+ }
1824
+
1811
1825
  """
1812
1826
  Arbitrary JSON data.
1813
1827
  """
@@ -3486,11 +3500,13 @@ type Query {
3486
3500
  """
3487
3501
  chainIdentifier: String!
3488
3502
  """
3489
- Fetch a checkpoint by its sequence number, or the latest checkpoint if no sequence number is provided.
3503
+ Fetch a checkpoint by its sequence number or digest, or the latest checkpoint if neither is provided.
3504
+
3505
+ It is an error to specify both `sequenceNumber` and `digest`.
3490
3506
 
3491
3507
  Returns `null` if the checkpoint does not exist in the store, either because it never existed or because it was pruned.
3492
3508
  """
3493
- checkpoint(sequenceNumber: UInt53): Checkpoint
3509
+ checkpoint(sequenceNumber: UInt53, digest: String): Checkpoint
3494
3510
  """
3495
3511
  Paginate checkpoints in the network, optionally bounded to checkpoints in the given epoch.
3496
3512
  """
@@ -3681,6 +3697,22 @@ type Query {
3681
3697
  """
3682
3698
  type(type: String!): MoveType
3683
3699
  """
3700
+ Verify a signature is from the given `author`.
3701
+
3702
+ Supports all signature types: Ed25519, Secp256k1, Secp256r1, MultiSig, ZkLogin, and
3703
+ Passkey.
3704
+
3705
+ Returns successfully if the signature is valid. If the signature is invalid, returns an
3706
+ error with the reason for the failure.
3707
+
3708
+ - `message` is either a serialized personal message or `TransactionData`, Base64-encoded.
3709
+ - `signature` is a serialized signature, also Base64-encoded.
3710
+ - `intentScope` indicates whether `message` is to be parsed as a personal message or
3711
+ `TransactionData`.
3712
+ - `author` is the signer's address.
3713
+ """
3714
+ verifySignature(message: Base64!, signature: Base64!, intentScope: IntentScope!, author: SuiAddress!): SignatureVerifyResult
3715
+ """
3684
3716
  Verify a zkLogin signature is from the given `author`.
3685
3717
 
3686
3718
  Returns successfully if the signature is valid. If the signature is invalid, returns an error with the reason for the failure.
@@ -3690,7 +3722,7 @@ type Query {
3690
3722
  - `intentScope` indicates whether `bytes` are to be parsed as a personal message or `TransactionData`.
3691
3723
  - `author` is the signer's address.
3692
3724
  """
3693
- verifyZkLoginSignature(bytes: Base64!, signature: Base64!, intentScope: ZkLoginIntentScope!, author: SuiAddress!): ZkLoginVerifyResult
3725
+ verifyZkLoginSignature(bytes: Base64!, signature: Base64!, intentScope: ZkLoginIntentScope!, author: SuiAddress!): ZkLoginVerifyResult @deprecated(reason: "Use `verifySignature` instead, which supports all signature types.")
3694
3726
  }
3695
3727
 
3696
3728
  """
@@ -3976,6 +4008,16 @@ The structured details of a signature, varying by scheme.
3976
4008
  """
3977
4009
  union SignatureScheme = Ed25519Signature | Secp256K1Signature | Secp256R1Signature | MultisigSignature | ZkLoginSignature | PasskeySignature
3978
4010
 
4011
+ """
4012
+ The result of signature verification.
4013
+ """
4014
+ type SignatureVerifyResult {
4015
+ """
4016
+ Whether the signature was verified successfully.
4017
+ """
4018
+ success: Boolean
4019
+ }
4020
+
3979
4021
  """
3980
4022
  The result of simulating a transaction, including the predicted effects.
3981
4023
  """
@@ -4194,6 +4236,10 @@ type TransactionEffects {
4194
4236
  The unchanged consensus-managed objects that were referenced by this transaction.
4195
4237
  """
4196
4238
  unchangedConsensusObjects(first: Int, after: String, last: Int, before: String): UnchangedConsensusObjectConnection
4239
+ """
4240
+ The schema version of the effects struct.
4241
+ """
4242
+ version: Int
4197
4243
  }
4198
4244
 
4199
4245
  input TransactionFilter {