settleOrder
このコンテンツはまだ日本語訳がありません。
settleOrder(
kernelClient,params):Promise<SettleOrderResult>
Defined in: src/settlement/settle-order.ts:193
Pay an order through Settlement from the Kernel smart account, as one sponsored UserOp.
Three things are deliberately NOT parameters:
- the payer — the contract hashes
msg.sender, so it iskernelClient.account.address; - the
Settlementaddress and the token — they come from this package’s deployment tables forkernelClient.chain. An order’s issuer may tell you which contract to pay; this function never listens.
It does not check the merchant against an allowlist or the amount against a cap: that is the
session key’s on-chain policy (createBuyListPolicies) and the chain’s job.
Retrying. An order can be paid once. A retry of an already-paid order is refused by the
contract (AlreadySettled), and that refusal most likely surfaces as a THROWN bundler error
during gas estimation rather than as success: false. So on any failure after submission, do
not guess: read settled(ref) on the contract. ref is returned — and is computable with
hashOrderRef — before anything is sent.
Parameters
kernelClient
params
Returns
Promise<SettleOrderResult>
Throws
If an argument is structurally invalid or the order has expired.
Throws
If expectedRef is given and differs. Nothing was sent.
Throws
If Settlement is not deployed on the client’s chain.
Example
import { settleOrder } from "kawasekit";
const { ref, transactionHash } = await settleOrder(kernelClient, { merchant: order.merchant, amount: order.amount, validUntil: order.validUntil, details: order.details, expectedRef: order.ref, // what the issuer quoted — checked before anything is sent});