> For the complete documentation index, see [llms.txt](/llms.txt)

# Managing Owned Kiosk

Manage kiosk items by placing, listing, delisting, and withdrawing using the Kiosk SDK.



The kiosk extension (`client.kiosk`) helps in managing a kiosk.

You need to follow the steps explained in the [Kiosk Transaction section](./kiosk-transaction) to
create a `KioskTransaction`.

## Available functions

### `take`

Removes an item from the Kiosk and returns a `TransactionArgument` to use it in a different
Programmable Transaction Block (PTB) call.

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

// Take item from kiosk.
const item = kioskTx.take({
	itemId,
	itemType,
});

// Do something with `item`, like transfer it to someone else.
tx.transferObjects([item], 'address_to_transfer_the_object');

// Finalize the kiosk Tx.
kioskTx.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `transfer`

Similar to `take`, but transfers the item to an address internally.

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

// Take item from kiosk.
kioskTx
	.transfer({
		itemId,
		itemType,
		address: 'address_to_transfer_the_object',
	})
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `place`

Places an item in the kiosk.

```typescript
const item = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx
	.place({
		item,
		itemType,
	})
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `list`

Lists an item for sale (the item must be in the kiosk).

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx
	.list({
		itemId,
		itemType,
		price: 100000n,
	})
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `placeAndList`

List an item for sale by first placing it in the kiosk (places the item and lists it for sale). It's
a short hand for `place()` and `list()`.

```typescript
const item = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx
	.placeAndList({
		item,
		itemType,
		price: 100000n,
	})
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `delist`

Removes the listing, keeping the item placed in the kiosk.

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx
	.delist({
		itemId,
		itemType,
	})
	.finalize();

// sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `withdraw`

Withdraw (all or specific amount) from a kiosk.

`amount`: Can be empty, which will withdraw all the funds.

```typescript
const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx.withdraw('address_to_transfer_funds', 100000n).finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `borrowTx` (callback)

Borrows an item from a kiosk. This function follows the `callback` approach, similar to the
ownerCap. The return of the item happens automatically after the execution of the callback.

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

kioskTx
	.borrowTx(
		{
			itemId,
			itemType,
		},
		(item) => {
			tx.moveCall({
				target: '0xMyGame::hero::level_up',
				arguments: [item],
			});
		},
	)
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```

### `borrow` / `return`

Similar to `borrowTx`, borrows an item from the kiosk, but returns two transaction arguments: `item`
and `promise`. You can use the `item` in your PTBs, but you must always call the `return()` function
with the `item` and the `Promise`.

```typescript
const itemId = '0xHeroAddress';
const itemType = '0x..::hero::Hero';

const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });

const [item, promise] = kioskTx.borrow({
	itemId,
	itemType,
});

tx.moveCall({
	target: '0xMyGame::hero::level_up',
	arguments: [item],
});

kioskTx
	.return({
		itemType,
		item,
		promise,
	})
	.finalize();

// Sign and execute transaction.
await signAndExecuteTransaction({ tx: tx });
```
