@mysten/docs 0.1.1
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/README.md +24 -0
- package/dist/bcs/index.md +358 -0
- package/dist/bcs/llms-index.md +4 -0
- package/dist/codegen/index.md +441 -0
- package/dist/codegen/llms-index.md +4 -0
- package/dist/dapp-kit/actions/connect-wallet.md +69 -0
- package/dist/dapp-kit/actions/disconnect-wallet.md +38 -0
- package/dist/dapp-kit/actions/sign-and-execute-transaction.md +96 -0
- package/dist/dapp-kit/actions/sign-personal-message.md +58 -0
- package/dist/dapp-kit/actions/sign-transaction.md +65 -0
- package/dist/dapp-kit/actions/switch-account.md +37 -0
- package/dist/dapp-kit/actions/switch-network.md +37 -0
- package/dist/dapp-kit/dapp-kit-instance.md +162 -0
- package/dist/dapp-kit/getting-started/create-dapp.md +151 -0
- package/dist/dapp-kit/getting-started/next-js.md +162 -0
- package/dist/dapp-kit/getting-started/react.md +172 -0
- package/dist/dapp-kit/getting-started/vue.md +193 -0
- package/dist/dapp-kit/index.md +70 -0
- package/dist/dapp-kit/llms-index.md +26 -0
- package/dist/dapp-kit/react/components/connect-button.md +42 -0
- package/dist/dapp-kit/react/components/connect-modal.md +51 -0
- package/dist/dapp-kit/react/components/index.md +13 -0
- package/dist/dapp-kit/react/dapp-kit-provider.md +86 -0
- package/dist/dapp-kit/react/hooks/index.md +25 -0
- package/dist/dapp-kit/react/hooks/use-current-account.md +33 -0
- package/dist/dapp-kit/react/hooks/use-current-client.md +36 -0
- package/dist/dapp-kit/react/hooks/use-current-network.md +28 -0
- package/dist/dapp-kit/react/hooks/use-current-wallet.md +36 -0
- package/dist/dapp-kit/react/hooks/use-dapp-kit.md +100 -0
- package/dist/dapp-kit/react/hooks/use-wallet-connection.md +48 -0
- package/dist/dapp-kit/react/hooks/use-wallets.md +33 -0
- package/dist/dapp-kit/state.md +169 -0
- package/dist/dapp-kit/theming.md +196 -0
- package/dist/dapp-kit/web-components/connect-button.md +89 -0
- package/dist/dapp-kit/web-components/connect-modal.md +177 -0
- package/dist/kiosk/advanced-examples.md +101 -0
- package/dist/kiosk/from-v1.md +320 -0
- package/dist/kiosk/index.md +22 -0
- package/dist/kiosk/kiosk-client/introduction.md +52 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +119 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +235 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +110 -0
- package/dist/kiosk/kiosk-client/querying.md +237 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
- package/dist/kiosk/llms-index.md +8 -0
- package/dist/llms-index.md +125 -0
- package/dist/payment-kit/getting-started.md +256 -0
- package/dist/payment-kit/index.md +132 -0
- package/dist/payment-kit/llms-index.md +8 -0
- package/dist/payment-kit/payment-kit-sdk.md +747 -0
- package/dist/payment-kit/payment-processing.md +372 -0
- package/dist/payment-kit/registry-management.md +529 -0
- package/dist/seal/index.md +85 -0
- package/dist/seal/llms-index.md +4 -0
- package/dist/slush-wallet/dapp.md +95 -0
- package/dist/slush-wallet/deep-linking.md +465 -0
- package/dist/slush-wallet/index.md +7 -0
- package/dist/slush-wallet/llms-index.md +6 -0
- package/dist/sui/bcs.md +134 -0
- package/dist/sui/clients/core.md +606 -0
- package/dist/sui/clients/graphql.md +101 -0
- package/dist/sui/clients/grpc.md +155 -0
- package/dist/sui/clients/index.md +95 -0
- package/dist/sui/clients/json-rpc.md +239 -0
- package/dist/sui/cryptography/keypairs.md +267 -0
- package/dist/sui/cryptography/multisig.md +194 -0
- package/dist/sui/cryptography/passkey.md +111 -0
- package/dist/sui/cryptography/webcrypto-signer.md +81 -0
- package/dist/sui/executors.md +148 -0
- package/dist/sui/faucet.md +26 -0
- package/dist/sui/hello-sui.md +115 -0
- package/dist/sui/index.md +53 -0
- package/dist/sui/install.md +61 -0
- package/dist/sui/llm-docs.md +32 -0
- package/dist/sui/llms-index.md +44 -0
- package/dist/sui/migrations/0.38.md +58 -0
- package/dist/sui/migrations/sui-1.0.md +455 -0
- package/dist/sui/migrations/sui-2.0/agent-prompt.md +42 -0
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +350 -0
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/dist/sui/migrations/sui-2.0/index.md +158 -0
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +386 -0
- package/dist/sui/migrations/sui-2.0/kiosk.md +120 -0
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/dist/sui/migrations/sui-2.0/seal.md +14 -0
- package/dist/sui/migrations/sui-2.0/sui.md +341 -0
- package/dist/sui/migrations/sui-2.0/suins.md +43 -0
- package/dist/sui/migrations/sui-2.0/wallet-builders.md +66 -0
- package/dist/sui/migrations/sui-2.0/walrus.md +41 -0
- package/dist/sui/migrations/sui-2.0/zksend.md +95 -0
- package/dist/sui/plugins.md +258 -0
- package/dist/sui/sdk-building.md +344 -0
- package/dist/sui/transaction-building/basics.md +299 -0
- package/dist/sui/transaction-building/gas.md +62 -0
- package/dist/sui/transaction-building/intents.md +62 -0
- package/dist/sui/transaction-building/offline.md +73 -0
- package/dist/sui/transaction-building/sponsored-transactions.md +22 -0
- package/dist/sui/utils/derived_objects.md +59 -0
- package/dist/sui/utils/index.md +52 -0
- package/dist/sui/zklogin.md +83 -0
- package/dist/walrus/index.md +527 -0
- package/dist/walrus/llms-index.md +4 -0
- package/dist/zksend/index.md +27 -0
- package/dist/zksend/link-builder.md +192 -0
- package/dist/zksend/llms-index.md +5 -0
- package/package.json +66 -0
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
|
|
39
|
+
const client = new SuiGrpcClient({
|
|
40
|
+
network: 'devnet',
|
|
41
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const executor = new SerialTransactionExecutor({
|
|
45
|
+
client,
|
|
46
|
+
signer: yourKeyPair,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const tx1 = new Transaction();
|
|
50
|
+
const [coin1] = tx1.splitCoins(tx1.gas, [1]);
|
|
51
|
+
tx1.transferObjects([coin1], address1);
|
|
52
|
+
const tx2 = new Transaction();
|
|
53
|
+
const [coin2] = tx2.splitCoins(tx2.gas, [1]);
|
|
54
|
+
tx2.transferObjects([coin2], address2);
|
|
55
|
+
|
|
56
|
+
const [{ digest: digest1 }, { digest: digest2 }] = await Promise.all([
|
|
57
|
+
executor.executeTransaction(tx1),
|
|
58
|
+
executor.executeTransaction(tx2),
|
|
59
|
+
]);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## `ParallelTransactionExecutor`
|
|
63
|
+
|
|
64
|
+
> **Warning:** `ParallelTransactionExecutor` is experimental and may change rapidly as it is being 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
|
+
|
|
108
|
+
const client = new SuiJsonRpcClient({ url: getJsonRpcFullnodeUrl('devnet'), network: 'devnet' });
|
|
109
|
+
|
|
110
|
+
const executor = new ParallelTransactionExecutor({
|
|
111
|
+
client,
|
|
112
|
+
signer: yourKeyPair,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const tx1 = new Transaction();
|
|
116
|
+
const [coin1] = tx1.splitCoins(tx1.gas, [1]);
|
|
117
|
+
tx1.transferObjects([coin1], address1);
|
|
118
|
+
const tx2 = new Transaction();
|
|
119
|
+
const [coin2] = tx2.splitCoins(tx2.gas, [1]);
|
|
120
|
+
tx2.transferObjects([coin2], address2);
|
|
121
|
+
|
|
122
|
+
const [{ digest: digest1 }, { digest: digest2 }] = await Promise.all([
|
|
123
|
+
executor.executeTransaction(tx1),
|
|
124
|
+
executor.executeTransaction(tx2),
|
|
125
|
+
]);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Building and Executing Transactions with Executors
|
|
129
|
+
|
|
130
|
+
The executor classes will significantly improve efficiency when executing multiple transactions, but
|
|
131
|
+
to get the best results there are some best practices to follow:
|
|
132
|
+
|
|
133
|
+
When building transactions, always prefer using unresolved object IDs rather than specifying the
|
|
134
|
+
full `id`/`version`/`digest` for an object input (eg use `tx.object(id)` rather than
|
|
135
|
+
`tx.objectRef({ objectId, version, digest })`). By doing this, you allow the executor to use object
|
|
136
|
+
versions and digests from the cache, and will avoid executing transactions using stale object
|
|
137
|
+
versions.
|
|
138
|
+
|
|
139
|
+
If the signer executes transactions that are not sent through the executor that may cause
|
|
140
|
+
transactions to fail. The executor classes will handle this by invalidating the cache for any
|
|
141
|
+
objects used in the transaction, so you will often be able to recover by re-trying a failed
|
|
142
|
+
transaction once. If it was caused by a stale cache, it should succeed on the second execution.
|
|
143
|
+
|
|
144
|
+
> **Warning:** Transaction plugins and intents may resolve their own data (such as object references) that are
|
|
145
|
+
> not automatically managed by the executor's object cache. This can cause transactions to include
|
|
146
|
+
> stale object versions. The `coinWithBalance` intent is partially supported by the executors and
|
|
147
|
+
> will work correctly when all coin types are either SUI or the required balances are available as
|
|
148
|
+
> address balances rather than coin objects.
|
|
@@ -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, you surpass
|
|
25
|
+
> the limit and must wait to successfully run it again. For testnet, the best way to get SUI is via
|
|
26
|
+
> the Web UI: `faucet.sui.io`.
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
|
|
59
|
+
// replace <YOUR_SUI_ADDRESS> with your actual address, which is in the form 0x123...
|
|
60
|
+
const MY_ADDRESS = '<YOUR_SUI_ADDRESS>';
|
|
61
|
+
|
|
62
|
+
// create a new SuiGrpcClient object pointing to the network you want to use
|
|
63
|
+
const suiClient = new SuiGrpcClient({
|
|
64
|
+
network: 'devnet',
|
|
65
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Convert MIST to Sui
|
|
69
|
+
const balance = (balance) => {
|
|
70
|
+
return Number.parseInt(balance.totalBalance) / Number(MIST_PER_SUI);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// store the JSON representation for the SUI the address owns before using faucet
|
|
74
|
+
const suiBefore = await suiClient.getBalance({
|
|
75
|
+
owner: MY_ADDRESS,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await requestSuiFromFaucetV2({
|
|
79
|
+
// use getFaucetHost to make sure you're using correct faucet address
|
|
80
|
+
// you can also just use the address (see Sui TypeScript SDK Quick Start for values)
|
|
81
|
+
host: getFaucetHost('devnet'),
|
|
82
|
+
recipient: MY_ADDRESS,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// store the JSON representation for the SUI the address owns after using faucet
|
|
86
|
+
const suiAfter = await suiClient.getBalance({
|
|
87
|
+
owner: MY_ADDRESS,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Output result to console.
|
|
91
|
+
console.log(
|
|
92
|
+
`Balance before faucet: ${balance(suiBefore)} SUI. Balance after: ${balance(
|
|
93
|
+
suiAfter,
|
|
94
|
+
)} SUI. Hello, SUI!`,
|
|
95
|
+
);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Save the file, then use Node.js to run it in your Console or Terminal:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
node index.js
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The code imports the `requestSuiFromFaucetV2` function from the SDK and calls it to mint SUI for the
|
|
105
|
+
provided address. The code also imports `SuiGrpcClient` to create a new client on the Sui network
|
|
106
|
+
that it uses to query the address and output the amount of SUI the address owns before and after
|
|
107
|
+
using the faucet. You can check the total SUI for your address using the Sui Wallet or Sui Client
|
|
108
|
+
CLI.
|
|
109
|
+
|
|
110
|
+
> **Note:** Faucets on Devnet and Testnet are rate limited. If you run the script too many times, you surpass
|
|
111
|
+
> the limit and must wait to successfully run it again. For testnet, the best way to get SUI is via
|
|
112
|
+
> the Web UI: `faucet.sui.io`.
|
|
113
|
+
|
|
114
|
+
You can also use the [Sui Client CLI](https://docs.sui.io/references/cli/client) to perform client
|
|
115
|
+
calls on a Sui network.
|
|
@@ -0,0 +1,53 @@
|
|
|
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. The public
|
|
26
|
+
> endpoints maintained by Mysten Labs (`fullnode.<NETWORK>.sui.io:443`) are rate-limited, and support
|
|
27
|
+
> only 100 requests per 30 seconds or so. Do not use public endpoints in production applications with
|
|
28
|
+
> high traffic volume.
|
|
29
|
+
>
|
|
30
|
+
> You can either run your own Full nodes, or outsource this to a professional infrastructure provider
|
|
31
|
+
> (preferred for apps that have high traffic). You can find a list of reliable RPC endpoint providers
|
|
32
|
+
> for Sui on the [Sui Dev Portal](https://sui.io/developers#dev-tools) using the **Node Service** tab.
|
|
33
|
+
|
|
34
|
+
## Module packages
|
|
35
|
+
|
|
36
|
+
The SDK contains a set of modular packages that you can use independently or together. Import just
|
|
37
|
+
what you need to keep your code light and compact.
|
|
38
|
+
|
|
39
|
+
- [`@mysten/sui/client`](/sui/clients) - A client for interacting with Sui RPC nodes.
|
|
40
|
+
- [`@mysten/sui/bcs`](/sui/bcs) - A BCS builder with pre-defined types for Sui.
|
|
41
|
+
- [`@mysten/sui/transactions`](/sui/transaction-building/basics) - Utilities for building and
|
|
42
|
+
interacting with transactions.
|
|
43
|
+
- [`@mysten/sui/keypairs/*`](/sui/cryptography/keypairs) - Modular exports for specific KeyPair
|
|
44
|
+
implementations.
|
|
45
|
+
- [`@mysten/sui/verify`](/sui/cryptography/keypairs#verifying-signatures-without-a-key-pair) -
|
|
46
|
+
Methods for verifying transactions and messages.
|
|
47
|
+
- [`@mysten/sui/cryptography`](/sui/cryptography/keypairs) - Shared types and classes for
|
|
48
|
+
cryptography.
|
|
49
|
+
- [`@mysten/sui/multisig`](/sui/cryptography/multisig) - Utilities for working with multisig
|
|
50
|
+
signatures.
|
|
51
|
+
- [`@mysten/sui/utils`](/sui/utils) - Utilities for formatting and parsing various Sui types.
|
|
52
|
+
- [`@mysten/sui/faucet`](/sui/faucet) - Methods for requesting SUI from a faucet.
|
|
53
|
+
- [`@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,44 @@
|
|
|
1
|
+
# Sui SDK
|
|
2
|
+
> TypeScript interfaces for Sui
|
|
3
|
+
|
|
4
|
+
- [Sui TypeScript SDK Quick Start](./index.md): TypeScript SDK for building on the Sui blockchain
|
|
5
|
+
- [Install Sui TypeScript SDK](./install.md): Install the @mysten/sui package and configure your project
|
|
6
|
+
- [LLM Documentation](./llm-docs.md): Give AI agents access to Sui SDK documentation in your project
|
|
7
|
+
- [Hello Sui](./hello-sui.md): Build your first Sui application with the TypeScript SDK
|
|
8
|
+
- [Faucet](./faucet.md): Request test SUI tokens from the faucet
|
|
9
|
+
- [Sui Clients](./clients/index.md): Choose and configure gRPC, GraphQL, or JSON-RPC clients
|
|
10
|
+
- [Core API](./clients/core.md): Transport-agnostic Core API shared by all Sui clients
|
|
11
|
+
- [SuiGrpcClient](./clients/grpc.md): Connect to Sui via gRPC with SuiGrpcClient
|
|
12
|
+
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui via GraphQL with SuiGraphQLClient
|
|
13
|
+
- [SuiJsonRpcClient](./clients/json-rpc.md): Connect to Sui via JSON-RPC with SuiJsonRpcClient
|
|
14
|
+
- [Sui Programmable Transaction Basics](./transaction-building/basics.md): Construct programmable transaction blocks with the Transaction API
|
|
15
|
+
- [Paying for Sui Transactions with Gas Coins](./transaction-building/gas.md): Configure gas budget, price, and coin selection for transactions
|
|
16
|
+
- [Transaction Intents](./transaction-building/intents.md): Use high-level intents to simplify transaction building
|
|
17
|
+
- [Building Offline](./transaction-building/offline.md): Build transactions without a network connection
|
|
18
|
+
- [Sponsored Transactions](./transaction-building/sponsored-transactions.md): Pay gas fees on behalf of other users with sponsored transactions
|
|
19
|
+
- [Key pairs](./cryptography/keypairs.md): Create and manage Ed25519, Secp256k1, and Secp256r1 keypairs
|
|
20
|
+
- [Multi-Signature Transactions](./cryptography/multisig.md): Create multi-signature transactions with multiple signers
|
|
21
|
+
- [Passkey](./cryptography/passkey.md): Use WebAuthn passkeys for Sui transaction signing
|
|
22
|
+
- [Web Crypto Signer](./cryptography/webcrypto-signer.md): Sign transactions using the Web Crypto API
|
|
23
|
+
- [The `@mysten/sui/utils` package](./utils/index.md): Utility functions for addresses, coins, and common operations
|
|
24
|
+
- [Derived Objects](./utils/derived_objects.md): Compute derived object IDs from parent objects
|
|
25
|
+
- [BCS](./bcs.md): Binary Canonical Serialization for encoding Sui Move types
|
|
26
|
+
- [ZkLogin](./zklogin.md): Zero-knowledge authentication with OAuth providers on Sui
|
|
27
|
+
- [Transaction Executors](./executors.md): Manage transaction execution with queuing and parallel strategies
|
|
28
|
+
- [Transaction Plugins](./plugins.md): Extend transaction building with reusable plugins
|
|
29
|
+
- [Building SDKs](./sdk-building.md): Build custom SDKs on top of the Sui TypeScript SDK
|
|
30
|
+
- [Migrate to 2.0](./migrations/sui-2.0/index.md): Migration guide for Sui TypeScript SDK 2.0
|
|
31
|
+
- [Agent Migration Prompt](./migrations/sui-2.0/agent-prompt.md): AI agent prompt for automated SDK 2.0 migration
|
|
32
|
+
- [@mysten/sui](./migrations/sui-2.0/sui.md): Migrate @mysten/sui from 1.x to 2.0
|
|
33
|
+
- [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md): Migrate from JSON-RPC to the new Core API
|
|
34
|
+
- [@mysten/dapp-kit](./migrations/sui-2.0/dapp-kit.md): Migrate @mysten/dapp-kit to 2.0
|
|
35
|
+
- [@mysten/kiosk](./migrations/sui-2.0/kiosk.md): Migrate @mysten/kiosk to 2.0
|
|
36
|
+
- [@mysten/zksend](./migrations/sui-2.0/zksend.md): Migrate @mysten/zksend to 2.0
|
|
37
|
+
- [@mysten/suins](./migrations/sui-2.0/suins.md): Migrate @mysten/suins to 2.0
|
|
38
|
+
- [@mysten/deepbook-v3](./migrations/sui-2.0/deepbook-v3.md): Migrate @mysten/deepbook-v3 to 2.0
|
|
39
|
+
- [@mysten/walrus](./migrations/sui-2.0/walrus.md): Migrate @mysten/walrus to 2.0
|
|
40
|
+
- [@mysten/seal](./migrations/sui-2.0/seal.md): Migrate @mysten/seal to 2.0
|
|
41
|
+
- [Wallet Builders](./migrations/sui-2.0/wallet-builders.md): Migration guide for wallet extension developers
|
|
42
|
+
- [SDK Maintainers](./migrations/sui-2.0/sdk-maintainers.md): Migration guide for SDK maintainers and library authors
|
|
43
|
+
- [Migrate to 1.0](./migrations/sui-1.0.md): Migrate to Sui TypeScript SDK 1.0
|
|
44
|
+
- [Migrate to 0.38.0](./migrations/0.38.md): Migrate from SDK version 0.37 to 0.38
|
|
@@ -0,0 +1,58 @@
|
|
|
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 help as an
|
|
6
|
+
> intermediate step when upgrading from older versions of the SDK, but all apps should be upgraded to
|
|
7
|
+
> 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
|
+
|
|
54
|
+
await requestSuiFromFaucetV0({
|
|
55
|
+
host: getFaucetHost('devnet'),
|
|
56
|
+
recipient: '<SUI_ADDRESS>',
|
|
57
|
+
});
|
|
58
|
+
```
|