@ocap/client 1.25.3 → 1.25.5

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 (92) hide show
  1. package/README.md +76 -80
  2. package/dist/report.html +1 -1
  3. package/docs/_sidebar.md +22 -0
  4. package/docs/api-reference-client-methods.ja.md +229 -0
  5. package/docs/api-reference-client-methods.md +229 -0
  6. package/docs/api-reference-client-methods.zh-TW.md +229 -0
  7. package/docs/api-reference-client-methods.zh.md +229 -0
  8. package/docs/api-reference-data-types.ja.md +482 -0
  9. package/docs/api-reference-data-types.md +482 -0
  10. package/docs/api-reference-data-types.zh-TW.md +482 -0
  11. package/docs/api-reference-data-types.zh.md +482 -0
  12. package/docs/api-reference-low-level-api.ja.md +228 -0
  13. package/docs/api-reference-low-level-api.md +228 -0
  14. package/docs/api-reference-low-level-api.zh-TW.md +228 -0
  15. package/docs/api-reference-low-level-api.zh.md +228 -0
  16. package/docs/api-reference-query-mutation-methods.ja.md +814 -0
  17. package/docs/api-reference-query-mutation-methods.md +814 -0
  18. package/docs/api-reference-query-mutation-methods.zh-TW.md +814 -0
  19. package/docs/api-reference-query-mutation-methods.zh.md +814 -0
  20. package/docs/api-reference-transaction-helpers.ja.md +649 -0
  21. package/docs/api-reference-transaction-helpers.md +649 -0
  22. package/docs/api-reference-transaction-helpers.zh-TW.md +649 -0
  23. package/docs/api-reference-transaction-helpers.zh.md +649 -0
  24. package/docs/api-reference.ja.md +23 -0
  25. package/docs/api-reference.md +23 -0
  26. package/docs/api-reference.zh-TW.md +23 -0
  27. package/docs/api-reference.zh.md +23 -0
  28. package/docs/core-concepts-client-architecture.ja.md +102 -0
  29. package/docs/core-concepts-client-architecture.md +102 -0
  30. package/docs/core-concepts-client-architecture.zh-TW.md +102 -0
  31. package/docs/core-concepts-client-architecture.zh.md +102 -0
  32. package/docs/core-concepts-event-subscriptions.ja.md +123 -0
  33. package/docs/core-concepts-event-subscriptions.md +123 -0
  34. package/docs/core-concepts-event-subscriptions.zh-TW.md +123 -0
  35. package/docs/core-concepts-event-subscriptions.zh.md +123 -0
  36. package/docs/core-concepts-gas-payment.ja.md +111 -0
  37. package/docs/core-concepts-gas-payment.md +111 -0
  38. package/docs/core-concepts-gas-payment.zh-TW.md +111 -0
  39. package/docs/core-concepts-gas-payment.zh.md +111 -0
  40. package/docs/core-concepts-transaction-lifecycle.ja.md +183 -0
  41. package/docs/core-concepts-transaction-lifecycle.md +183 -0
  42. package/docs/core-concepts-transaction-lifecycle.zh-TW.md +183 -0
  43. package/docs/core-concepts-transaction-lifecycle.zh.md +183 -0
  44. package/docs/core-concepts.ja.md +22 -0
  45. package/docs/core-concepts.md +22 -0
  46. package/docs/core-concepts.zh-TW.md +22 -0
  47. package/docs/core-concepts.zh.md +22 -0
  48. package/docs/getting-started-basic-usage.ja.md +87 -0
  49. package/docs/getting-started-basic-usage.md +87 -0
  50. package/docs/getting-started-basic-usage.zh-TW.md +87 -0
  51. package/docs/getting-started-basic-usage.zh.md +87 -0
  52. package/docs/getting-started-installation.ja.md +60 -0
  53. package/docs/getting-started-installation.md +60 -0
  54. package/docs/getting-started-installation.zh-TW.md +60 -0
  55. package/docs/getting-started-installation.zh.md +60 -0
  56. package/docs/getting-started.ja.md +16 -0
  57. package/docs/getting-started.md +16 -0
  58. package/docs/getting-started.zh-TW.md +16 -0
  59. package/docs/getting-started.zh.md +17 -0
  60. package/docs/how-to-guides-delegate-permissions.ja.md +167 -0
  61. package/docs/how-to-guides-delegate-permissions.md +167 -0
  62. package/docs/how-to-guides-delegate-permissions.zh-TW.md +167 -0
  63. package/docs/how-to-guides-delegate-permissions.zh.md +166 -0
  64. package/docs/how-to-guides-manage-accounts.ja.md +73 -0
  65. package/docs/how-to-guides-manage-accounts.md +73 -0
  66. package/docs/how-to-guides-manage-accounts.zh-TW.md +73 -0
  67. package/docs/how-to-guides-manage-accounts.zh.md +73 -0
  68. package/docs/how-to-guides-manage-assets.ja.md +255 -0
  69. package/docs/how-to-guides-manage-assets.md +255 -0
  70. package/docs/how-to-guides-manage-assets.zh-TW.md +255 -0
  71. package/docs/how-to-guides-manage-assets.zh.md +255 -0
  72. package/docs/how-to-guides-manage-tokens.ja.md +179 -0
  73. package/docs/how-to-guides-manage-tokens.md +179 -0
  74. package/docs/how-to-guides-manage-tokens.zh-TW.md +179 -0
  75. package/docs/how-to-guides-manage-tokens.zh.md +179 -0
  76. package/docs/how-to-guides-stake-tokens-and-assets.ja.md +205 -0
  77. package/docs/how-to-guides-stake-tokens-and-assets.md +205 -0
  78. package/docs/how-to-guides-stake-tokens-and-assets.zh-TW.md +205 -0
  79. package/docs/how-to-guides-stake-tokens-and-assets.zh.md +205 -0
  80. package/docs/how-to-guides-transfer-tokens-and-nfts.ja.md +179 -0
  81. package/docs/how-to-guides-transfer-tokens-and-nfts.md +179 -0
  82. package/docs/how-to-guides-transfer-tokens-and-nfts.zh-TW.md +179 -0
  83. package/docs/how-to-guides-transfer-tokens-and-nfts.zh.md +179 -0
  84. package/docs/how-to-guides.ja.md +27 -0
  85. package/docs/how-to-guides.md +27 -0
  86. package/docs/how-to-guides.zh-TW.md +27 -0
  87. package/docs/how-to-guides.zh.md +27 -0
  88. package/docs/overview.ja.md +70 -0
  89. package/docs/overview.md +70 -0
  90. package/docs/overview.zh-TW.md +70 -0
  91. package/docs/overview.zh.md +70 -0
  92. package/package.json +14 -14
@@ -0,0 +1,649 @@
1
+ # High-level API
2
+
3
+ Transaction helpers are high-level functions built into the OCAP Client that abstract away the complexity of creating and signing common transactions. Instead of manually constructing transaction objects, you can use these convenient methods for workflows like creating assets, transferring tokens, staking, and performing atomic swaps. These helpers ensure that the transaction structure is correct and simplify the development process significantly.
4
+
5
+ For a deeper understanding of the underlying transaction lifecycle, see [Core Concepts: Transaction Lifecycle](./core-concepts-transaction-lifecycle.md).
6
+
7
+ ---
8
+
9
+ ## Account Management
10
+
11
+ ### migrateAccount
12
+
13
+ Migrates the ownership of an account to a new key pair. This is useful for key rotation or account recovery.
14
+
15
+ **Parameters**
16
+
17
+ <x-field-group>
18
+ <x-field data-name="from" data-type="WalletObject" data-required="true" data-desc="The wallet object of the account to migrate from."></x-field>
19
+ <x-field data-name="to" data-type="WalletObject" data-required="true" data-desc="The wallet object of the account to migrate to."></x-field>
20
+ </x-field-group>
21
+
22
+ **Returns**
23
+
24
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
25
+
26
+ **Example**
27
+
28
+ ```javascript Send an AccountMigrateTx icon=logos:javascript
29
+ const txHash = await client.migrateAccount({
30
+ from: oldWallet,
31
+ to: newWallet,
32
+ });
33
+ console.log('Migration transaction hash:', txHash);
34
+ ```
35
+
36
+ ### delegate
37
+
38
+ Authorizes another account (the delegatee) to send specific types of transactions on behalf of the delegator. This is a powerful feature for creating secure, sandboxed permissions.
39
+
40
+ **Parameters**
41
+
42
+ <x-field-group>
43
+ <x-field data-name="from" data-type="WalletObject" data-required="true" data-desc="The delegator's wallet, who is granting the privilege."></x-field>
44
+ <x-field data-name="to" data-type="WalletObject" data-required="true" data-desc="The delegatee's wallet, who is receiving the privilege."></x-field>
45
+ <x-field data-name="privileges" data-type="array" data-required="true" data-desc="An array of privilege objects specifying the allowed actions.">
46
+ <x-field data-name="typeUrl" data-type="string" data-required="true" data-desc="The type URL of the transaction being permitted (e.g., 'fg:t:transfer_v2')."></x-field>
47
+ <x-field data-name="limit" data-type="object" data-required="false" data-desc="Optional limits on the delegation.">
48
+ <x-field data-name="tokens" data-type="array" data-desc="Limits on specific fungible tokens."></x-field>
49
+ <x-field data-name="assets" data-type="array" data-desc="Limits on specific assets (NFTs)."></x-field>
50
+ </x-field>
51
+ </x-field>
52
+ </x-field-group>
53
+
54
+ **Returns**
55
+
56
+ <x-field data-name="result" data-type="Promise<[string, string]>" data-desc="An array containing the transaction hash and the newly created delegate address."></x-field>
57
+
58
+ **Example**
59
+
60
+ ```javascript Send a DelegateTx icon=logos:javascript
61
+ const [txHash, delegateAddress] = await client.delegate({
62
+ from: userWallet,
63
+ to: appWallet,
64
+ privileges: [
65
+ {
66
+ typeUrl: 'fg:t:transfer_v2',
67
+ },
68
+ ],
69
+ });
70
+ console.log('Delegation tx hash:', txHash);
71
+ console.log('Delegate address:', delegateAddress);
72
+ ```
73
+
74
+ ### revokeDelegate
75
+
76
+ Revokes previously granted permissions from a delegatee.
77
+
78
+ **Parameters**
79
+
80
+ <x-field-group>
81
+ <x-field data-name="from" data-type="WalletObject" data-required="true" data-desc="The delegator's wallet."></x-field>
82
+ <x-field data-name="to" data-type="WalletObject" data-required="true" data-desc="The delegatee's wallet."></x-field>
83
+ <x-field data-name="privileges" data-type="array" data-required="true" data-desc="An array of privilege objects specifying the permissions to revoke.">
84
+ <x-field data-name="typeUrl" data-type="string" data-required="true" data-desc="The type URL of the transaction to revoke (e.g., 'fg:t:transfer_v2')."></x-field>
85
+ </x-field>
86
+ </x-field-group>
87
+
88
+ **Returns**
89
+
90
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
91
+
92
+ **Example**
93
+
94
+ ```javascript Send a RevokeDelegateTx icon=logos:javascript
95
+ const txHash = await client.revokeDelegate({
96
+ from: userWallet,
97
+ to: appWallet,
98
+ privileges: ['fg:t:transfer_v2'],
99
+ });
100
+ console.log('Revocation tx hash:', txHash);
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Asset (NFT) Management
106
+
107
+ ### createAsset
108
+
109
+ Creates a new asset (Non-Fungible Token) on the blockchain.
110
+
111
+ **Parameters**
112
+
113
+ <x-field-group>
114
+ <x-field data-name="moniker" data-type="string" data-required="true" data-desc="A short, human-readable name for the asset."></x-field>
115
+ <x-field data-name="data" data-type="object" data-required="true" data-desc="A JSON object containing the asset's metadata."></x-field>
116
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the asset's initial owner."></x-field>
117
+ <x-field data-name="parent" data-type="string" data-required="false" data-desc="The address of a parent asset, establishing a hierarchical link."></x-field>
118
+ <x-field data-name="ttl" data-type="number" data-required="false" data-default="0" data-desc="Time-to-live in seconds after the first consumption."></x-field>
119
+ <x-field data-name="readonly" data-type="boolean" data-required="false" data-default="false" data-desc="If true, the asset cannot be updated after creation."></x-field>
120
+ <x-field data-name="transferrable" data-type="boolean" data-required="false" data-default="true" data-desc="If true, the asset can be transferred to another account."></x-field>
121
+ <x-field data-name="display" data-type="object" data-required="false" data-desc="Object for asset display metadata."></x-field>
122
+ <x-field data-name="endpoint" data-type="object" data-required="false" data-desc="Object for asset endpoint metadata."></x-field>
123
+ <x-field data-name="tags" data-type="string[]" data-required="false" data-desc="An array of tags for categorization."></x-field>
124
+ <x-field data-name="delegator" data-type="string" data-required="false" data-desc="The address of the delegator, if the transaction is sent by a delegatee."></x-field>
125
+ </x-field-group>
126
+
127
+ **Returns**
128
+
129
+ <x-field data-name="result" data-type="Promise<[string, string]>" data-desc="An array containing the transaction hash and the address of the newly created asset."></x-field>
130
+
131
+ **Example**
132
+
133
+ ```javascript Send a CreateAssetTx icon=logos:javascript
134
+ const [txHash, assetAddress] = await client.createAsset({
135
+ moniker: 'My First NFT',
136
+ data: {
137
+ typeUrl: 'json',
138
+ value: { name: 'Digital Collectible', description: 'A unique item.' },
139
+ },
140
+ wallet: userWallet,
141
+ });
142
+ console.log('Create asset tx hash:', txHash);
143
+ console.log('New asset address:', assetAddress);
144
+ ```
145
+
146
+ ### updateAsset
147
+
148
+ Updates the `moniker` and `data` fields of an existing, non-readonly asset.
149
+
150
+ **Parameters**
151
+
152
+ <x-field-group>
153
+ <x-field data-name="address" data-type="string" data-required="true" data-desc="The address of the asset to update."></x-field>
154
+ <x-field data-name="moniker" data-type="string" data-required="true" data-desc="The new moniker for the asset."></x-field>
155
+ <x-field data-name="data" data-type="object" data-required="true" data-desc="The new JSON data object for the asset."></x-field>
156
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the asset's current owner."></x-field>
157
+ </x-field-group>
158
+
159
+ **Returns**
160
+
161
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
162
+
163
+ **Example**
164
+
165
+ ```javascript Send an UpdateAssetTx icon=logos:javascript
166
+ const txHash = await client.updateAsset({
167
+ address: 'z3g...',
168
+ moniker: 'Updated NFT Name',
169
+ data: {
170
+ typeUrl: 'json',
171
+ value: { name: 'Updated Collectible', description: 'Now with more features!' },
172
+ },
173
+ wallet: userWallet,
174
+ });
175
+ console.log('Update asset tx hash:', txHash);
176
+ ```
177
+
178
+ ### createAssetFactory
179
+
180
+ Creates an asset factory, which acts as a template for minting multiple new assets with a consistent structure.
181
+
182
+ **Parameters**
183
+
184
+ <x-field-group>
185
+ <x-field data-name="factory" data-type="object" data-required="true" data-desc="An object containing the factory's configuration.">
186
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="Name of the factory."></x-field>
187
+ <x-field data-name="description" data-type="string" data-required="true" data-desc="Description of the factory."></x-field>
188
+ <x-field data-name="limit" data-type="number" data-required="false" data-default="0" data-desc="The maximum number of assets that can be minted (0 for unlimited)."></x-field>
189
+ <x-field data-name="trustedIssuers" data-type="string[]" data-required="false" data-desc="A list of wallet addresses allowed to mint from this factory."></x-field>
190
+ <x-field data-name="input" data-type="object" data-required="true" data-desc="Defines the inputs required for minting."></x-field>
191
+ <x-field data-name="output" data-type="object" data-required="true" data-desc="Defines the structure of the minted asset, often using templates."></x-field>
192
+ </x-field>
193
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet to own the factory."></x-field>
194
+ </x-field-group>
195
+
196
+ **Returns**
197
+
198
+ <x-field data-name="result" data-type="Promise<[string, string]>" data-desc="An array containing the transaction hash and the address of the newly created factory."></x-field>
199
+
200
+ **Example**
201
+
202
+ ```javascript Send a CreateFactoryTx icon=logos:javascript
203
+ const factoryConfig = {
204
+ name: 'Ticket Factory',
205
+ description: 'Mints event tickets',
206
+ limit: 1000,
207
+ input: { ... },
208
+ output: { ... },
209
+ };
210
+
211
+ const [txHash, factoryAddress] = await client.createAssetFactory({
212
+ factory: factoryConfig,
213
+ wallet: eventCreatorWallet,
214
+ });
215
+ console.log('Create factory tx hash:', txHash);
216
+ console.log('New factory address:', factoryAddress);
217
+ ```
218
+
219
+ ### acquireAsset
220
+
221
+ Acquires (mints) a new asset from an existing asset factory. This is typically initiated by the end-user who will own the asset.
222
+
223
+ **Parameters**
224
+
225
+ <x-field-group>
226
+ <x-field data-name="itx" data-type="AcquireAssetV2Tx" data-required="true" data-desc="The inner transaction object, often prepared using a helper like `preMintAsset`."></x-field>
227
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the user acquiring the asset."></x-field>
228
+ <x-field data-name="delegator" data-type="string" data-required="false" data-desc="The address of the delegator, if applicable."></x-field>
229
+ </x-field-group>
230
+
231
+ **Returns**
232
+
233
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
234
+
235
+ **Example**
236
+
237
+ ```javascript Send an AcquireAssetV2Tx icon=logos:javascript
238
+ // First, prepare the minting transaction (e.g., on the server)
239
+ const itx = await client.preMintAsset({
240
+ factory: factoryAddress,
241
+ owner: userWallet.address,
242
+ wallet: issuerWallet,
243
+ });
244
+
245
+ // Then, the user sends the transaction
246
+ const txHash = await client.acquireAsset({ itx, wallet: userWallet });
247
+ console.log('Acquire asset tx hash:', txHash);
248
+ ```
249
+
250
+ ### mintAsset
251
+
252
+ This is the issuer-side counterpart to `acquireAsset`. It allows a trusted issuer to mint an asset from a factory and assign it to a specified owner.
253
+
254
+ **Parameters**
255
+
256
+ <x-field-group>
257
+ <x-field data-name="itx" data-type="MintAssetTx" data-required="true" data-desc="The inner transaction object, often prepared using `preMintAsset`."></x-field>
258
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the trusted issuer."></x-field>
259
+ </x-field-group>
260
+
261
+ **Returns**
262
+
263
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
264
+
265
+ **Example**
266
+
267
+ ```javascript Send a MintAssetTx icon=logos:javascript
268
+ const itx = await client.preMintAsset({
269
+ factory: factoryAddress,
270
+ owner: userWallet.address,
271
+ wallet: issuerWallet,
272
+ });
273
+
274
+ const txHash = await client.mintAsset({ itx, wallet: issuerWallet });
275
+ console.log('Mint asset tx hash:', txHash);
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Token Management
281
+
282
+ ### createTokenFactory
283
+
284
+ Creates a new factory for minting and burning a specific fungible token, often based on a bonding curve pricing model.
285
+
286
+ **Parameters**
287
+
288
+ <x-field-group>
289
+ <x-field data-name="feeRate" data-type="number" data-required="false" data-default="0" data-desc="The fee rate for minting and burning operations."></x-field>
290
+ <x-field data-name="curve" data-type="object" data-required="true" data-desc="The bonding curve configuration for pricing."></x-field>
291
+ <x-field data-name="token" data-type="object" data-required="true">
292
+ <x-field-desc markdown>The configuration for the token to be created. This includes properties like `name`, `symbol`, `decimal`, and `maxTotalSupply`.</x-field-desc>
293
+ </x-field>
294
+ <x-field data-name="data" data-type="object" data-required="false" data-desc="Optional metadata for the token factory."></x-field>
295
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the factory's owner."></x-field>
296
+ </x-field-group>
297
+
298
+ **Returns**
299
+
300
+ <x-field data-name="result" data-type="Promise<[string, string]>" data-desc="An array containing the transaction hash and the address of the newly created token factory."></x-field>
301
+
302
+ **Example**
303
+
304
+ ```javascript Send a CreateTokenFactoryTx icon=logos:javascript
305
+ const [txHash, factoryAddress] = await client.createTokenFactory({
306
+ feeRate: 100, // 1%
307
+ curve: { fixedPrice: '1' }, // 1 native token per new token
308
+ token: {
309
+ name: 'My Community Token',
310
+ symbol: 'MCT',
311
+ decimal: 18,
312
+ maxTotalSupply: '1000000',
313
+ },
314
+ wallet: creatorWallet,
315
+ });
316
+ console.log('Create token factory tx hash:', txHash);
317
+ console.log('New token factory address:', factoryAddress);
318
+ ```
319
+
320
+ ### updateTokenFactory
321
+
322
+ Updates the `feeRate` and `data` for an existing token factory.
323
+
324
+ **Parameters**
325
+
326
+ <x-field-group>
327
+ <x-field data-name="address" data-type="string" data-required="true" data-desc="The address of the token factory to update."></x-field>
328
+ <x-field data-name="feeRate" data-type="number" data-required="false" data-desc="The new fee rate for minting and burning."></x-field>
329
+ <x-field data-name="data" data-type="object" data-required="false" data-desc="New metadata for the token factory."></x-field>
330
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the factory's owner."></x-field>
331
+ </x-field-group>
332
+
333
+ **Returns**
334
+
335
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
336
+
337
+ **Example**
338
+
339
+ ```javascript Send an UpdateTokenFactoryTx icon=logos:javascript
340
+ const txHash = await client.updateTokenFactory({
341
+ address: 'z2f...',
342
+ feeRate: 50, // 0.5%
343
+ wallet: ownerWallet,
344
+ });
345
+ console.log('Update token factory tx hash:', txHash);
346
+ ```
347
+
348
+ ### mintToken
349
+
350
+ Mints new tokens from a token factory in exchange for the reserve token (usually the native chain token). The cost is determined by the factory's bonding curve.
351
+
352
+ **Parameters**
353
+
354
+ <x-field-group>
355
+ <x-field data-name="tokenFactory" data-type="string" data-required="true" data-desc="The address of the token factory."></x-field>
356
+ <x-field data-name="amount" data-type="number" data-required="true" data-desc="The amount of new tokens to mint."></x-field>
357
+ <x-field data-name="receiver" data-type="string" data-required="true" data-desc="The address that will receive the newly minted tokens."></x-field>
358
+ <x-field data-name="maxReserve" data-type="number" data-required="true" data-desc="The maximum amount of reserve tokens the user is willing to pay. This acts as slippage protection."></x-field>
359
+ <x-field data-name="data" data-type="object" data-required="false" data-desc="Optional metadata for the transaction."></x-field>
360
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet initiating the mint."></x-field>
361
+ </x-field-group>
362
+
363
+ **Returns**
364
+
365
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
366
+
367
+ **Example**
368
+
369
+ ```javascript Send a MintTokenTx icon=logos:javascript
370
+ const txHash = await client.mintToken({
371
+ tokenFactory: 'z2f...',
372
+ amount: 100,
373
+ receiver: userWallet.address,
374
+ maxReserve: 105, // Willing to pay up to 105 native tokens
375
+ wallet: userWallet,
376
+ });
377
+ console.log('Mint token tx hash:', txHash);
378
+ ```
379
+
380
+ ### burnToken
381
+
382
+ Burns existing tokens at a factory to receive the underlying reserve token in return. The amount of reserve token received is determined by the factory's bonding curve.
383
+
384
+ **Parameters**
385
+
386
+ <x-field-group>
387
+ <x-field data-name="tokenFactory" data-type="string" data-required="true" data-desc="The address of the token factory."></x-field>
388
+ <x-field data-name="amount" data-type="number" data-required="true" data-desc="The amount of tokens to burn."></x-field>
389
+ <x-field data-name="receiver" data-type="string" data-required="true" data-desc="The address that will receive the reserve tokens."></x-field>
390
+ <x-field data-name="minReserve" data-type="number" data-required="true" data-desc="The minimum amount of reserve tokens the user expects to receive. This acts as slippage protection."></x-field>
391
+ <x-field data-name="data" data-type="object" data-required="false" data-desc="Optional metadata for the transaction."></x-field>
392
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet initiating the burn."></x-field>
393
+ </x-field-group>
394
+
395
+ **Returns**
396
+
397
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
398
+
399
+ **Example**
400
+
401
+ ```javascript Send a BurnTokenTx icon=logos:javascript
402
+ const txHash = await client.burnToken({
403
+ tokenFactory: 'z2f...',
404
+ amount: 50,
405
+ receiver: userWallet.address,
406
+ minReserve: 48, // Expecting to receive at least 48 native tokens
407
+ wallet: userWallet,
408
+ });
409
+ console.log('Burn token tx hash:', txHash);
410
+ ```
411
+
412
+ ---
413
+
414
+ ## Transfer & Exchange
415
+
416
+ ### transfer
417
+
418
+ Transfers native tokens, custom fungible tokens, and/or assets (NFTs) to another account in a single transaction.
419
+
420
+ **Parameters**
421
+
422
+ <x-field-group>
423
+ <x-field data-name="to" data-type="string" data-required="true" data-desc="The address of the recipient."></x-field>
424
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The sender's wallet."></x-field>
425
+ <x-field data-name="token" data-type="number" data-required="false" data-default="0" data-desc="The amount of the chain's native token to transfer."></x-field>
426
+ <x-field data-name="assets" data-type="string[]" data-required="false" data-desc="An array of asset addresses (NFTs) to transfer."></x-field>
427
+ <x-field data-name="tokens" data-type="object[]" data-required="false" data-desc="An array of custom fungible token objects to transfer.">
428
+ <x-field data-name="address" data-type="string" data-required="true" data-desc="The address of the custom token contract."></x-field>
429
+ <x-field data-name="value" data-type="number" data-required="true" data-desc="The amount of the custom token to transfer."></x-field>
430
+ </x-field>
431
+ <x-field data-name="memo" data-type="string" data-required="false" data-desc="An optional note for the transaction."></x-field>
432
+ <x-field data-name="delegator" data-type="string" data-required="false" data-desc="The delegator's address, if applicable."></x-field>
433
+ </x-field-group>
434
+
435
+ **Returns**
436
+
437
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
438
+
439
+ **Example**
440
+
441
+ ```javascript Send a TransferV2Tx icon=logos:javascript
442
+ const txHash = await client.transfer({
443
+ to: 'z1sb...',
444
+ token: 1.5, // 1.5 of the native chain token
445
+ assets: ['z3g...'], // An NFT
446
+ tokens: [{ address: 'z2t...', value: 100 }], // 100 of a custom token
447
+ memo: 'Payment for services',
448
+ wallet: senderWallet,
449
+ });
450
+ console.log('Transfer tx hash:', txHash);
451
+ ```
452
+
453
+ ### prepareExchange
454
+
455
+ Prepares the sender's half of an atomic swap (exchange) transaction. It signs the sender's offer and returns a transaction object that can be passed to the receiver.
456
+
457
+ **Parameters**
458
+
459
+ <x-field-group>
460
+ <x-field data-name="receiver" data-type="string" data-required="true" data-desc="The address of the other party in the exchange."></x-field>
461
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the user making the offer."></x-field>
462
+ <x-field data-name="offerToken" data-type="number" data-required="false" data-desc="Amount of native token offered."></x-field>
463
+ <x-field data-name="offerAssets" data-type="string[]" data-required="false" data-desc="Array of asset addresses offered."></x-field>
464
+ <x-field data-name="offerTokens" data-type="object[]" data-required="false" data-desc="Array of custom fungible tokens offered."></x-field>
465
+ <x-field data-name="demandToken" data-type="number" data-required="false" data-desc="Amount of native token demanded in return."></x-field>
466
+ <x-field data-name="demandAssets" data-type="string[]" data-required="false" data-desc="Array of asset addresses demanded in return."></x-field>
467
+ <x-field data-name="demandTokens" data-type="object[]" data-required="false" data-desc="Array of custom fungible tokens demanded."></x-field>
468
+ <x-field data-name="memo" data-type="string" data-required="false" data-desc="An optional note for the transaction."></x-field>
469
+ </x-field-group>
470
+
471
+ **Returns**
472
+
473
+ <x-field data-name="transactionObject" data-type="Promise<object>" data-desc="The partially signed transaction object."></x-field>
474
+
475
+ ### finalizeExchange
476
+
477
+ Finalizes the receiver's half of an atomic swap. It takes the partially signed transaction from `prepareExchange`, adds the receiver's signature, and returns the fully signed transaction object.
478
+
479
+ **Parameters**
480
+
481
+ <x-field-group>
482
+ <x-field data-name="tx" data-type="object" data-required="true" data-desc="The transaction object returned from `prepareExchange`."></x-field>
483
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the user accepting the offer."></x-field>
484
+ <x-field data-name="data" data-type="object" data-required="false" data-desc="Extra data in the multi-signature."></x-field>
485
+ </x-field-group>
486
+
487
+ **Returns**
488
+
489
+ <x-field data-name="transactionObject" data-type="Promise<object>" data-desc="The fully signed, multi-signature transaction object."></x-field>
490
+
491
+ ### exchange
492
+
493
+ Sends the fully signed exchange transaction to the blockchain. This can be called by either party after `finalizeExchange` is complete.
494
+
495
+ **Parameters**
496
+
497
+ <x-field-group>
498
+ <x-field data-name="tx" data-type="object" data-required="true" data-desc="The transaction object returned from `finalizeExchange`."></x-field>
499
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the user submitting the transaction."></x-field>
500
+ </x-field-group>
501
+
502
+ **Returns**
503
+
504
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
505
+
506
+ **Example (Full Exchange Flow)**
507
+
508
+ ```javascript Perform an atomic swap icon=logos:javascript
509
+ // 1. Offerer prepares the transaction
510
+ const offerTx = await client.prepareExchange({
511
+ receiver: receiverWallet.address,
512
+ offerAssets: ['z3g...'], // Offer an NFT
513
+ demandToken: 10, // Demand 10 native tokens
514
+ wallet: offererWallet,
515
+ });
516
+
517
+ // 2. Receiver finalizes the transaction
518
+ const finalTx = await client.finalizeExchange({
519
+ tx: offerTx,
520
+ wallet: receiverWallet,
521
+ });
522
+
523
+ // 3. Either party can send the finalized transaction
524
+ const txHash = await client.exchange({ tx: finalTx, wallet: offererWallet });
525
+ console.log('Exchange tx hash:', txHash);
526
+ ```
527
+
528
+ ---
529
+
530
+ ## Staking
531
+
532
+ ### stake
533
+
534
+ Stakes tokens and/or assets to a receiver address. Staking locks up resources, often in exchange for rewards or to provide security.
535
+
536
+ **Parameters**
537
+
538
+ <x-field-group>
539
+ <x-field data-name="to" data-type="string" data-required="true" data-desc="The address of the stake receiver."></x-field>
540
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the staker."></x-field>
541
+ <x-field data-name="assets" data-type="string[]" data-required="false" data-desc="An array of asset addresses to stake."></x-field>
542
+ <x-field data-name="tokens" data-type="object[]" data-required="false" data-desc="An array of fungible token objects to stake."></x-field>
543
+ <x-field data-name="locked" data-type="boolean" data-required="false" data-default="false" data-desc="Whether the stake is locked upon creation."></x-field>
544
+ <x-field data-name="slashers" data-type="string[]" data-required="false" data-desc="A list of addresses that are permitted to slash this stake."></x-field>
545
+ <x-field data-name="message" data-type="string" data-required="false" data-desc="An optional note for the stake."></x-field>
546
+ </x-field-group>
547
+
548
+ **Returns**
549
+
550
+ <x-field data-name="result" data-type="Promise<[string, string]>" data-desc="An array containing the transaction hash and the address of the newly created stake."></x-field>
551
+
552
+ **Example**
553
+
554
+ ```javascript Send a StakeTx icon=logos:javascript
555
+ const [txHash, stakeAddress] = await client.stake({
556
+ to: 'z1v...',
557
+ tokens: [{ address: 'z2t...', value: 5000 }],
558
+ message: 'Staking for validator rewards',
559
+ wallet: userWallet,
560
+ });
561
+ console.log('Stake tx hash:', txHash);
562
+ console.log('New stake address:', stakeAddress);
563
+ ```
564
+
565
+ ### revokeStake
566
+
567
+ Revokes previously staked tokens and/or assets, initiating the process to return them to the owner. Note that there may be an unbonding period before the assets can be claimed.
568
+
569
+ **Parameters**
570
+
571
+ <x-field-group>
572
+ <x-field data-name="from" data-type="string" data-required="true" data-desc="The address of the stake to revoke from."></x-field>
573
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the stake owner."></x-field>
574
+ <x-field data-name="assets" data-type="string[]" data-required="false" data-desc="An array of asset addresses to revoke."></x-field>
575
+ <x-field data-name="tokens" data-type="object[]" data-required="false" data-desc="An array of fungible token objects to revoke."></x-field>
576
+ </x-field-group>
577
+
578
+ **Returns**
579
+
580
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
581
+
582
+ **Example**
583
+
584
+ ```javascript Send a RevokeStakeTx icon=logos:javascript
585
+ const txHash = await client.revokeStake({
586
+ from: 'z6s...',
587
+ tokens: [{ address: 'z2t...', value: 1000 }],
588
+ wallet: userWallet,
589
+ });
590
+ console.log('Revoke stake tx hash:', txHash);
591
+ ```
592
+
593
+ ### claimStake
594
+
595
+ Claims items from a stake that have been successfully revoked and have passed their unbonding period.
596
+
597
+ **Parameters**
598
+
599
+ <x-field-group>
600
+ <x-field data-name="from" data-type="string" data-required="true" data-desc="The address of the stake to claim from."></x-field>
601
+ <x-field data-name="evidence" data-type="string" data-required="true" data-desc="The transaction hash of the `revokeStake` transaction."></x-field>
602
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the stake owner."></x-field>
603
+ </x-field-group>
604
+
605
+ **Returns**
606
+
607
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
608
+
609
+ **Example**
610
+
611
+ ```javascript Send a ClaimStakeTx icon=logos:javascript
612
+ const revokeTxHash = '0x123...abc';
613
+ const txHash = await client.claimStake({
614
+ from: 'z6s...',
615
+ evidence: revokeTxHash,
616
+ wallet: userWallet,
617
+ });
618
+ console.log('Claim stake tx hash:', txHash);
619
+ ```
620
+
621
+ ### slashStake
622
+
623
+ Allows a designated slasher to penalize a stake, typically for misbehavior. The slashed assets are transferred to a designated vault address.
624
+
625
+ **Parameters**
626
+
627
+ <x-field-group>
628
+ <x-field data-name="from" data-type="string" data-required="true" data-desc="The address of the stake to slash."></x-field>
629
+ <x-field data-name="reason" data-type="string" data-required="true" data-desc="A message explaining the reason for slashing."></x-field>
630
+ <x-field data-name="wallet" data-type="WalletObject" data-required="true" data-desc="The wallet of the designated slasher."></x-field>
631
+ <x-field data-name="assets" data-type="string[]" data-required="false" data-desc="An array of asset addresses to slash."></x-field>
632
+ <x-field data-name="tokens" data-type="object[]" data-required="false" data-desc="An array of fungible token objects to slash."></x-field>
633
+ </x-field-group>
634
+
635
+ **Returns**
636
+
637
+ <x-field data-name="transactionHash" data-type="Promise<string>" data-desc="The hash of the submitted transaction."></x-field>
638
+
639
+ **Example**
640
+
641
+ ```javascript Send a SlashStakeTx icon=logos:javascript
642
+ const txHash = await client.slashStake({
643
+ from: 'z6s...',
644
+ reason: 'Validator downtime',
645
+ tokens: [{ address: 'z2t...', value: 500 }],
646
+ wallet: slasherWallet,
647
+ });
648
+ console.log('Slash stake tx hash:', txHash);
649
+ ```