llms.txt
@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

Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction

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

The Kiosk SDK accepts SuiGrpcClient, SuiGraphQLClient, and other clients that implement ClientWithCoreApi. Use SuiGrpcClient for new Kiosk code. The gRPC object API returns Display v2 metadata; use GraphQL or JSON-RPC for object types that still rely on legacy Display metadata.

- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
- import { KioskClient, Network } from '@mysten/kiosk';
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
+ import { kiosk } from '@mysten/kiosk';

- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
- const kioskClient = new KioskClient({
-   client: suiClient,
-   network: Network.MAINNET,
- });
+ const client = new SuiGrpcClient({
+   baseUrl: 'https://fullnode.mainnet.sui.io:443',
+   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 { SuiGrpcClient } from '@mysten/sui/grpc';

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

+ const client = new SuiGrpcClient({
+   baseUrl: 'https://fullnode.mainnet.sui.io:443',
+   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