@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
MigrationsMigrate to 2.0

@mysten/kiosk

This package now exports a client extension that integrates with Sui clients.

Note: The Kiosk SDK requires SuiJsonRpcClient or SuiGraphQLClient. It does not work with SuiGrpcClient because it uses event queries that are not available in gRPC.

- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
- import { KioskClient, Network } from '@mysten/kiosk';
+ import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc'; // or SuiGraphQLClient
+ import { kiosk } from '@mysten/kiosk';

- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
- const kioskClient = new KioskClient({
-   client: suiClient,
-   network: Network.MAINNET,
- });
+ const client = new SuiJsonRpcClient({
+   url: getJsonRpcFullnodeUrl('mainnet'),
+   network: 'mainnet',
+ }).$extend(kiosk());

- const ownedKiosks = await kioskClient.getOwnedKiosks({ address: myAddress });
+ const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: myAddress });

Removed: transactionBlock Parameter

The deprecated transactionBlock parameter has been removed from KioskTransaction, TransferPolicyTransaction, and rule resolving functions. Use transaction instead:

const kioskTx = new KioskTransaction({
-  transactionBlock: tx,
+  transaction: tx,
   kioskClient,
   cap,
});

const tpTx = new TransferPolicyTransaction({
-  transactionBlock: tx,
+  transaction: tx,
   kioskClient,
   cap,
});

Removed: Low-Level Helper Functions

The low-level helper functions have been removed in favor of the KioskTransaction and TransferPolicyTransaction builder classes.

Kiosk Functions

Removed FunctionUse Instead
createKioskkioskTx.create()
shareKioskkioskTx.share()
placekioskTx.place()
lockkioskTx.lock()
takekioskTx.take()
listkioskTx.list()
delistkioskTx.delist()
placeAndListkioskTx.placeAndList()
purchasekioskTx.purchase()
withdrawFromKioskkioskTx.withdraw()
borrowValuekioskTx.borrow()
returnValuekioskTx.return()

Transfer Policy Functions

Removed FunctionUse Instead
createTransferPolicyWithoutSharingtpTx.create()
shareTransferPolicytpTx.shareAndTransferCap()
confirmRequestHandled automatically by kioskTx.purchaseAndResolve()
removeTransferPolicyRuletpTx.removeRule()

Personal Kiosk Functions

Removed FunctionUse Instead
convertToPersonalTxkioskTx.convertToPersonal()
transferPersonalCapTxHandled automatically by kioskTx.finalize()

Rule Attachment Functions

Removed FunctionUse Instead
attachKioskLockRuleTxtpTx.addLockRule()
attachRoyaltyRuleTxtpTx.addRoyaltyRule()
attachPersonalKioskRuleTxtpTx.addPersonalKioskRule()
attachFloorPriceRuleTxtpTx.addFloorPriceRule()

Migration Example

- import { createKiosk, shareKiosk, placeAndList } from '@mysten/kiosk';
+ import { kiosk, KioskTransaction } from '@mysten/kiosk';
+ import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';

- const [kiosk, cap] = createKiosk(tx);
- shareKiosk(tx, kiosk);
- placeAndList(tx, itemType, kiosk, cap, item, price);

+ const client = new SuiJsonRpcClient({
+   url: getJsonRpcFullnodeUrl('mainnet'),
+   network: 'mainnet',
+ }).$extend(kiosk());
+
+ const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk });
+ kioskTx
+   .create()
+   .placeAndList({ itemType, item, price })
+   .shareAndTransferCap(address)
+   .finalize();

On this page