@mysten/docs 0.1.17 → 0.1.19
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/bcs/llms-index.md +1 -1
- package/dist/codegen/index.md +53 -53
- package/dist/codegen/llms-index.md +1 -1
- package/dist/dapp-kit/actions/connect-wallet.md +4 -4
- package/dist/dapp-kit/actions/disconnect-wallet.md +8 -7
- package/dist/dapp-kit/actions/sign-and-execute-transaction.md +14 -14
- package/dist/dapp-kit/actions/sign-personal-message.md +8 -8
- package/dist/dapp-kit/actions/sign-transaction.md +7 -7
- package/dist/dapp-kit/actions/switch-account.md +6 -6
- package/dist/dapp-kit/actions/switch-network.md +5 -5
- package/dist/dapp-kit/dapp-kit-instance.md +19 -18
- package/dist/dapp-kit/getting-started/create-dapp.md +12 -12
- package/dist/dapp-kit/getting-started/next-js.md +12 -11
- package/dist/dapp-kit/getting-started/react.md +25 -25
- package/dist/dapp-kit/getting-started/vue.md +12 -12
- package/dist/dapp-kit/index.md +4 -4
- package/dist/dapp-kit/llms-index.md +23 -23
- package/dist/dapp-kit/react/components/connect-button.md +3 -3
- package/dist/dapp-kit/react/components/connect-modal.md +3 -3
- package/dist/dapp-kit/react/components/index.md +2 -2
- package/dist/dapp-kit/react/dapp-kit-provider.md +6 -6
- package/dist/dapp-kit/react/hooks/index.md +4 -3
- package/dist/dapp-kit/react/hooks/use-current-account.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-client.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-network.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-wallet.md +3 -3
- package/dist/dapp-kit/react/hooks/use-dapp-kit.md +5 -5
- package/dist/dapp-kit/react/hooks/use-wallet-connection.md +3 -3
- package/dist/dapp-kit/react/hooks/use-wallets.md +3 -3
- package/dist/dapp-kit/state.md +16 -16
- package/dist/dapp-kit/theming.md +27 -27
- package/dist/dapp-kit/web-components/connect-button.md +9 -9
- package/dist/dapp-kit/web-components/connect-modal.md +16 -16
- package/dist/kiosk/advanced-examples.md +1 -1
- package/dist/kiosk/from-v1.md +1 -1
- package/dist/kiosk/index.md +5 -5
- package/dist/kiosk/kiosk-client/introduction.md +6 -6
- package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +3 -3
- package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +1 -1
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +11 -11
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +1 -1
- package/dist/kiosk/kiosk-client/querying.md +1 -1
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +1 -1
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +1 -3
- package/dist/kiosk/llms-index.md +5 -5
- package/dist/llms-index.md +84 -83
- package/dist/payment-kit/getting-started.md +13 -13
- package/dist/payment-kit/index.md +13 -13
- package/dist/payment-kit/llms-index.md +5 -5
- package/dist/payment-kit/payment-kit-sdk.md +18 -18
- package/dist/payment-kit/payment-processing.md +34 -34
- package/dist/payment-kit/registry-management.md +35 -35
- package/dist/seal/index.md +5 -5
- package/dist/seal/llms-index.md +1 -1
- package/dist/slush-wallet/dapp.md +10 -10
- package/dist/slush-wallet/deep-linking.md +54 -54
- package/dist/slush-wallet/index.md +2 -2
- package/dist/slush-wallet/llms-index.md +3 -3
- package/dist/sui/bcs.md +11 -11
- package/dist/sui/clients/core.md +57 -56
- package/dist/sui/clients/graphql.md +3 -3
- package/dist/sui/clients/grpc.md +10 -10
- package/dist/sui/clients/index.md +14 -14
- package/dist/sui/clients/json-rpc.md +16 -16
- package/dist/sui/cryptography/keypairs.md +6 -6
- package/dist/sui/cryptography/multisig.md +4 -4
- package/dist/sui/cryptography/passkey.md +15 -14
- package/dist/sui/cryptography/webcrypto-signer.md +4 -4
- package/dist/sui/executors.md +18 -16
- package/dist/sui/faucet.md +3 -3
- package/dist/sui/hello-sui.md +5 -5
- package/dist/sui/index.md +12 -12
- package/dist/sui/install.md +3 -3
- package/dist/sui/llm-docs.md +9 -9
- package/dist/sui/llms-index.md +41 -41
- package/dist/sui/migrations/0.38.md +6 -6
- package/dist/sui/migrations/sui-1.0.md +32 -32
- package/dist/sui/migrations/sui-2.0/agent-prompt.md +3 -3
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +43 -43
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +1 -1
- package/dist/sui/migrations/sui-2.0/index.md +37 -37
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +53 -47
- package/dist/sui/migrations/sui-2.0/kiosk.md +8 -8
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +7 -7
- package/dist/sui/migrations/sui-2.0/seal.md +1 -1
- package/dist/sui/migrations/sui-2.0/sui.md +16 -16
- package/dist/sui/migrations/sui-2.0/suins.md +4 -3
- package/dist/sui/migrations/sui-2.0/wallet-builders.md +5 -5
- package/dist/sui/migrations/sui-2.0/walrus.md +3 -3
- package/dist/sui/migrations/sui-2.0/zksend.md +5 -5
- package/dist/sui/plugins.md +14 -14
- package/dist/sui/sdk-building.md +32 -32
- package/dist/sui/transaction-building/basics.md +13 -13
- package/dist/sui/transaction-building/gas.md +2 -3
- package/dist/sui/transaction-building/intents.md +4 -4
- package/dist/sui/transaction-building/offline.md +8 -8
- package/dist/sui/transaction-building/sponsored-transactions.md +1 -1
- package/dist/sui/utils/derived_objects.md +10 -10
- package/dist/sui/utils/index.md +8 -1
- package/dist/sui/zklogin.md +1 -1
- package/dist/walrus/index.md +1 -1
- package/dist/walrus/llms-index.md +1 -1
- package/dist/zksend/composable-claim.md +70 -0
- package/dist/zksend/index.md +2 -2
- package/dist/zksend/link-builder.md +5 -4
- package/dist/zksend/llms-index.md +3 -2
- package/package.json +8 -8
package/dist/sui/plugins.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Transaction Plugins
|
|
2
2
|
|
|
3
|
-
> Extend transaction building with reusable plugins
|
|
3
|
+
> Extend transaction building with reusable plugins.
|
|
4
4
|
|
|
5
|
-
> **Warning:** The `Transaction` plugin API is experimental and
|
|
5
|
+
> **Warning:** The `Transaction` plugin API is experimental and might change rapidly as it is being developed.
|
|
6
6
|
|
|
7
7
|
This document describes the plugin API for the `Transaction` builder. It covers internal details
|
|
8
8
|
intended for developers interested in extending the `Transaction` builder. Developers using the
|
|
@@ -19,10 +19,10 @@ modify the data and commands added to a transaction before it is serialized to J
|
|
|
19
19
|
BCS bytes. Transaction Intents are custom representations of user intents for a transaction,
|
|
20
20
|
eventually resolved to one or more commands in the transaction.
|
|
21
21
|
|
|
22
|
-
## Contents of a
|
|
22
|
+
## Contents of a transaction
|
|
23
23
|
|
|
24
|
-
When a `Transaction` is created (
|
|
25
|
-
[TransactionDataBuilder](/typedoc/classes/_mysten_sui.transactions.TransactionDataBuilder.html)
|
|
24
|
+
When a `Transaction` is created (for example, `new Transaction()`), it is initialized with an empty
|
|
25
|
+
[`TransactionDataBuilder`](/typedoc/classes/_mysten_sui.transactions.TransactionDataBuilder.html)
|
|
26
26
|
instance which stores the state of the partially built transaction. The full API of the
|
|
27
27
|
`TransactionDataBuilder` won't be covered here, but you can find the available methods and
|
|
28
28
|
properties in the
|
|
@@ -35,13 +35,13 @@ takes depend on the command, but they will be one of a few different types:
|
|
|
35
35
|
- `GasCoin`: A reference to the coin used to pay for gas.
|
|
36
36
|
- `Input`: An input to the transaction (described below).
|
|
37
37
|
- `Result`: The result of a previous command.
|
|
38
|
-
- `NestedResult`: If a previous command returns a tuple (
|
|
39
|
-
used to refer to a specific value in that tuple.
|
|
38
|
+
- `NestedResult`: If a previous command returns a tuple (for example, `SplitCoin`), a `NestedResult`
|
|
39
|
+
is used to refer to a specific value in that tuple.
|
|
40
40
|
|
|
41
41
|
Transactions also store a list of Inputs, which refer to user-provided values. Inputs can either be
|
|
42
42
|
objects or Pure values and can be represented in several different ways:
|
|
43
43
|
|
|
44
|
-
- `Pure`: An input value serialized to BCS. Pure values are generally scalar values or
|
|
44
|
+
- `Pure`: An input value serialized to BCS. Pure values are generally scalar values or basic
|
|
45
45
|
wrappers like options or vectors and cannot represent object types.
|
|
46
46
|
- `Object`: A fully resolved object reference, which will be one of the following types:
|
|
47
47
|
- `ImmOrOwnedObject`: A reference to an object, including the object's `id`, `version`, and
|
|
@@ -52,13 +52,13 @@ objects or Pure values and can be represented in several different ways:
|
|
|
52
52
|
`digest`.
|
|
53
53
|
- `UnresolvedPure`: A placeholder for a pure value that has not been serialized to BCS.
|
|
54
54
|
- `UnresolvedObject`: A partial reference to an object, often containing just the object's `id`, but
|
|
55
|
-
|
|
55
|
+
might also include a version, digest, or initialSharedVersion.
|
|
56
56
|
|
|
57
|
-
## Lifecycle of a
|
|
57
|
+
## Lifecycle of a transaction
|
|
58
58
|
|
|
59
59
|
Because transactions can contain `UnresolvedPure` and `UnresolvedObject` inputs, these values need
|
|
60
60
|
to be resolved before the transaction can be serialized to BCS. However, these unresolved inputs can
|
|
61
|
-
be represented in JSON. What
|
|
61
|
+
be represented in JSON. What might not be able to be represented in JSON are Transaction Intents.
|
|
62
62
|
Transaction Intents represent custom concepts added by plugins or third-party SDKs. To account for
|
|
63
63
|
this, the build process of a transaction is split into two phases: serialization and building.
|
|
64
64
|
Serialization prepares the transaction to be serialized to JSON by running serialization plugins,
|
|
@@ -66,7 +66,7 @@ and resolving any unsupported intents. The Build phase then runs, which runs bui
|
|
|
66
66
|
resolves any UnresolvedPure and UnresolvedObject inputs, before the transaction is serialized to
|
|
67
67
|
BCS.
|
|
68
68
|
|
|
69
|
-
## Serialization
|
|
69
|
+
## Serialization plugins
|
|
70
70
|
|
|
71
71
|
Serialization plugins can be added to a `Transaction` by calling the `addSerializationPlugin` method
|
|
72
72
|
on a `Transaction` instance. Serialization plugins are called in the order they are added and are
|
|
@@ -82,7 +82,7 @@ transaction.addSerializationPlugin(async (transactionData, buildOptions, next) =
|
|
|
82
82
|
});
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
## Build
|
|
85
|
+
## Build plugins
|
|
86
86
|
|
|
87
87
|
The build phase is responsible for taking unresolved objects and unresolved pure values and
|
|
88
88
|
converting them to their resolved versions by querying the RPC API to fetch the missing data. Build
|
|
@@ -136,7 +136,7 @@ const transaction = new Transaction();
|
|
|
136
136
|
transaction.addBuildPlugin(simpleObjectCachePlugin);
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
## Transaction
|
|
139
|
+
## Transaction intents
|
|
140
140
|
|
|
141
141
|
Transaction Intents consist of two parts: adding the intent to the transaction and resolving the
|
|
142
142
|
intent to standard commands.
|
package/dist/sui/sdk-building.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# Building SDKs
|
|
2
2
|
|
|
3
|
-
> Build custom SDKs on top of the Sui TypeScript SDK
|
|
3
|
+
> Build custom SDKs on top of the Sui TypeScript SDK.
|
|
4
4
|
|
|
5
5
|
This guide covers recommended patterns for building TypeScript SDKs that integrate with the Sui SDK.
|
|
6
6
|
Following these patterns ensures your SDK integrates seamlessly with the ecosystem, works across
|
|
7
7
|
different transports (JSON-RPC, GraphQL, gRPC), and composes well with other SDKs.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
All SDKs should depend on [`ClientWithCoreApi`](./clients/core), which is the transport-agnostic
|
|
10
|
+
interface implemented by all Sui clients. This ensures your SDK works with any client the user
|
|
11
|
+
chooses.
|
|
12
12
|
|
|
13
|
-
## Package
|
|
13
|
+
## Package setup
|
|
14
14
|
|
|
15
|
-
### Use Mysten
|
|
15
|
+
### Use Mysten packages as peer dependencies
|
|
16
16
|
|
|
17
|
-
SDKs should declare all `@mysten/*` packages as
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
SDKs should declare all `@mysten/*` packages as peer dependencies rather than direct dependencies.
|
|
18
|
+
This ensures users get a single shared instance of each package, avoiding version conflicts and
|
|
19
|
+
duplicate code.
|
|
20
20
|
|
|
21
21
|
```json title="package.json"
|
|
22
22
|
{
|
|
@@ -40,14 +40,14 @@ This approach:
|
|
|
40
40
|
- Avoids subtle bugs from mismatched package instances
|
|
41
41
|
- Allows the SDK to work with any compatible client
|
|
42
42
|
|
|
43
|
-
## Client
|
|
43
|
+
## Client extensions
|
|
44
44
|
|
|
45
45
|
The recommended way to build SDKs is using the **client extension pattern**. This allows your SDK to
|
|
46
46
|
extend the Sui client with custom functionality. This makes it easier to use custom SDKs across the
|
|
47
47
|
ecosystem without having to build custom bindings (like react context providers) for each individual
|
|
48
48
|
SDK and client.
|
|
49
49
|
|
|
50
|
-
### Extension
|
|
50
|
+
### Extension pattern
|
|
51
51
|
|
|
52
52
|
Client extensions use the `$extend` method to add functionality to any Sui client. Create a factory
|
|
53
53
|
function that returns a `name` and `register` function:
|
|
@@ -99,25 +99,25 @@ const client = new SuiGrpcClient({
|
|
|
99
99
|
await client.mySDK.getResource('0x...');
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
### Real-
|
|
102
|
+
### Real-world examples
|
|
103
103
|
|
|
104
104
|
Several official SDKs use this pattern:
|
|
105
105
|
|
|
106
|
-
- **[@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus)
|
|
107
|
-
- **[@mysten/seal](https://www.npmjs.com/package/@mysten/seal)
|
|
106
|
+
- **[@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus):** Decentralized storage
|
|
107
|
+
- **[@mysten/seal](https://www.npmjs.com/package/@mysten/seal):** Encryption and key management
|
|
108
108
|
|
|
109
|
-
## SDK
|
|
109
|
+
## SDK organization
|
|
110
110
|
|
|
111
111
|
Most Mysten SDKs do not strictly follow these patterns yet, but we recommend scoping methods on your
|
|
112
112
|
client extension into the following categories for clarity and consistency:
|
|
113
113
|
|
|
114
|
-
| Property | Purpose
|
|
115
|
-
| -------- |
|
|
116
|
-
| Methods | Top-level operations (execute actions or read
|
|
117
|
-
| `tx` | Methods that create transactions without executing
|
|
118
|
-
| `bcs` | BCS type definitions for encoding
|
|
119
|
-
| `call` | Methods returning Move calls that can be used with tx.add
|
|
120
|
-
| `view` | Methods that use simulate API to read onchain state
|
|
114
|
+
| Property | Purpose | Example |
|
|
115
|
+
| -------- | ------------------------------------------------------------- | ----------------------------------- |
|
|
116
|
+
| Methods | Top-level operations (execute actions or read and parse data) | `sdk.readBlob()`, `sdk.getConfig()` |
|
|
117
|
+
| `tx` | Methods that create transactions without executing | `sdk.tx.registerBlob()` |
|
|
118
|
+
| `bcs` | BCS type definitions for encoding and decoding | `sdk.bcs.MyStruct` |
|
|
119
|
+
| `call` | Methods returning Move calls that can be used with tx.add | `sdk.call.myFunction()` |
|
|
120
|
+
| `view` | Methods that use simulate API to read onchain state | `sdk.view.getState()` |
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
|
|
@@ -179,9 +179,9 @@ client extension into the following categories for clarity and consistency:
|
|
|
179
179
|
}
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
## Transaction
|
|
182
|
+
## Transaction building patterns
|
|
183
183
|
|
|
184
|
-
### Transaction
|
|
184
|
+
### Transaction thunks
|
|
185
185
|
|
|
186
186
|
Transaction thunks are functions that accept a `Transaction` and mutate it. This pattern enables
|
|
187
187
|
composition across multiple SDKs in a single transaction.
|
|
@@ -205,7 +205,7 @@ const resource = tx.add(createResource({ name: 'my-resource' }));
|
|
|
205
205
|
tx.transferObjects([resource], recipient);
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
### Async
|
|
208
|
+
### Async thunks
|
|
209
209
|
|
|
210
210
|
For operations requiring async work (like fetching package IDs or configuration), return async
|
|
211
211
|
thunks. These are used with `tx.add()` exactly like synchronous thunks - the async resolution
|
|
@@ -237,14 +237,14 @@ await signer.signAndExecuteTransaction({ transaction: tx, client });
|
|
|
237
237
|
This pattern is critical for web wallet compatibility - async work that happens during transaction
|
|
238
238
|
construction won't block the popup triggered by user interaction.
|
|
239
239
|
|
|
240
|
-
## Transaction
|
|
240
|
+
## Transaction execution
|
|
241
241
|
|
|
242
|
-
### Accept a
|
|
242
|
+
### Accept a signer parameter
|
|
243
243
|
|
|
244
244
|
For methods that execute transactions, accept a `Signer` parameter and always use the signer to
|
|
245
245
|
execute the transaction. This enables:
|
|
246
246
|
|
|
247
|
-
- Wallet integration through dApp
|
|
247
|
+
- Wallet integration through dApp kit
|
|
248
248
|
- Transaction sponsorship
|
|
249
249
|
- Custom signing flows
|
|
250
250
|
|
|
@@ -268,7 +268,7 @@ execute the transaction. This enables:
|
|
|
268
268
|
|
|
269
269
|
Using `signAndExecuteTransaction` allows wallets and sponsors to customize execution behavior.
|
|
270
270
|
|
|
271
|
-
## Code
|
|
271
|
+
## Code generation
|
|
272
272
|
|
|
273
273
|
For SDKs that interact with Move contracts, use **[@mysten/codegen](/codegen)** to generate
|
|
274
274
|
type-safe TypeScript bindings from your Move packages.
|
|
@@ -276,7 +276,7 @@ type-safe TypeScript bindings from your Move packages.
|
|
|
276
276
|
Benefits include type safety, BCS parsing, IDE support, and MoveRegistry support for human-readable
|
|
277
277
|
package names. See the [codegen documentation](/codegen) for setup instructions.
|
|
278
278
|
|
|
279
|
-
### Using
|
|
279
|
+
### Using generated code
|
|
280
280
|
|
|
281
281
|
The generated code provides both Move call functions and BCS struct definitions:
|
|
282
282
|
|
|
@@ -293,7 +293,7 @@ tx.add(
|
|
|
293
293
|
}),
|
|
294
294
|
);
|
|
295
295
|
|
|
296
|
-
// Generated BCS types parse
|
|
296
|
+
// Generated BCS types parse onchain data
|
|
297
297
|
const { object } = await client.core.getObject({
|
|
298
298
|
objectId: '0x123...',
|
|
299
299
|
include: { content: true },
|
|
@@ -303,7 +303,7 @@ const parsed = myContract.MyStruct.parse(object.content);
|
|
|
303
303
|
|
|
304
304
|
See the [codegen documentation](/codegen) for complete setup and configuration options.
|
|
305
305
|
|
|
306
|
-
## Reading
|
|
306
|
+
## Reading object contents
|
|
307
307
|
|
|
308
308
|
SDKs often need to fetch objects and parse their BCS-encoded content. Use `getObject` with
|
|
309
309
|
`include: { content: true }` and generated BCS types:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sui Programmable Transaction Basics
|
|
2
2
|
|
|
3
|
-
> Construct programmable transaction blocks with the Transaction API
|
|
3
|
+
> Construct programmable transaction blocks with the Transaction API.
|
|
4
4
|
|
|
5
5
|
This example starts by constructing a transaction to send SUI. To construct transactions, import the
|
|
6
6
|
`Transaction` class and construct it:
|
|
@@ -64,7 +64,7 @@ if (result.$kind === 'FailedTransaction') {
|
|
|
64
64
|
|
|
65
65
|
When you use `client.signAndExecuteTransaction` or `client.executeTransactionBlock`, the transaction
|
|
66
66
|
will be finalized on the blockchain before the function resolves, but the effects of the transaction
|
|
67
|
-
|
|
67
|
+
might not be immediately observable.
|
|
68
68
|
|
|
69
69
|
There are 2 ways to observe the results of a transaction. Methods like
|
|
70
70
|
`client.signAndExecuteTransaction` accept an `options` object with options like `showObjectChanges`
|
|
@@ -75,7 +75,7 @@ immediately displayed to the user, or used for further processing in your applic
|
|
|
75
75
|
|
|
76
76
|
The other way effects of transactions can be observed is by querying other RPC methods like
|
|
77
77
|
`client.getBalances` that return objects or balances owned by a specific address. These RPC calls
|
|
78
|
-
depend on the RPC node having indexed the effects of the transaction, which
|
|
78
|
+
depend on the RPC node having indexed the effects of the transaction, which might not have happened
|
|
79
79
|
immediately after a transaction has been executed. To ensure that effects of a transaction are
|
|
80
80
|
represented in future RPC calls, you can use the `waitForTransaction` method on the client:
|
|
81
81
|
|
|
@@ -101,21 +101,21 @@ Commands are steps of execution in the transaction. Each command in a Transactio
|
|
|
101
101
|
inputs, and produces results. The inputs for a transaction depend on the kind of command. Sui
|
|
102
102
|
supports following commands:
|
|
103
103
|
|
|
104
|
-
- `tx.splitCoins(coin, amounts)
|
|
104
|
+
- `tx.splitCoins(coin, amounts)`: Creates new coins with the defined amounts, split from the
|
|
105
105
|
provided coin. Returns the coins so that it can be used in subsequent transactions.
|
|
106
106
|
- Example: `tx.splitCoins(tx.gas, [100, 200])`
|
|
107
|
-
- `tx.mergeCoins(destinationCoin, sourceCoins)
|
|
107
|
+
- `tx.mergeCoins(destinationCoin, sourceCoins)`: Merges the sourceCoins into the destinationCoin.
|
|
108
108
|
- Example: `tx.mergeCoins(tx.object(coin1), [tx.object(coin2), tx.object(coin3)])`
|
|
109
|
-
- `tx.transferObjects(objects, address)
|
|
109
|
+
- `tx.transferObjects(objects, address)`: Transfers a list of objects to the specified address.
|
|
110
110
|
- Example: `tx.transferObjects([tx.object(thing1), tx.object(thing2)], myAddress)`
|
|
111
|
-
- `tx.moveCall({ target, arguments, typeArguments })
|
|
111
|
+
- `tx.moveCall({ target, arguments, typeArguments })`: Executes a Move call. Returns whatever the
|
|
112
112
|
Sui Move call returns.
|
|
113
113
|
- Example:
|
|
114
114
|
`tx.moveCall({ target: '0x2::devnet_nft::mint', arguments: [tx.pure.string(name), tx.pure.string(description), tx.pure.string(image)] })`
|
|
115
|
-
- `tx.makeMoveVec({ type, elements })
|
|
115
|
+
- `tx.makeMoveVec({ type, elements })`: Constructs a vector of objects that can be passed into a
|
|
116
116
|
`moveCall`. This is required as there’s no way to define a vector as an input.
|
|
117
117
|
- Example: `tx.makeMoveVec({ elements: [tx.object(id1), tx.object(id2)] })`
|
|
118
|
-
- `tx.publish(modules, dependencies)
|
|
118
|
+
- `tx.publish(modules, dependencies)`: Publishes a Move package. Returns the upgrade capability
|
|
119
119
|
object.
|
|
120
120
|
|
|
121
121
|
## Passing inputs to a command
|
|
@@ -140,7 +140,7 @@ tx.transferObjects([coin], '0xSomeSuiAddress');
|
|
|
140
140
|
|
|
141
141
|
When providing inputs that are not on chain objects, the values must be serialized as
|
|
142
142
|
|
|
143
|
-
[BCS](https://sdk.mystenlabs.com/bcs), which can be done using `tx.pure
|
|
143
|
+
[BCS](https://sdk.mystenlabs.com/bcs), which can be done using `tx.pure`, for example
|
|
144
144
|
`tx.pure.address(address)` or `tx.pure(bcs.vector(bcs.U8).serialize(bytes))`.
|
|
145
145
|
|
|
146
146
|
`tx.pure` can be called as a function that accepts a SerializedBcs object, or as a namespace that
|
|
@@ -277,9 +277,9 @@ tx.transferObjects([mintMany[0], mintMany[1]], address);
|
|
|
277
277
|
If you need the transaction bytes, instead of signing or executing the transaction, you can use the
|
|
278
278
|
`build` method on the transaction builder itself.
|
|
279
279
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
You might need to explicitly call `setSender()` on the transaction to ensure that the `sender` field
|
|
281
|
+
is populated. This is normally done by the signer before signing the transaction, but will not be
|
|
282
|
+
done automatically if you’re building the transaction bytes yourself.
|
|
283
283
|
|
|
284
284
|
```tsx
|
|
285
285
|
const tx = new Transaction();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Paying for Sui Transactions with Gas Coins
|
|
2
2
|
|
|
3
|
-
> Configure gas budget, price, and coin selection for transactions
|
|
3
|
+
> Configure gas budget, price, and coin selection for Sui transactions.
|
|
4
4
|
|
|
5
5
|
With Programmable Transactions, you can use the gas payment coin to construct coins with a set
|
|
6
6
|
balance using `splitCoin`. This is useful for Sui payments, and avoids the need for up-front coin
|
|
@@ -35,8 +35,7 @@ beforehand. The dry run gas consumption is then used to determine a balance for
|
|
|
35
35
|
can override this behavior by explicitly setting a gas budget for the transaction, by calling
|
|
36
36
|
`setGasBudget` on the transaction builder.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
into account.
|
|
38
|
+
The gas budget is represented in Sui and should take the gas price of the transaction into account.
|
|
40
39
|
|
|
41
40
|
```tsx
|
|
42
41
|
tx.setGasBudget(gasBudgetAmount);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Transaction Intents
|
|
2
2
|
|
|
3
|
-
> Use high-level intents to simplify transaction building
|
|
3
|
+
> Use high-level intents to simplify transaction building.
|
|
4
4
|
|
|
5
|
-
Transaction Intents enable
|
|
6
|
-
|
|
5
|
+
Transaction Intents enable third-party SDKs and [Transaction Plugins](../plugins) to more easily add
|
|
6
|
+
operations to a Transaction. The TypeScript SDK currently only includes a single Intent
|
|
7
7
|
(CoinWithBalance), but more will be added in the future.
|
|
8
8
|
|
|
9
9
|
## The CoinWithBalance intent
|
|
@@ -52,7 +52,7 @@ tx.transferObjects([coinWithBalance({ balance: 100, useGasCoin: false })], recip
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
It's important to only set `useGasCoin` option to false for sponsored transactions, otherwise the
|
|
55
|
-
coinWithBalance intent
|
|
55
|
+
coinWithBalance intent might use all the SUI coins, leaving no coins to use for gas.
|
|
56
56
|
|
|
57
57
|
## How it works
|
|
58
58
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Building Offline
|
|
2
2
|
|
|
3
|
-
> Build transactions without a network connection
|
|
3
|
+
> Build transactions without a network connection.
|
|
4
4
|
|
|
5
5
|
To build a transaction offline (with no `client` required), you need to fully define all of your
|
|
6
6
|
inputs, gas configuration, and expiration.
|
|
7
7
|
|
|
8
|
-
## Required
|
|
8
|
+
## Required configuration
|
|
9
9
|
|
|
10
10
|
When building offline, you must set the following:
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
12
|
+
- Sender address: The address that will execute the transaction
|
|
13
|
+
- Gas price: The price per gas unit (can be obtained from the network beforehand)
|
|
14
|
+
- Gas budget: The maximum gas to spend on this transaction
|
|
15
|
+
- Gas payment: One or more coin object references to use for gas, or an empty array for Address
|
|
16
16
|
Balances
|
|
17
|
-
-
|
|
17
|
+
- Expiration: Only needed when using address balances for gas
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
20
|
|
|
@@ -37,7 +37,7 @@ tx.setGasPayment([
|
|
|
37
37
|
const bytes = await tx.build();
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## Object
|
|
40
|
+
## Object references
|
|
41
41
|
|
|
42
42
|
For objects used in your transaction, you must provide full object references using the `Inputs`
|
|
43
43
|
helper:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sponsored Transactions
|
|
2
2
|
|
|
3
|
-
> Pay gas fees on behalf of other users with sponsored transactions
|
|
3
|
+
> Pay gas fees on behalf of other users with sponsored transactions.
|
|
4
4
|
|
|
5
5
|
The transaction builder can support sponsored transactions by using the `onlyTransactionKind` flag
|
|
6
6
|
when building the transaction.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Derived Objects
|
|
2
2
|
|
|
3
|
-
> Compute derived object IDs from parent objects
|
|
3
|
+
> Compute derived object IDs from parent objects for deterministic offline derivation.
|
|
4
4
|
|
|
5
5
|
Derived objects enable deterministic IDs for objects, enabling offline derivation of object IDs.
|
|
6
6
|
[Click here to read more.](https://docs.sui.io/concepts/sui-move-concepts/derived-objects)
|
|
@@ -14,7 +14,7 @@ To derive an object ID, you can import `deriveObjectID` function exposed from ut
|
|
|
14
14
|
To derive any object, you need to have its parent's ID (the object from which it was derived), and
|
|
15
15
|
the key used to generate it.
|
|
16
16
|
|
|
17
|
-
> **Warning:** It is recommended to verify the
|
|
17
|
+
> **Warning:** It is recommended to verify the onchain `derived_object::derive_address` match your offchain
|
|
18
18
|
> calculation (at least once when implementing offline calculations), especially for critical cases
|
|
19
19
|
> like transferring assets.
|
|
20
20
|
|
|
@@ -24,21 +24,21 @@ To derive the IDs using primitive types, you can use the built-in types like thi
|
|
|
24
24
|
a parent object with ID `0xc0ffee`.
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
// Example 1:
|
|
27
|
+
// Example 1: Onchain derivation for `0xc0ffee + vector<u8>([0,1,2])
|
|
28
28
|
deriveObjectID('0xc0ffee', 'vector<u8>', bcs.vector(bcs.u8()).serialize([0, 1, 2]).toBytes());
|
|
29
29
|
|
|
30
|
-
// Example 2:
|
|
30
|
+
// Example 2: Onchain derivation for `0xc0ffee + address('0x111')`
|
|
31
31
|
deriveObjectID('0xc0ffee', 'address', bcs.Address.serialize('0x111').toBytes());
|
|
32
32
|
|
|
33
|
-
// Example 3:
|
|
33
|
+
// Example 3: Onchain derivation for `0xc0ffee + non-ascii string ("foo")`
|
|
34
34
|
deriveObjectID('0xc0ffee', '0x1::string::String', bcs.String.serialize('foo').toBytes());
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Deriving using custom types
|
|
38
38
|
|
|
39
|
-
To derive IDs using your custom objects, you can use BCS
|
|
39
|
+
To derive IDs using your custom objects, you can use BCS and the known type IDs.
|
|
40
40
|
|
|
41
|
-
Assuming a custom struct
|
|
41
|
+
Assuming a custom struct onchain (for the key) being:
|
|
42
42
|
|
|
43
43
|
```move
|
|
44
44
|
public struct DemoStruct has copy, store, drop { value: u64 }
|
|
@@ -61,14 +61,14 @@ deriveObjectID('0xc0ffee', `0xc0ffee::demo::DemoStruct`, key);
|
|
|
61
61
|
### Deriving with fieldless structs
|
|
62
62
|
|
|
63
63
|
In Move, structs with no user-defined fields automatically get a `dummy_field: bool` injected by the
|
|
64
|
-
compiler. This means their BCS encoding is not empty
|
|
64
|
+
compiler. This means their BCS encoding is not empty. It is a single `0x00` byte (the encoding of
|
|
65
65
|
`false`). You can treat this as a constant.
|
|
66
66
|
|
|
67
67
|
A real-world example is `0x2::coin_registry::CurrencyKey<T>`, which is a fieldless generic struct
|
|
68
68
|
used to derive `Currency` objects from the coin registry (`0xc`) based on their type:
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
//
|
|
71
|
+
// Onchain: `public struct CurrencyKey<phantom T>() has copy, store, drop`
|
|
72
72
|
// The compiler injects `dummy_field: bool`, always `false`.
|
|
73
73
|
const key = new Uint8Array([0]);
|
|
74
74
|
|
|
@@ -76,5 +76,5 @@ const coinType = '0x2::sui::SUI';
|
|
|
76
76
|
const currencyId = deriveObjectID('0xc', `0x2::coin_registry::CurrencyKey<${coinType}>`, key);
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
This applies to any struct with no fields
|
|
79
|
+
This applies to any struct with no fields. Phantom type parameters do not add any BCS-encoded data,
|
|
80
80
|
so the key is always `new Uint8Array([0])`.
|
package/dist/sui/utils/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The `@mysten/sui/utils` package
|
|
2
2
|
|
|
3
|
-
> Utility functions for addresses, coins, and common operations
|
|
3
|
+
> Utility functions for addresses, coins, and common operations in the Sui TypeScript SDK.
|
|
4
4
|
|
|
5
5
|
This package contains some utilities that simplify common operations when working with the Sui
|
|
6
6
|
TypeScript SDK.
|
|
@@ -31,6 +31,13 @@ You can use the following helpers to format various values:
|
|
|
31
31
|
- `normalizeSuiNSName`
|
|
32
32
|
- `normalizeSuiNSName`
|
|
33
33
|
|
|
34
|
+
## Parsers
|
|
35
|
+
|
|
36
|
+
You can use the following helpers to parse decimal strings into smallest-unit bigints:
|
|
37
|
+
|
|
38
|
+
- `parseToUnits`: Parse a decimal string into a `bigint`, given a coin's `decimals`
|
|
39
|
+
- `parseToMist`: Parse a SUI decimal string into MIST (9 decimals)
|
|
40
|
+
|
|
34
41
|
## Validators
|
|
35
42
|
|
|
36
43
|
You can use the following helpers to validate the format of various values (this only validates that
|
package/dist/sui/zklogin.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ZkLogin
|
|
2
2
|
|
|
3
|
-
> Zero-knowledge authentication with OAuth providers on Sui
|
|
3
|
+
> Zero-knowledge authentication with OAuth providers on Sui.
|
|
4
4
|
|
|
5
5
|
Utilities for working with zkLogin. Currently contains functionality to create and parse zkLogin
|
|
6
6
|
signatures and compute zkLogin addresses.
|
package/dist/walrus/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Walrus SDK
|
|
2
2
|
|
|
3
|
-
> Store and retrieve blobs on Walrus decentralized storage
|
|
3
|
+
> Store and retrieve blobs on Walrus decentralized storage using the TypeScript SDK.
|
|
4
4
|
|
|
5
5
|
The Walrus TypeScript SDK works directly with Walrus storage nodes or with the Walrus upload relay.
|
|
6
6
|
When you use the Walrus SDK without an upload relay, reading and writing Walrus blobs requires many
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Composable Claims
|
|
2
|
+
|
|
3
|
+
> Claim a zkSend link and use the assets in the same transaction
|
|
4
|
+
|
|
5
|
+
By default, `link.claimAssets(address)` builds a claim transaction that transfers every asset to the
|
|
6
|
+
recipient and submits it via a Mysten-hosted sponsor. If you want to _use_ a claimed object in the
|
|
7
|
+
same transaction — for example, inserting a claimed NFT into another on-chain object, staking a
|
|
8
|
+
claimed coin, or depositing into a vault — use `link.claimFlow()` to compose the claim into your own
|
|
9
|
+
transaction.
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
`link.claimFlow()` returns three transaction thunks:
|
|
14
|
+
|
|
15
|
+
- **`init`** — adds the `init_claim` (or `reclaim`) move call that creates the claim proof.
|
|
16
|
+
- **`assets`** — an array of claimable assets. Each `asset.argument` is a lazy
|
|
17
|
+
`TransactionObjectArgument` that emits the backing `claim<T>` move call the first time it's used.
|
|
18
|
+
- **`finalize`** — consumes the claim proof. Must be added after every asset is claimed.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
|
|
22
|
+
const tx = new Transaction();
|
|
23
|
+
tx.setSender(claimLink.keypair!.toSuiAddress());
|
|
24
|
+
|
|
25
|
+
const { init, assets, finalize } = claimLink.claimFlow();
|
|
26
|
+
|
|
27
|
+
tx.add(init);
|
|
28
|
+
|
|
29
|
+
for (const asset of assets) {
|
|
30
|
+
if (asset.type === `${PACKAGE_ID}::record::Record`) {
|
|
31
|
+
// Insert the claimed record directly into the recipient's player object
|
|
32
|
+
tx.moveCall({
|
|
33
|
+
target: `${PACKAGE_ID}::player::add_record`,
|
|
34
|
+
arguments: [tx.object(playerId), asset.argument],
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
tx.transferObjects([asset.argument], recipient);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
tx.add(finalize);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Every asset in the returned list must be claimed somewhere in the transaction — assets that are
|
|
45
|
+
never used won't create a `claim<T>` command and the transaction will fail. If you only want the
|
|
46
|
+
default claim-and-transfer behavior, use `link.createClaimTransaction(address)` instead.
|
|
47
|
+
|
|
48
|
+
## Sponsorship
|
|
49
|
+
|
|
50
|
+
`link.claimAssets(address)` uses a sponsorship flow so the claimer does not need gas to claim the
|
|
51
|
+
assets, but it only accepts the standard `init_claim` → `claim<T>` → transfer → `finalize` shape.
|
|
52
|
+
Transactions built with `claimFlow()` may include extra move calls, so the default sponsor may
|
|
53
|
+
reject them.
|
|
54
|
+
|
|
55
|
+
Apps using `claimFlow()` are responsible for their own gas and sponsorship. The ephemeral link
|
|
56
|
+
keypair is still the transaction sender (it authorizes the claim), so the typical pattern is dual
|
|
57
|
+
signing: the link keypair signs as sender and your app's sponsor signs for gas.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
tx.setGasOwner(sponsorAddress);
|
|
61
|
+
const txBytes = await tx.build({ client });
|
|
62
|
+
|
|
63
|
+
const linkSig = await claimLink.keypair!.signTransaction(txBytes);
|
|
64
|
+
const sponsorSig = await sponsor.signTransaction(txBytes);
|
|
65
|
+
|
|
66
|
+
const result = await client.core.executeTransaction({
|
|
67
|
+
transaction: txBytes,
|
|
68
|
+
signatures: [linkSig.signature, sponsorSig.signature],
|
|
69
|
+
});
|
|
70
|
+
```
|
package/dist/zksend/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# zkSend SDK
|
|
2
2
|
|
|
3
|
-
> Send Sui assets
|
|
3
|
+
> Send Sui assets through shareable claim links using the zkSend SDK.
|
|
4
4
|
|
|
5
5
|
The zkSend SDK provides tools for interacting with the zkSend primitive. It provides functionality
|
|
6
6
|
to create your own zkSend Claim Links, with support for any publicly transferrable asset.
|
|
@@ -23,5 +23,5 @@ const client = new SuiGrpcClient({
|
|
|
23
23
|
}).$extend(zksend());
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
The zkSend SDK supports
|
|
26
|
+
The zkSend SDK supports Mainnet and Testnet networks. The extension automatically configures the
|
|
27
27
|
correct contract IDs based on the client's network.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Creating zkSend Links
|
|
2
2
|
|
|
3
|
-
> Create and customize zkSend claim links
|
|
3
|
+
> Create and customize zkSend claim links for sending Sui assets.
|
|
4
4
|
|
|
5
|
-
> **Warning:** Products and services that incorporate zkSend links
|
|
5
|
+
> **Warning:** Products and services that incorporate zkSend links might be subject to financial regulations,
|
|
6
6
|
> including obtaining money transmitter licenses in jurisdictions where you provide your services.
|
|
7
7
|
> It is the developer's responsibility to ensure compliance with all relevant laws and obtain any
|
|
8
8
|
> necessary licenses. The information provided by Mysten Labs is not legal advice, and developers
|
|
@@ -42,7 +42,8 @@ params:
|
|
|
42
42
|
You can add non-SUI coins to the link by calling `link.addClaimableBalance()`. This method takes the
|
|
43
43
|
following params:
|
|
44
44
|
|
|
45
|
-
- **`coinType`** (required) - The coin type of the coin to add to the link (
|
|
45
|
+
- **`coinType`** (required) - The coin type of the coin to add to the link (for example,
|
|
46
|
+
`0x2::sui::SUI`).
|
|
46
47
|
- **`amount`** (required) - The amount of the coin to add to the link. Represented in the base unit
|
|
47
48
|
of the coin.
|
|
48
49
|
|
|
@@ -124,7 +125,7 @@ await link.create({
|
|
|
124
125
|
|
|
125
126
|
## Claiming a link
|
|
126
127
|
|
|
127
|
-
To claim a link
|
|
128
|
+
To claim a link through the SDK you can use the `loadLinkFromUrl` method:
|
|
128
129
|
|
|
129
130
|
```ts
|
|
130
131
|
// Load a link instance from a URL
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# ZkSend
|
|
2
2
|
> Send Sui with a link
|
|
3
3
|
|
|
4
|
-
- [zkSend SDK](..md): Send Sui assets
|
|
5
|
-
- [Creating zkSend Links](./link-builder.md): Create and customize zkSend claim links
|
|
4
|
+
- [zkSend SDK](..md): Send Sui assets through shareable claim links using the zkSend SDK.
|
|
5
|
+
- [Creating zkSend Links](./link-builder.md): Create and customize zkSend claim links for sending Sui assets.
|
|
6
|
+
- [Composable Claims](./composable-claim.md): Claim a zkSend link and use the assets in the same transaction
|