@mysten/sui 2.16.3 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +82 -1
- package/dist/grpc/client.d.mts +2 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +2 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/proto/google/protobuf/struct.mjs +1 -1
- package/dist/grpc/proto/google/protobuf/struct.mjs.map +1 -1
- package/dist/grpc/proto/google/rpc/status.mjs +1 -1
- package/dist/grpc/proto/google/rpc/status.mjs.map +1 -1
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +66 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.mjs +48 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.mjs.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.d.mts +135 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.d.mts.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.mjs +144 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/checkpoint.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.mjs +3 -3
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_contents.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.mjs +3 -3
- package/dist/grpc/proto/sui/rpc/v2/checkpoint_summary.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/effects.d.mts +71 -3
- package/dist/grpc/proto/sui/rpc/v2/effects.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/effects.mjs +71 -5
- package/dist/grpc/proto/sui/rpc/v2/effects.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/event.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +2 -2
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +3 -3
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package.mjs +13 -13
- package/dist/grpc/proto/sui/rpc/v2/move_package.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature.mjs +3 -3
- package/dist/grpc/proto/sui/rpc/v2/signature.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/state_service.mjs +3 -3
- package/dist/grpc/proto/sui/rpc/v2/state_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/system_state.mjs +2 -2
- package/dist/grpc/proto/sui/rpc/v2/system_state.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +16 -16
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +3 -2
- package/dist/grpc/proto/types.mjs +11 -1
- package/dist/grpc/proto/types.mjs.map +1 -1
- package/dist/jsonRpc/types/params.d.mts +5 -5
- package/dist/transactions/Transaction.d.mts +25 -11
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +8 -3
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/index.d.mts +2 -2
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/jwt-utils.d.mts.map +1 -1
- package/dist/zklogin/jwt-utils.mjs.map +1 -1
- package/dist/zklogin/utils.d.mts.map +1 -1
- package/dist/zklogin/utils.mjs +9 -0
- package/dist/zklogin/utils.mjs.map +1 -1
- package/docs/bcs.md +11 -6
- package/docs/clients/core.md +10 -9
- package/docs/clients/grpc.md +1 -1
- package/docs/index.md +176 -22
- package/docs/llms-index.md +6 -9
- package/docs/migrations/0.38.md +2 -2
- package/docs/migrations/sui-1.0.md +2 -2
- package/docs/migrations/sui-2.0/json-rpc-migration.md +76 -33
- package/docs/plugins.md +29 -5
- package/docs/transactions/basics.md +279 -0
- package/docs/transactions/coins-and-balances.md +293 -0
- package/docs/transactions/offline.md +192 -0
- package/docs/transactions/reference.md +380 -0
- package/docs/transactions/signing-and-execution.md +401 -0
- package/package.json +27 -27
- package/src/graphql/generated/queries.ts +46 -1
- package/src/graphql/generated/schema.graphql +49 -3
- package/src/graphql/generated/tada-env.ts +97 -1
- package/src/grpc/client.ts +3 -0
- package/src/grpc/proto/google/protobuf/struct.ts +1 -1
- package/src/grpc/proto/google/rpc/error_details.ts +4 -4
- package/src/grpc/proto/google/rpc/status.ts +1 -1
- package/src/grpc/proto/sui/forking/v1alpha/forking_service.client.ts +125 -0
- package/src/grpc/proto/sui/forking/v1alpha/forking_service.ts +230 -0
- package/src/grpc/proto/sui/rpc/v2/checkpoint.ts +1 -1
- package/src/grpc/proto/sui/rpc/v2/checkpoint_contents.ts +3 -3
- package/src/grpc/proto/sui/rpc/v2/checkpoint_summary.ts +3 -3
- package/src/grpc/proto/sui/rpc/v2/effects.ts +112 -6
- package/src/grpc/proto/sui/rpc/v2/event.ts +1 -1
- package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +2 -2
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +3 -3
- package/src/grpc/proto/sui/rpc/v2/move_package.ts +19 -13
- package/src/grpc/proto/sui/rpc/v2/move_package_service.ts +1 -1
- package/src/grpc/proto/sui/rpc/v2/object.ts +7 -1
- package/src/grpc/proto/sui/rpc/v2/signature.ts +3 -3
- package/src/grpc/proto/sui/rpc/v2/signature_verification_service.ts +7 -1
- package/src/grpc/proto/sui/rpc/v2/state_service.ts +9 -3
- package/src/grpc/proto/sui/rpc/v2/system_state.ts +2 -2
- package/src/grpc/proto/sui/rpc/v2/transaction.ts +22 -16
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +4 -4
- package/src/grpc/proto/types.ts +1 -0
- package/src/jsonRpc/types/params.ts +5 -5
- package/src/transactions/Transaction.ts +36 -5
- package/src/transactions/index.ts +1 -0
- package/src/version.ts +1 -1
- package/src/zklogin/jwt-utils.ts +3 -0
- package/src/zklogin/utils.ts +17 -0
- package/docs/faucet.md +0 -26
- package/docs/hello-sui.md +0 -115
- package/docs/install.md +0 -61
- package/docs/transaction-building/basics.md +0 -299
- package/docs/transaction-building/gas.md +0 -61
- package/docs/transaction-building/intents.md +0 -62
- package/docs/transaction-building/offline.md +0 -73
- package/docs/transaction-building/sponsored-transactions.md +0 -22
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# Commands and Inputs Reference
|
|
2
|
+
|
|
3
|
+
> Complete reference for transaction commands and input types
|
|
4
|
+
|
|
5
|
+
A
|
|
6
|
+
[programmable transaction block](https://docs.sui.io/guides/developer/transactions/prog-txn-blocks)
|
|
7
|
+
has two parts: **inputs** (objects and pure values) and **commands** (operations that execute on
|
|
8
|
+
those inputs). This page is a complete reference for all input types and commands available in the
|
|
9
|
+
SDK. For task-oriented guides, see [Building Transactions](./basics).
|
|
10
|
+
|
|
11
|
+
See also the [Sui documentation on PTB commands](https://docs.sui.io/references/ptb-commands) and
|
|
12
|
+
[inputs and results](https://docs.sui.io/concepts/transactions/inputs-and-results).
|
|
13
|
+
|
|
14
|
+
## Passing inputs
|
|
15
|
+
|
|
16
|
+
### Object references
|
|
17
|
+
|
|
18
|
+
Commands that accept objects (like `splitCoins`, `mergeCoins`, `transferObjects`, and `moveCall`)
|
|
19
|
+
accept any of the following as an object reference:
|
|
20
|
+
|
|
21
|
+
- **String object ID**:`'0xObjectId'`, SDK looks up version and digest at build time
|
|
22
|
+
- **`tx.object('0xObjectId')`**: Equivalent to a string ID, but explicit
|
|
23
|
+
- **`tx.objectRef({...})`**: Fully-resolved owned or immutable object (no lookup needed)
|
|
24
|
+
- **`tx.sharedObjectRef({...})`**: Fully-resolved shared object (no lookup needed)
|
|
25
|
+
- **`tx.receivingRef({...})`**: Fully-resolved receiving object (no lookup needed)
|
|
26
|
+
- **Transaction result**: The return value of a previous command (for example, from `splitCoins`)
|
|
27
|
+
- **`tx.coin({...})`** or **`coinWithBalance({...})`**: A coin intent resolved at build time
|
|
28
|
+
- **`tx.gas`**: The gas coin (when gas is paid from coin objects)
|
|
29
|
+
|
|
30
|
+
### JavaScript value shortcuts
|
|
31
|
+
|
|
32
|
+
For arguments where the expected type is known, you can pass plain JavaScript values. The SDK
|
|
33
|
+
coerces them to the correct Move type automatically.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// amounts in splitCoins are coerced to u64
|
|
37
|
+
tx.splitCoins(tx.gas, [100, 200]);
|
|
38
|
+
|
|
39
|
+
// addresses in transferObjects are coerced to address
|
|
40
|
+
tx.transferObjects([coin], '0xRecipientAddress');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Pure values
|
|
44
|
+
|
|
45
|
+
For Move primitive types, use `tx.pure` to serialize values as BCS:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
tx.pure.u8(255);
|
|
49
|
+
tx.pure.u16(65535);
|
|
50
|
+
tx.pure.u32(4294967295);
|
|
51
|
+
tx.pure.u64(100);
|
|
52
|
+
tx.pure.u128(100n);
|
|
53
|
+
tx.pure.u256(100n);
|
|
54
|
+
tx.pure.bool(true);
|
|
55
|
+
tx.pure.string('hello');
|
|
56
|
+
tx.pure.address('0xSomeAddress');
|
|
57
|
+
tx.pure.id('0xSomeObjectId');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Vectors and options
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Using type-specific methods
|
|
64
|
+
tx.pure.vector('u8', [1, 2, 3]);
|
|
65
|
+
tx.pure.option('u8', 1);
|
|
66
|
+
tx.pure.option('u8', null); // None
|
|
67
|
+
|
|
68
|
+
// Using type string syntax
|
|
69
|
+
tx.pure('vector<u8>', [1, 2, 3]);
|
|
70
|
+
tx.pure('option<u8>', 1);
|
|
71
|
+
tx.pure('option<u8>', null);
|
|
72
|
+
tx.pure('vector<option<u8>>', [1, null, 2]);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### BCS serialization
|
|
76
|
+
|
|
77
|
+
For complex types, use the BCS library directly:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
|
|
81
|
+
tx.pure(bcs.vector(bcs.U8).serialize([1, 2, 3]));
|
|
82
|
+
tx.pure(bcs.option(bcs.U8).serialize(1));
|
|
83
|
+
tx.pure(bcs.option(bcs.U8).serialize(null));
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Address balance withdrawals
|
|
87
|
+
|
|
88
|
+
> **Warning:** Address balances are currently only available on Devnet and Testnet. They are not yet supported on
|
|
89
|
+
> Mainnet.
|
|
90
|
+
|
|
91
|
+
Use `tx.withdrawal()` to create an input that withdraws from your address balance:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Withdraw SUI
|
|
95
|
+
const withdrawal = tx.withdrawal({ amount: 1_000_000_000 });
|
|
96
|
+
|
|
97
|
+
// Withdraw another coin type
|
|
98
|
+
const withdrawal = tx.withdrawal({ amount: 1_000_000, type: '0xPackageId::module::CoinType' });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See [Coins and Balances](./coins-and-balances#withdrawing-from-address-balance) for usage examples.
|
|
102
|
+
|
|
103
|
+
### The gas coin
|
|
104
|
+
|
|
105
|
+
`tx.gas` references the coin used for gas payment. It can be used as an input to commands:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const [coin] = tx.splitCoins(tx.gas, [1_000_000_000]);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **Warning:** `tx.gas` is not available when gas is paid from address balances. Use `tx.coin()` instead for
|
|
112
|
+
> portable code.
|
|
113
|
+
|
|
114
|
+
## Object inputs
|
|
115
|
+
|
|
116
|
+
Objects on Sui have different
|
|
117
|
+
[ownership types](https://docs.sui.io/guides/developer/objects/object-ownership), including
|
|
118
|
+
address-owned, shared, immutable, and object-owned (receiving). Each type requires different
|
|
119
|
+
metadata when used as a transaction input, but the SDK handles most of this automatically.
|
|
120
|
+
|
|
121
|
+
### tx.object(id)
|
|
122
|
+
|
|
123
|
+
The simplest way to reference an onchain object. The SDK automatically looks up the object's
|
|
124
|
+
version, digest, and type when the transaction is built:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
tx.moveCall({
|
|
128
|
+
target: '0xPackage::module::function',
|
|
129
|
+
arguments: [tx.object('0xSomeObjectId')],
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Object IDs can also be passed directly to commands that only accept objects:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
tx.transferObjects(['0xObjectId1', '0xObjectId2'], '0xRecipient');
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
When a Move function expects a `Receiving<T>` argument, `tx.object()` automatically converts the
|
|
140
|
+
reference to a receiving input:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
tx.moveCall({
|
|
144
|
+
target: '0xPackage::module::receive',
|
|
145
|
+
// The SDK detects the function signature expects Receiving<T> and adjusts accordingly
|
|
146
|
+
arguments: [tx.object('0xParentId'), tx.object('0xReceivingObjectId')],
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Fully-resolved object references
|
|
151
|
+
|
|
152
|
+
To avoid the SDK's automatic lookup (for [offline building](./offline) or performance), provide the
|
|
153
|
+
full object metadata directly:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Owned or immutable objects — need exact version and digest
|
|
157
|
+
tx.objectRef({
|
|
158
|
+
objectId: '0xObjectId',
|
|
159
|
+
version: '42',
|
|
160
|
+
digest: 'abc123...',
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Shared objects — need initial shared version (stable, doesn't change)
|
|
164
|
+
tx.sharedObjectRef({
|
|
165
|
+
objectId: '0xObjectId',
|
|
166
|
+
initialSharedVersion: '1',
|
|
167
|
+
mutable: true,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Receiving objects — need exact version and digest
|
|
171
|
+
tx.receivingRef({
|
|
172
|
+
objectId: '0xObjectId',
|
|
173
|
+
version: '42',
|
|
174
|
+
digest: 'abc123...',
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Shared objects
|
|
179
|
+
|
|
180
|
+
Shared objects are accessible by any transaction and are sequenced through consensus. When using
|
|
181
|
+
`tx.object()` with a shared object ID, the SDK looks up the required metadata automatically. For
|
|
182
|
+
offline building or performance, use `tx.sharedObjectRef()` with the `initialSharedVersion` (which
|
|
183
|
+
is stable and never changes after the object is shared):
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
tx.sharedObjectRef({
|
|
187
|
+
objectId: '0xSharedObjectId',
|
|
188
|
+
initialSharedVersion: '1',
|
|
189
|
+
mutable: true, // false for read-only access
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Party objects
|
|
194
|
+
|
|
195
|
+
Party objects are address-owned but consensus-versioned, with per-address permissions (read, write,
|
|
196
|
+
delete, or transfer). They are referenced the same way as shared objects:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
tx.sharedObjectRef({
|
|
200
|
+
objectId: '0xPartyObjectId',
|
|
201
|
+
initialSharedVersion: '1',
|
|
202
|
+
mutable: true,
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Key differences from regular owned objects:
|
|
207
|
+
|
|
208
|
+
- **Enable pipelining**: Multiple in-flight transactions on the same object
|
|
209
|
+
- **No version lookup needed**: `initialSharedVersion` is stable
|
|
210
|
+
- **Cannot be used for gas payment**: Use address balance for gas instead
|
|
211
|
+
|
|
212
|
+
### Object helpers
|
|
213
|
+
|
|
214
|
+
Common system objects have shorthand methods. Passing `mutable` skips the SDK's automatic mutability
|
|
215
|
+
lookup:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
tx.object.system(); // Sui system state (SDK looks up mutability)
|
|
219
|
+
tx.object.system({ mutable: true }); // Mutable system state (no lookup needed)
|
|
220
|
+
tx.object.system({ mutable: false }); // Immutable system state (no lookup needed)
|
|
221
|
+
tx.object.clock(); // On-chain clock (always immutable)
|
|
222
|
+
tx.object.random(); // Random number generator
|
|
223
|
+
tx.object.denyList(); // Coin deny list (SDK looks up mutability)
|
|
224
|
+
tx.object.denyList({ mutable: true }); // Mutable deny list (no lookup needed)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`tx.object.option` wraps an object as a Move `Option<T>`. This adds a `moveCall` command to the
|
|
228
|
+
transaction that constructs the option value:
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// Some — wraps the object in Option::some()
|
|
232
|
+
tx.object.option({
|
|
233
|
+
type: '0xPackage::module::Thing',
|
|
234
|
+
value: '0xObjectId',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// None — creates Option::none()
|
|
238
|
+
tx.object.option({
|
|
239
|
+
type: '0xPackage::module::Thing',
|
|
240
|
+
value: null,
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Commands
|
|
245
|
+
|
|
246
|
+
### `splitCoins`
|
|
247
|
+
|
|
248
|
+
Creates new coins by splitting amounts from an existing coin. Returns one result per amount.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const [coin1, coin2] = tx.splitCoins(coin, [amount1, amount2]);
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
| Parameter | Type | Description |
|
|
255
|
+
| --------- | -------------------------------------------------- | ------------------------- |
|
|
256
|
+
| `coin` | [object reference](#object-references) or `tx.gas` | The coin to split from |
|
|
257
|
+
| `amounts` | `(number \| bigint \| string)[]` | Amounts for each new coin |
|
|
258
|
+
|
|
259
|
+
### `mergeCoins`
|
|
260
|
+
|
|
261
|
+
Merges one or more source coins into a destination coin. The source coins are destroyed.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
tx.mergeCoins(destinationCoin, [sourceCoin1, sourceCoin2]);
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
| Parameter | Type | Description |
|
|
268
|
+
| ------------- | ---------------------------------------- | -------------------------------- |
|
|
269
|
+
| `destination` | [object reference](#object-references) | The coin to merge into |
|
|
270
|
+
| `sources` | [object reference](#object-references)[] | Coins to merge (destroyed after) |
|
|
271
|
+
|
|
272
|
+
### `transferObjects`
|
|
273
|
+
|
|
274
|
+
Transfers one or more objects to a recipient address.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
tx.transferObjects([obj1, obj2], recipientAddress);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
| Parameter | Type | Description |
|
|
281
|
+
| --------- | ---------------------------------------- | ------------------- |
|
|
282
|
+
| `objects` | [object reference](#object-references)[] | Objects to transfer |
|
|
283
|
+
| `address` | `string` | Recipient address |
|
|
284
|
+
|
|
285
|
+
### `moveCall`
|
|
286
|
+
|
|
287
|
+
Calls a function in a published Move package. Returns whatever the Move function returns.
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
const [result] = tx.moveCall({
|
|
291
|
+
target: '0xPackage::module::function',
|
|
292
|
+
arguments: [arg1, arg2],
|
|
293
|
+
typeArguments: ['0x2::sui::SUI'],
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
| Parameter | Type | Description |
|
|
298
|
+
| --------------- | ---------- | -------------------------------------------------- |
|
|
299
|
+
| `target` | `string` | `packageId::moduleName::functionName` |
|
|
300
|
+
| `arguments` | `any[]` | Function arguments (objects, pure values, results) |
|
|
301
|
+
| `typeArguments` | `string[]` | Move type parameters |
|
|
302
|
+
|
|
303
|
+
You can also pass `package`, `module`, and `function` separately instead of `target`:
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
tx.moveCall({
|
|
307
|
+
package: '0xPackageId',
|
|
308
|
+
module: 'my_module',
|
|
309
|
+
function: 'my_function',
|
|
310
|
+
arguments: [],
|
|
311
|
+
typeArguments: [],
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### `makeMoveVec`
|
|
316
|
+
|
|
317
|
+
Constructs a vector of objects for use in `moveCall`. Required because there's no other way to pass
|
|
318
|
+
a vector of objects as a transaction input.
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
const vec = tx.makeMoveVec({ elements: [obj1, obj2] });
|
|
322
|
+
|
|
323
|
+
// Pass the vector to a Move function
|
|
324
|
+
tx.moveCall({
|
|
325
|
+
target: '0xPackage::module::process_items',
|
|
326
|
+
arguments: [vec],
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
| Parameter | Type | Description |
|
|
331
|
+
| ---------- | ---------------------------------------- | -------------------------------- |
|
|
332
|
+
| `elements` | [object reference](#object-references)[] | Objects to include in the vector |
|
|
333
|
+
| `type` | `string` (optional) | Move type of the elements |
|
|
334
|
+
|
|
335
|
+
### `publish`
|
|
336
|
+
|
|
337
|
+
Publishes a new Move package. Returns the upgrade capability object.
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
const [upgradeCap] = tx.publish({ modules, dependencies });
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
| Parameter | Type | Description |
|
|
344
|
+
| -------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
345
|
+
| `modules` | `number[][] \| string[]` | Compiled module bytecodes. Each module as a `number[]` (byte array) or base64-encoded `string`. To convert from `Uint8Array`, use `Array.from(bytes)`. |
|
|
346
|
+
| `dependencies` | `string[]` | Package IDs of dependencies |
|
|
347
|
+
|
|
348
|
+
### `upgrade`
|
|
349
|
+
|
|
350
|
+
Upgrades an existing Move package.
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
const [upgradeReceipt] = tx.upgrade({ modules, dependencies, package: packageId, ticket });
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
| Parameter | Type | Description |
|
|
357
|
+
| -------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
358
|
+
| `modules` | `number[][] \| string[]` | Compiled module bytecodes. Each module as a `number[]` (byte array) or base64-encoded `string`. To convert from `Uint8Array`, use `Array.from(bytes)`. |
|
|
359
|
+
| `dependencies` | `string[]` | Package IDs of dependencies |
|
|
360
|
+
| `package` | `string` | ID of the package being upgraded |
|
|
361
|
+
| `ticket` | [object reference](#object-references) | The upgrade ticket |
|
|
362
|
+
|
|
363
|
+
## Transaction results
|
|
364
|
+
|
|
365
|
+
Every command returns a `TransactionResult` that can be used as input to subsequent commands:
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
const [coin] = tx.splitCoins(tx.gas, [100]);
|
|
369
|
+
tx.transferObjects([coin], address);
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
When a command returns multiple values, use destructuring or indexing:
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
const [a, b] = tx.moveCall({ target: '0xPkg::mod::returns_two' });
|
|
376
|
+
|
|
377
|
+
// or
|
|
378
|
+
const result = tx.moveCall({ target: '0xPkg::mod::returns_two' });
|
|
379
|
+
tx.transferObjects([result[0], result[1]], address);
|
|
380
|
+
```
|