@mysten/sui 2.6.0 → 2.8.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 (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/types.d.mts +17 -0
  5. package/dist/client/types.d.mts.map +1 -1
  6. package/dist/cryptography/signature.d.mts +14 -14
  7. package/dist/graphql/core.d.mts.map +1 -1
  8. package/dist/graphql/core.mjs +21 -8
  9. package/dist/graphql/core.mjs.map +1 -1
  10. package/dist/graphql/generated/queries.d.mts.map +1 -1
  11. package/dist/graphql/generated/queries.mjs +18 -3
  12. package/dist/graphql/generated/queries.mjs.map +1 -1
  13. package/dist/graphql/generated/tada-env.d.mts +703 -73
  14. package/dist/grpc/core.d.mts.map +1 -1
  15. package/dist/grpc/core.mjs +15 -2
  16. package/dist/grpc/core.mjs.map +1 -1
  17. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/sui/rpc/v2/object.d.mts +38 -1
  19. package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
  20. package/dist/grpc/proto/sui/rpc/v2/object.mjs +26 -1
  21. package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
  22. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  23. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  24. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  25. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  26. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +8 -0
  27. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  28. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +23 -12
  29. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  30. package/dist/grpc/proto/types.d.mts +2 -2
  31. package/dist/grpc/proto/types.mjs +2 -1
  32. package/dist/jsonRpc/core.d.mts.map +1 -1
  33. package/dist/jsonRpc/core.mjs +10 -3
  34. package/dist/jsonRpc/core.mjs.map +1 -1
  35. package/dist/keypairs/passkey/keypair.d.mts +11 -4
  36. package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
  37. package/dist/keypairs/passkey/keypair.mjs +19 -6
  38. package/dist/keypairs/passkey/keypair.mjs.map +1 -1
  39. package/dist/transactions/Transaction.d.mts +9 -9
  40. package/dist/transactions/Transaction.d.mts.map +1 -1
  41. package/dist/version.mjs +2 -2
  42. package/dist/version.mjs.map +1 -1
  43. package/dist/zklogin/bcs.d.mts +14 -14
  44. package/docs/bcs.md +131 -0
  45. package/docs/clients/core.md +601 -0
  46. package/docs/clients/graphql.md +99 -0
  47. package/docs/clients/grpc.md +152 -0
  48. package/docs/clients/index.md +93 -0
  49. package/docs/clients/json-rpc.md +235 -0
  50. package/docs/cryptography/keypairs.md +258 -0
  51. package/docs/cryptography/multisig.md +192 -0
  52. package/docs/cryptography/passkey.md +111 -0
  53. package/docs/cryptography/webcrypto-signer.md +81 -0
  54. package/docs/executors.md +147 -0
  55. package/docs/faucet.md +26 -0
  56. package/docs/hello-sui.md +114 -0
  57. package/docs/index.md +54 -0
  58. package/docs/install.md +61 -0
  59. package/docs/llm-docs.md +32 -0
  60. package/docs/llms-index.md +60 -0
  61. package/docs/migrations/0.38.md +57 -0
  62. package/docs/migrations/sui-1.0.md +453 -0
  63. package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
  64. package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
  65. package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
  66. package/docs/migrations/sui-2.0/index.md +157 -0
  67. package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
  68. package/docs/migrations/sui-2.0/kiosk.md +120 -0
  69. package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
  70. package/docs/migrations/sui-2.0/seal.md +14 -0
  71. package/docs/migrations/sui-2.0/sui.md +341 -0
  72. package/docs/migrations/sui-2.0/suins.md +42 -0
  73. package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
  74. package/docs/migrations/sui-2.0/walrus.md +41 -0
  75. package/docs/migrations/sui-2.0/zksend.md +94 -0
  76. package/docs/plugins.md +255 -0
  77. package/docs/sdk-building.md +340 -0
  78. package/docs/transaction-building/basics.md +297 -0
  79. package/docs/transaction-building/gas.md +62 -0
  80. package/docs/transaction-building/intents.md +61 -0
  81. package/docs/transaction-building/offline.md +71 -0
  82. package/docs/transaction-building/sponsored-transactions.md +22 -0
  83. package/docs/utils/derived_objects.md +59 -0
  84. package/docs/utils/index.md +52 -0
  85. package/docs/zklogin.md +78 -0
  86. package/package.json +5 -3
  87. package/src/client/types.ts +16 -0
  88. package/src/graphql/core.ts +34 -13
  89. package/src/graphql/generated/queries.ts +252 -14
  90. package/src/graphql/generated/schema.graphql +324 -8
  91. package/src/graphql/generated/tada-env.ts +844 -99
  92. package/src/graphql/queries/objects.graphql +10 -0
  93. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -1
  94. package/src/grpc/core.ts +34 -0
  95. package/src/grpc/proto/sui/rpc/v2/object.ts +44 -0
  96. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +16 -0
  97. package/src/jsonRpc/core.ts +9 -0
  98. package/src/keypairs/passkey/keypair.ts +20 -6
  99. package/src/version.ts +2 -2
@@ -0,0 +1,147 @@
1
+ # Transaction Executors
2
+
3
+ > Manage transaction execution with queuing and parallel strategies
4
+
5
+ The Typescript SDK ships 2 Transaction executor classes that simplify the processes of efficiently
6
+ executing multiple transactions signed by the same address. These executors help manage object
7
+ versions and gas coins which significantly reduces the number of requests made to RPC nodes, and for
8
+ many cases avoids the need to wait for the RPC nodes to index previously executed transactions.
9
+
10
+ ## `SerialTransactionExecutor`
11
+
12
+ The `SerialTransactionExecutor` is designed for use in wallet implementations, and dapps where the
13
+ objects owned by the address executing transactions are unlikely to be changed by transactions not
14
+ executed through the executor.
15
+
16
+ To fund transactions, the `SerialTransactionExecutor` will select all of the senders SUI coins for
17
+ the first transaction, which will result in a single coin that will then be used as the gas payment
18
+ on all subsequent transactions. This allows executing multiple transactions, without needing to
19
+ re-query for gas coins, or wait for the RPC node to index the previous transactions.
20
+
21
+ To further improve execution efficiency, the `SerialTransactionExecutor` caches the object versions
22
+ of every object used or created by a transaction. This will significantly speed up the execution
23
+ when multiple transactions use the same objects.
24
+
25
+ `SerialTransactionExecutor` maintains an internal queue, so you don't need to wait for previous
26
+ transactions to finish before sending the next one.
27
+
28
+ `SerialTransactionExecutor` can be configured with a number of options:
29
+
30
+ - `client`: An instance of a Sui client (such as `SuiGrpcClient`) used to execute transactions.
31
+ - `signer`: The signer/keypair used for signed transactions.
32
+ - `defaultBudget`: The default budget for transactions, which will be used if the transaction does
33
+ not specify a budget (default `50_000_000n`).
34
+ - `gasMode`: Either `'coins'` (default) to use owned coins for gas, or `'addressBalance'` to pay gas
35
+ from the sender's address balance.
36
+
37
+ ```ts
38
+ const client = new SuiGrpcClient({
39
+ network: 'devnet',
40
+ baseUrl: 'https://fullnode.devnet.sui.io:443',
41
+ });
42
+
43
+ const executor = new SerialTransactionExecutor({
44
+ client,
45
+ signer: yourKeyPair,
46
+ });
47
+
48
+ const tx1 = new Transaction();
49
+ const [coin1] = tx1.splitCoins(tx1.gas, [1]);
50
+ tx1.transferObjects([coin1], address1);
51
+ const tx2 = new Transaction();
52
+ const [coin2] = tx2.splitCoins(tx2.gas, [1]);
53
+ tx2.transferObjects([coin2], address2);
54
+
55
+ const [{ digest: digest1 }, { digest: digest2 }] = await Promise.all([
56
+ executor.executeTransaction(tx1),
57
+ executor.executeTransaction(tx2),
58
+ ]);
59
+ ```
60
+
61
+ ## `ParallelTransactionExecutor`
62
+
63
+ > **Warning:** `ParallelTransactionExecutor` is experimental and may change rapidly as it is being
64
+ > developed.
65
+
66
+ The `ParallelTransactionExecutor` class works similarly to the `SerialTransactionExecutor`, but
67
+ allows for parallel execution of transactions. To make this work, the `ParallelTransactionExecutor`
68
+ will maintain a pool of gas coins, and automatically execute additional transactions to refill the
69
+ gas pool as needed.
70
+
71
+ > **Warning:** Using other client methods or wallets to execute additional transactions while
72
+ > `ParallelTransactionExecutor` is in use may consume/combine gas coins in the gasPool, causing
73
+ > transactions to fail. This may also result in the coins becoming locked for the remainder of the
74
+ > current epoch, preventing them from being used in future transactions.
75
+ >
76
+ > Running multiple instances of `ParallelTransactionExecutor` using the same `sourceCoins` will
77
+ > result in the same issues.
78
+
79
+ In addition to managing gas and caching object versions, the `ParallelTransactionExecutor` will
80
+ automatically detect what objects are being used by transactions, and schedules transactions in a
81
+ way that avoids conflicts between transactions using the same object ids.
82
+
83
+ `ParallelTransactionExecutor` can be configured with a number of options:
84
+
85
+ - `client`: An instance of `SuiJsonRpcClient` used to execute transactions.
86
+ - `signer`: The signer/keypair used for signed transactions.
87
+ - `gasMode`: Either `'coins'` (default) to use owned coins for gas, or `'addressBalance'` to pay gas
88
+ from the sender's address balance. When using `'addressBalance'`, coin-specific options like
89
+ `coinBatchSize`, `initialCoinBalance`, `minimumCoinBalance`, and `sourceCoins` are not available.
90
+ - `coinBatchSize`: The maximum number of new coins to create when refilling the gas pool
91
+ (default 20)
92
+ - `initialCoinBalance`: The balance of new coins created for the gas pool in MIST (default
93
+ `200_000_000n`),
94
+ - `minimumCoinBalance`: After executing a transaction, the gasCoin will be reused unless it's
95
+ balance is below this value (default `50_000_000n`),
96
+ - `defaultBudget`: The default budget for transactions, which will be used if the transaction does
97
+ not specify a budget (default `minimumCoinBalance`),
98
+ - `maxPoolSize`: The maximum number of gas coins to keep in the gas pool, which also limits the
99
+ maximum number of concurrent transactions (default 50),
100
+ - `sourceCoins`: An array of coins to use to create the gas pool, defaults to using all coins owned
101
+ by the signer.
102
+ - `epochBoundaryWindow` Time to wait before/after the expected epoch boundary before re-fetching the
103
+ gas pool (in milliseconds). Building transactions will be paused for up to 2x this duration around
104
+ each epoch boundary to ensure the gas price is up-to-date for the next epoch. (default `1000`)
105
+
106
+ ```ts
107
+ const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
108
+
109
+ const executor = new ParallelTransactionExecutor({
110
+ client,
111
+ signer: yourKeyPair,
112
+ });
113
+
114
+ const tx1 = new Transaction();
115
+ const [coin1] = tx1.splitCoins(tx1.gas, [1]);
116
+ tx1.transferObjects([coin1], address1);
117
+ const tx2 = new Transaction();
118
+ const [coin2] = tx2.splitCoins(tx2.gas, [1]);
119
+ tx2.transferObjects([coin2], address2);
120
+
121
+ const [{ digest: digest1 }, { digest: digest2 }] = await Promise.all([
122
+ executor.executeTransaction(tx1),
123
+ executor.executeTransaction(tx2),
124
+ ]);
125
+ ```
126
+
127
+ ## Building and Executing Transactions with Executors
128
+
129
+ The executor classes will significantly improve efficiency when executing multiple transactions, but
130
+ to get the best results there are some best practices to follow:
131
+
132
+ When building transactions, always prefer using unresolved object IDs rather than specifying the
133
+ full `id`/`version`/`digest` for an object input (eg use `tx.object(id)` rather than
134
+ `tx.objectRef({ objectId, version, digest })`). By doing this, you allow the executor to use object
135
+ versions and digests from the cache, and will avoid executing transactions using stale object
136
+ versions.
137
+
138
+ If the signer executes transactions that are not sent through the executor that may cause
139
+ transactions to fail. The executor classes will handle this by invalidating the cache for any
140
+ objects used in the transaction, so you will often be able to recover by re-trying a failed
141
+ transaction once. If it was caused by a stale cache, it should succeed on the second execution.
142
+
143
+ > **Warning:** Transaction plugins and intents may resolve their own data (such as object
144
+ > references) that are not automatically managed by the executor's object cache. This can cause
145
+ > transactions to include stale object versions. The `coinWithBalance` intent is partially supported
146
+ > by the executors and will work correctly when all coin types are either SUI or the required
147
+ > balances are available as address balances rather than coin objects.
package/docs/faucet.md ADDED
@@ -0,0 +1,26 @@
1
+ # Faucet
2
+
3
+ > Request test SUI tokens from the faucet
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,
25
+ > you surpass the limit and must wait to successfully run it again. For testnet, the best way to get
26
+ > SUI is via the Web UI: `faucet.sui.io`.
@@ -0,0 +1,114 @@
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, local). If you don't already have
13
+ 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
+ // replace <YOUR_SUI_ADDRESS> with your actual address, which is in the form 0x123...
59
+ const MY_ADDRESS = '<YOUR_SUI_ADDRESS>';
60
+
61
+ // create a new SuiGrpcClient object pointing to the network you want to use
62
+ const suiClient = new SuiGrpcClient({
63
+ network: 'devnet',
64
+ baseUrl: 'https://fullnode.devnet.sui.io:443',
65
+ });
66
+
67
+ // Convert MIST to Sui
68
+ const balance = (balance) => {
69
+ return Number.parseInt(balance.totalBalance) / Number(MIST_PER_SUI);
70
+ };
71
+
72
+ // store the JSON representation for the SUI the address owns before using faucet
73
+ const suiBefore = await suiClient.getBalance({
74
+ owner: MY_ADDRESS,
75
+ });
76
+
77
+ await requestSuiFromFaucetV2({
78
+ // use getFaucetHost to make sure you're using correct faucet address
79
+ // you can also just use the address (see Sui TypeScript SDK Quick Start for values)
80
+ host: getFaucetHost('devnet'),
81
+ recipient: MY_ADDRESS,
82
+ });
83
+
84
+ // store the JSON representation for the SUI the address owns after using faucet
85
+ const suiAfter = await suiClient.getBalance({
86
+ owner: MY_ADDRESS,
87
+ });
88
+
89
+ // Output result to console.
90
+ console.log(
91
+ `Balance before faucet: ${balance(suiBefore)} SUI. Balance after: ${balance(
92
+ suiAfter,
93
+ )} SUI. Hello, SUI!`,
94
+ );
95
+ ```
96
+
97
+ Save the file, then use Node.js to run it in your Console or Terminal:
98
+
99
+ ```sh
100
+ node index.js
101
+ ```
102
+
103
+ The code imports the `requestSuiFromFaucetV2` function from the SDK and calls it to mint SUI for the
104
+ provided address. The code also imports `SuiGrpcClient` to create a new client on the Sui network
105
+ that it uses to query the address and output the amount of SUI the address owns before and after
106
+ using the faucet. You can check the total SUI for your address using the Sui Wallet or Sui Client
107
+ CLI.
108
+
109
+ > **Note:** Faucets on Devnet and Testnet are rate limited. If you run the script too many times,
110
+ > you surpass the limit and must wait to successfully run it again. For testnet, the best way to get
111
+ > SUI is via the Web UI: `faucet.sui.io`.
112
+
113
+ You can also use the [Sui Client CLI](https://docs.sui.io/references/cli/client) to perform client
114
+ calls on a Sui network.
package/docs/index.md ADDED
@@ -0,0 +1,54 @@
1
+ # Sui TypeScript SDK Quick Start
2
+
3
+ > TypeScript SDK for building on the Sui blockchain
4
+
5
+ The Sui TypeScript SDK is a modular library of tools for interacting with the Sui blockchain. Use it
6
+ to send queries to RPC nodes, build and sign transactions, and interact with a Sui or local network.
7
+
8
+ ## Installation
9
+
10
+ ```sh npm2yarn
11
+ npm i @mysten/sui
12
+ ```
13
+
14
+ ## Network locations
15
+
16
+ The following table lists the locations for Sui networks.
17
+
18
+ | Network | Full node | faucet |
19
+ | ------- | ------------------------------------- | ---------------------------------------- |
20
+ | local | `http://127.0.0.1:9000` (default) | `http://127.0.0.1:9123/v2/gas` (default) |
21
+ | Devnet | `https://fullnode.devnet.sui.io:443` | `https://faucet.devnet.sui.io/v2/gas` |
22
+ | Testnet | `https://fullnode.testnet.sui.io:443` | `https://faucet.testnet.sui.io/v2/gas` |
23
+ | Mainnet | `https://fullnode.mainnet.sui.io:443` | `null` |
24
+
25
+ > **Warning:** Use dedicated nodes/shared services rather than public endpoints for production apps.
26
+ > The public endpoints maintained by Mysten Labs (`fullnode.<NETWORK>.sui.io:443`) are rate-limited,
27
+ > and support only 100 requests per 30 seconds or so. Do not use public endpoints in production
28
+ > applications with high traffic volume.
29
+ >
30
+ > You can either run your own Full nodes, or outsource this to a professional infrastructure
31
+ > provider (preferred for apps that have high traffic). You can find a list of reliable RPC endpoint
32
+ > providers for Sui on the [Sui Dev Portal](https://sui.io/developers#dev-tools) using the **Node
33
+ > Service** tab.
34
+
35
+ ## Module packages
36
+
37
+ The SDK contains a set of modular packages that you can use independently or together. Import just
38
+ what you need to keep your code light and compact.
39
+
40
+ - [`@mysten/sui/client`](/sui/clients) - A client for interacting with Sui RPC nodes.
41
+ - [`@mysten/sui/bcs`](/sui/bcs) - A BCS builder with pre-defined types for Sui.
42
+ - [`@mysten/sui/transactions`](/sui/transaction-building/basics) - Utilities for building and
43
+ interacting with transactions.
44
+ - [`@mysten/sui/keypairs/*`](/sui/cryptography/keypairs) - Modular exports for specific KeyPair
45
+ implementations.
46
+ - [`@mysten/sui/verify`](/sui/cryptography/keypairs#verifying-signatures-without-a-key-pair) -
47
+ Methods for verifying transactions and messages.
48
+ - [`@mysten/sui/cryptography`](/sui/cryptography/keypairs) - Shared types and classes for
49
+ cryptography.
50
+ - [`@mysten/sui/multisig`](/sui/cryptography/multisig) - Utilities for working with multisig
51
+ signatures.
52
+ - [`@mysten/sui/utils`](/sui/utils) - Utilities for formatting and parsing various Sui types.
53
+ - [`@mysten/sui/faucet`](/sui/faucet) - Methods for requesting SUI from a faucet.
54
+ - [`@mysten/sui/zklogin`](/sui/zklogin) - Utilities for working with zkLogin.
@@ -0,0 +1,61 @@
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 on-chain 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 your 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
+ ```
@@ -0,0 +1,32 @@
1
+ # LLM Documentation
2
+
3
+ > Give AI agents access to Sui SDK documentation in your project
4
+
5
+ Every `@mysten/*` package ships a `docs/` directory containing flat markdown files optimized for AI
6
+ agent consumption. When you install an SDK package, you automatically get accurate, up-to-date
7
+ documentation that coding agents (Claude Code, Cursor, Copilot, etc.) can read directly — no
8
+ separate install or training data required.
9
+
10
+ ## How It Works
11
+
12
+ Each package includes:
13
+
14
+ - `docs/llms-index.md` — routing index listing all doc pages with descriptions
15
+ - `docs/*.md` — individual reference pages
16
+
17
+ For example, installing `@mysten/sui` gives you docs at
18
+ `node_modules/@mysten/sui/docs/llms-index.md`.
19
+
20
+ ## Configure Your Agent
21
+
22
+ Add the following snippet to your agent's configuration file (`AGENTS.md`, `CLAUDE.md`,
23
+ `.cursorrules`, etc.):
24
+
25
+ ```markdown
26
+ ## Sui SDK Reference
27
+
28
+ Every @mysten/\* package ships LLM documentation in its `docs/` directory. When working with these
29
+ packages, find the relevant docs by looking for `docs/llms-index.md` files inside
30
+ `node_modules/@mysten/\*/`. Read the index first to find the page you need, then read that page for
31
+ details.
32
+ ```
@@ -0,0 +1,60 @@
1
+ # Sui SDK
2
+
3
+ > TypeScript interfaces for Sui
4
+
5
+ - [Sui TypeScript SDK Quick Start](./index.md): TypeScript SDK for building on the Sui blockchain
6
+ - [Install Sui TypeScript SDK](./install.md): Install the @mysten/sui package and configure your
7
+ project
8
+ - [LLM Documentation](./llm-docs.md): Give AI agents access to Sui SDK documentation in your project
9
+ - [Hello Sui](./hello-sui.md): Build your first Sui application with the TypeScript SDK
10
+ - [Faucet](./faucet.md): Request test SUI tokens from the faucet
11
+ - [Sui Clients](./clients/index.md): Choose and configure gRPC, GraphQL, or JSON-RPC clients
12
+ - [Core API](./clients/core.md): Transport-agnostic Core API shared by all Sui clients
13
+ - [SuiGrpcClient](./clients/grpc.md): Connect to Sui via gRPC with SuiGrpcClient
14
+ - [SuiGraphQLClient](./clients/graphql.md): Connect to Sui via GraphQL with SuiGraphQLClient
15
+ - [SuiJsonRpcClient](./clients/json-rpc.md): Connect to Sui via JSON-RPC with SuiJsonRpcClient
16
+ - [Sui Programmable Transaction Basics](./transaction-building/basics.md): Construct programmable
17
+ transaction blocks with the Transaction API
18
+ - [Paying for Sui Transactions with Gas Coins](./transaction-building/gas.md): Configure gas budget,
19
+ price, and coin selection for transactions
20
+ - [Transaction Intents](./transaction-building/intents.md): Use high-level intents to simplify
21
+ transaction building
22
+ - [Building Offline](./transaction-building/offline.md): Build transactions without a network
23
+ connection
24
+ - [Sponsored Transactions](./transaction-building/sponsored-transactions.md): Pay gas fees on behalf
25
+ of other users with sponsored transactions
26
+ - [Key pairs](./cryptography/keypairs.md): Create and manage Ed25519, Secp256k1, and Secp256r1
27
+ keypairs
28
+ - [Multi-Signature Transactions](./cryptography/multisig.md): Create multi-signature transactions
29
+ with multiple signers
30
+ - [Passkey](./cryptography/passkey.md): Use WebAuthn passkeys for Sui transaction signing
31
+ - [Web Crypto Signer](./cryptography/webcrypto-signer.md): Sign transactions using the Web Crypto
32
+ API
33
+ - [The `@mysten/sui/utils` package](./utils/index.md): Utility functions for addresses, coins, and
34
+ common operations
35
+ - [Derived Objects](./utils/derived_objects.md): Compute derived object IDs from parent objects
36
+ - [BCS](./bcs.md): Binary Canonical Serialization for encoding Sui Move types
37
+ - [ZkLogin](./zklogin.md): Zero-knowledge authentication with OAuth providers on Sui
38
+ - [Transaction Executors](./executors.md): Manage transaction execution with queuing and parallel
39
+ strategies
40
+ - [Transaction Plugins](./plugins.md): Extend transaction building with reusable plugins
41
+ - [Building SDKs](./sdk-building.md): Build custom SDKs on top of the Sui TypeScript SDK
42
+ - [Migrate to 2.0](./migrations/sui-2.0/index.md): Migration guide for Sui TypeScript SDK 2.0
43
+ - [Agent Migration Prompt](./migrations/sui-2.0/agent-prompt.md): AI agent prompt for automated SDK
44
+ 2.0 migration
45
+ - [@mysten/sui](./migrations/sui-2.0/sui.md): Migrate @mysten/sui from 1.x to 2.0
46
+ - [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md): Migrate from JSON-RPC to
47
+ the new Core API
48
+ - [@mysten/dapp-kit](./migrations/sui-2.0/dapp-kit.md): Migrate @mysten/dapp-kit to 2.0
49
+ - [@mysten/kiosk](./migrations/sui-2.0/kiosk.md): Migrate @mysten/kiosk to 2.0
50
+ - [@mysten/zksend](./migrations/sui-2.0/zksend.md): Migrate @mysten/zksend to 2.0
51
+ - [@mysten/suins](./migrations/sui-2.0/suins.md): Migrate @mysten/suins to 2.0
52
+ - [@mysten/deepbook-v3](./migrations/sui-2.0/deepbook-v3.md): Migrate @mysten/deepbook-v3 to 2.0
53
+ - [@mysten/walrus](./migrations/sui-2.0/walrus.md): Migrate @mysten/walrus to 2.0
54
+ - [@mysten/seal](./migrations/sui-2.0/seal.md): Migrate @mysten/seal to 2.0
55
+ - [Wallet Builders](./migrations/sui-2.0/wallet-builders.md): Migration guide for wallet extension
56
+ developers
57
+ - [SDK Maintainers](./migrations/sui-2.0/sdk-maintainers.md): Migration guide for SDK maintainers
58
+ and library authors
59
+ - [Migrate to 1.0](./migrations/sui-1.0.md): Migrate to Sui TypeScript SDK 1.0
60
+ - [Migrate to 0.38.0](./migrations/0.38.md): Migrate from SDK version 0.37 to 0.38
@@ -0,0 +1,57 @@
1
+ # Migrate to 0.38.0
2
+
3
+ > Migrate from SDK version 0.37 to 0.38
4
+
5
+ > **Warning:** The 1.0 release of the SDK contains many additional changes. This document may help
6
+ > help as an intermediate step when upgrading from older versions of the SDK, but all apps should be
7
+ > upgraded to the latest version of the SDK instead of 0.38.0.
8
+
9
+ The Sui TypeScript SDK was refactored beginning with version 0.38.0. If you are updating from an
10
+ earlier version of the SDK, there are some changes you should consider when updating your code.
11
+
12
+ ### Module structure
13
+
14
+ The Sui TypeScript SDK is now divided into modular components. Before version 0.38.0, you imported
15
+ the complete SDK module. Now, you upload the individual packages of the SDK module instead. See the
16
+ [Module Packages section](#module-packages) for the list of packages.
17
+
18
+ ### Deprecated classes
19
+
20
+ The Sui TypeScript SDK deprecates the following classes with version 0.38.0:
21
+
22
+ - `JsonRpcProvider` - The `JsonRpcProvider` class is deprecated in favor of the `suiClient` class
23
+ when creating a client for a Sui network. See
24
+ [Network Interactions with SuiJsonRpcClient](/sui/clients) for more information.
25
+ - `SignerWithProver` and `RawSigner` - Key pairs now directly support signing transactions and
26
+ messages without the need of a `Signer` class. See the [Key pairs](/sui/cryptography/keypairs)
27
+ topic for more information.
28
+ - `signAndExecuteTransaction` - This method was not deprecated, but is now part of
29
+ `SuiJsonRpcClient`.
30
+ - `Connection` classes - The `Connection` classes (`Connection`, `devnetConnection`, and so on) have
31
+ been deprecated in favor ofSuiJsonRpcClientuiClient` for establishing the connection. See
32
+ [Network Interactions with SuiJsonRpcClient](/sui/clients) for more information.
33
+ - The `superstruct` type definitions for `JsonRPCProvider` types are replaced with generated types
34
+ exported from `@mysten/sui/client`. The new type definitions are pure TypeScript types that you
35
+ can't use for runtime validation.
36
+ - A more stable JSON-RPC API has reduced the need for many of the SDK "getter" methods, which are
37
+ now deprecated.
38
+
39
+ ### Signing transactions
40
+
41
+ Signing and sending transactions changes slightly with the deprecation of the `Signer` pattern. For
42
+ an example of transaction signing, see the
43
+ [Sui Programmable Transaction Blocks Basics](/sui/transaction-building/basics) topic.
44
+
45
+ ### Faucet requests
46
+
47
+ SuiJsonRpcClient The ability to request SUI from a faucet is not part of `SuiJsonRpcClient` as it
48
+ was with `JsonRpcProvider`. Instead, you must use the `requestSuiFromFaucetV0` method from
49
+ `@mysten/sui/faucet`. The `@mysten/sui/faucet` import also provides a `getFaucetHost` method to
50
+ retrieve the faucet URL for `localnet`, `testnet`, or `devnet` networks.
51
+
52
+ ```ts
53
+ await requestSuiFromFaucetV0({
54
+ host: getFaucetHost('devnet'),
55
+ recipient: '<SUI_ADDRESS>',
56
+ });
57
+ ```