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 Function | Use Instead |
|---|---|
createKiosk | kioskTx.create() |
shareKiosk | kioskTx.share() |
place | kioskTx.place() |
lock | kioskTx.lock() |
take | kioskTx.take() |
list | kioskTx.list() |
delist | kioskTx.delist() |
placeAndList | kioskTx.placeAndList() |
purchase | kioskTx.purchase() |
withdrawFromKiosk | kioskTx.withdraw() |
borrowValue | kioskTx.borrow() |
returnValue | kioskTx.return() |
Transfer policy functions
| Removed Function | Use Instead |
|---|---|
createTransferPolicyWithoutSharing | tpTx.create() |
shareTransferPolicy | tpTx.shareAndTransferCap() |
confirmRequest | Handled automatically by kioskTx.purchaseAndResolve() |
removeTransferPolicyRule | tpTx.removeRule() |
Personal Kiosk functions
| Removed Function | Use Instead |
|---|---|
convertToPersonalTx | kioskTx.convertToPersonal() |
transferPersonalCapTx | Handled automatically by kioskTx.finalize() |
Rule attachment functions
| Removed Function | Use Instead |
|---|---|
attachKioskLockRuleTx | tpTx.addLockRule() |
attachRoyaltyRuleTx | tpTx.addRoyaltyRule() |
attachPersonalKioskRuleTx | tpTx.addPersonalKioskRule() |
attachFloorPriceRuleTx | tpTx.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();