Skip to content

@gala-chain/chaincodeAPI


API > verifyAndUseAllowances

Function: verifyAndUseAllowances()

verifyAndUseAllowances(ctx, grantedBy, tokenInstanceKey, quantity, tokenInstance, authorizedOnBehalf, actionType, useAllowancesArr): Promise\<boolean>

Parameters

ctx: GalaChainContext

grantedBy: string

tokenInstanceKey: TokenInstanceKey

quantity: BigNumber

tokenInstance: TokenInstance

authorizedOnBehalf: string

actionType: AllowanceType

useAllowancesArr: string[]

Returns

Promise

Description

Query allowances from World State using either composite keys or a partial compomsite key query constructed from the provided paraemters, ensuring that the provided grantedBy and authorizedOnBehalf paraemters match the TokenAllowance grantedBy and grantedTo properties.

Apply the remaining quantity of each applicable allowance to the total quantity.

Return true after accounting for the full spend. Write a TokenClaim entry for each allowance used.

Throws an exception if the full quantity cannot be met by the provided allowances.

Source

chaincode/src/allowances/verifyAndUseAllowances.ts:50