For the complete documentation index, see llms.txt. This page is also available as Markdown.

purchase

purchase

purchase(params) → Receipt

Initiates a purchase for the specified product.

This method may trigger multiple write transactions (e.g., token approval and minting).

Parameters

Parameter
Type
Required
Description

account

✅

Buyer’s account

preparedPurchase

✅

Prepared transaction object returned from preparePurchase call

confirmations

number

❌

Number of confirmation blocks (Default 1)

Returns: Receipt

The receipt contains the confirmed transaction metadata under transactionReceipt and an order object with parsed token details for the mint that was executed.

Example

const receipt = await product.purchase({
  account,
  preparedPurchase,
});

console.log('Mint transaction:', receipt.transactionReceipt.txHash);

if (receipt.order) {
  console.log('Recipient:', receipt.order.recipientAddress);
  for (const item of receipt.order.items) {
    console.log(`Minted token ${item.token.tokenId} x${item.quantity}`);
  }
}

Errors

Code
Message
data
metadata

TRANSACTION_FAILED

transaction failed

{ receipts : Receipt[]} (For completed steps)

TRANSACTION_REVERTED

transaction reverted

{ receipts : Receipt[]} (For completed steps)

TRANSACTION_REJECTED

user rejected transaction

{ receipts : Receipt[]} (For completed steps)

INSUFFIENT_FUNDS

wallet does not have sufficient funds for purchase

{ receipts : Receipt[]} (For completed steps)

LEDGER_ERROR

error with ledger wallet, make sure blind signing is on

{ receipts : Receipt[]} (For completed steps)

Last updated