API ReferenceReact provider and hooksFunction
useRedeemLOCAuthorizationWorkflow()
function useRedeemLOCAuthorizationWorkflow(): UseRedeemLOCAuthorizationWorkflowResult;Validates and prepares the beneficiary’s signed redemption authorization — the EIP-712 payload a holder submits to redeem against the LOC.
The prepared workflow signs; it broadcasts no transaction. Its typed data is readable before the wallet prompt, for consent UI and audit logging.
Returns
UseRedeemLOCAuthorizationWorkflowResult
The canonical preparation envelope. validate reports a verdict without building anything;
prepareWorkflow validates and then builds, resolving to prepared, invalid, failed, or
cancelled; workflow, issues, error, and isPreparing mirror the latest request; and reset
discards it. No wallet is prompted until workflow.execute().
Throws
Error when rendered outside <AnvilProvider>, by way of useAnvilSDK. Nothing else
throws: a rejected validation or build is reported as a failed result, not as an exception.
Example
export function AuthorizeRedeemButton({ loc,}: { loc: OutstandingLetterOfCredit;}) { const authorization = useRedeemLOCAuthorizationWorkflow();
async function authorizeHalf() { const result = await authorization.prepareWorkflow({ id: loc.reference.id, redeemAmount: loc.remainingCredited.amount / 2n, locCreditedAmount: loc.remainingCredited.amount, }); if (result.status !== 'prepared') return;
// Available before the wallet prompt for consent UI and audit logging. console.log(result.workflow.operations[0]?.authorization?.typedData); const execution = await result.workflow.execute(); if (execution.status !== 'executed') return; const [operation] = execution.operations; if (operation?.status === WalletOperationStatus.Signed) { console.log(operation.signature); } }
return ( <button onClick={authorizeHalf} disabled={authorization.isPreparing}> Authorize half redemption </button> );}