Skip to main content

Class: KioskTransaction

A helper for building transactions that involve kiosk.

Constructors

Constructor

new KioskTransaction(__namedParameters): KioskTransaction;

Parameters

ParameterType
__namedParametersKioskTransactionParams

Returns

KioskTransaction

Properties

PropertyType
transactionTransaction
kioskClientKioskClient
kiosk?TransactionObjectArgument
kioskCap?TransactionObjectArgument

Methods

create()

create(): KioskTransaction;

Creates a kiosk and saves kiosk and kioskOwnerCap in state. Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.

Returns

KioskTransaction


createPersonal()

createPersonal(borrow?): KioskTransaction;

Creates a personal kiosk & shares it. The PersonalKioskCap is transferred to the signer.

Parameters

ParameterTypeDescription
borrow?booleanIf true, the kioskOwnerCap is borrowed from the PersonalKioskCap to be used in next transactions.

Returns

KioskTransaction


convertToPersonal()

convertToPersonal(borrow?): KioskTransaction;

Converts a kiosk to a Personal (Soulbound) Kiosk. Requires initialization by either calling ktxb.create() or ktxb.setCap().

Parameters

ParameterType
borrow?boolean

Returns

KioskTransaction


createAndShare()

createAndShare(address): void;

Single function way to create a kiosk, share it and transfer the cap to the specified address.

Parameters

ParameterType
addressstring

Returns

void


share()

share(): void;

Shares the kiosk.

Returns

void


shareAndTransferCap()

shareAndTransferCap(address): void;

Should be called only after create is called. It shares the kiosk & transfers the cap to the specified address.

Parameters

ParameterType
addressstring

Returns

void


borrowTx()

borrowTx(__namedParameters, callback): void;

A function to borrow an item from a kiosk & execute any function with it.

Parameters

ParameterType
__namedParametersItemId
callback(item) => void

Returns

void


borrow()

borrow(__namedParameters): [TransactionArgument, TransactionArgument];

Borrows an item from the kiosk. This will fail if the item is listed for sale.

Requires calling return.

Parameters

ParameterType
__namedParametersItemId

Returns

[TransactionArgument, TransactionArgument]


return()

return(__namedParameters): KioskTransaction;

Returns the item back to the kiosk. Accepts the parameters returned from the borrow function.

Parameters

ParameterType
__namedParametersItemValue & object

Returns

KioskTransaction


withdraw()

withdraw(address, amount?): KioskTransaction;

A function to withdraw from kiosk

Parameters

ParameterTypeDescription
addressstringWhere to transfer the coin.
amount?string | number | bigintThe amount we aim to withdraw.

Returns

KioskTransaction


place()

place(itemType): KioskTransaction;

A function to place an item in the kiosk.

Parameters

ParameterTypeDescription
itemTypeItemReferenceThe type T of the item

Returns

KioskTransaction


placeAndList()

placeAndList(itemType): KioskTransaction;

A function to place an item in the kiosk and list it for sale in one transaction.

Parameters

ParameterTypeDescription
itemTypeItemReference & PriceThe type T of the item

Returns

KioskTransaction


list()

list(itemType): KioskTransaction;

A function to list an item in the kiosk.

Parameters

ParameterTypeDescription
itemTypeItemId & objectThe type T of the item

Returns

KioskTransaction


delist()

delist(itemType): KioskTransaction;

A function to delist an item from the kiosk.

Parameters

ParameterTypeDescription
itemTypeItemIdThe type T of the item

Returns

KioskTransaction


take()

take(itemType): TransactionObjectArgument;

A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.

Parameters

ParameterTypeDescription
itemTypeItemIdThe type T of the item

Returns

TransactionObjectArgument


transfer()

transfer(itemType): KioskTransaction;

Transfer a non-locked/non-listed item to an address.

Parameters

ParameterTypeDescription
itemTypeItemId & objectThe type T of the item

Returns

KioskTransaction


lock()

lock(itemType): KioskTransaction;

A function to take lock an item in the kiosk.

Parameters

ParameterTypeDescription
itemTypeItemReference & objectThe type T of the item

Returns

KioskTransaction


purchase()

purchase(itemType): [TransactionObjectArgument, TransactionObjectArgument];

Purchase an item from a seller's kiosk. Returns [item, transferRequest] Can be called like: const [item, transferRequest] = kioskTx.purchase({...})

Parameters

ParameterTypeDescription
itemTypeItemId & Price & objectThe type T of the item

Returns

[TransactionObjectArgument, TransactionObjectArgument]


purchaseAndResolve()

purchaseAndResolve(itemType): Promise<KioskTransaction>;

A function to purchase and resolve a transfer policy. If the transfer policy has the lock rule, the item is locked in the kiosk. Otherwise, the item is placed in the kiosk.

Parameters

ParameterTypeDescription
itemTypeItemId & Price & object & PurchaseOptionsThe type of the item

Returns

Promise<KioskTransaction>


setCap()

setCap(cap): KioskTransaction | undefined;

A function to setup the client using an existing ownerCap, as return from the kioskClient.getOwnedKiosks function.

Parameters

ParameterTypeDescription
capKioskOwnerCapKioskOwnerCap object as returned from getOwnedKiosks SDK call.

Returns

KioskTransaction | undefined


finalize()

finalize(): void;

A function that ends up the kiosk building tx & returns the kioskOwnerCap back to the PersonalKioskCap, in case we are operating on a personal kiosk. It will also share the kiosk if it's not shared, and finalize the transfer of the personal cap if it's pending.

Returns

void


setKioskCap()

setKioskCap(cap): KioskTransaction;

Parameters

ParameterType
capTransactionObjectArgument

Returns

KioskTransaction


setKiosk()

setKiosk(kiosk): KioskTransaction;

Parameters

ParameterType
kioskTransactionObjectArgument

Returns

KioskTransaction


getKiosk()

getKiosk(): TransactionObjectArgument;

Returns

TransactionObjectArgument


getKioskCap()

getKioskCap(): TransactionObjectArgument;

Returns

TransactionObjectArgument