API ReferenceReact provider and hooksFunction
useExecuteWorkflow()
function useExecuteWorkflow(workflow): UseExecuteWorkflowReturn;Executes a prepared wallet workflow while keeping execute-time preflight and wallet progress
separate. Compose it with a preparation hook: that hook owns isPreparing, while this hook exposes
isPreflighting, domain issues, typed infrastructure failure, cancellation, and the existing
operation lifecycle without introducing a second result vocabulary.
Parameters
| Parameter | Type | Description |
|---|---|---|
workflow | WalletOperationWorkflow | Prepared workflow that executeWorkflow will run and manage. Build it with one of the operation hooks’ prepareWorkflow. |
Returns
The execution envelope: executeWorkflow to start a run, the advancing operations snapshot,
isPreflighting and isExecuting for the two phases, and the exclusive executionResult alongside
the issues, error, and wasCancelled it decomposes into.
Example
export function ExecutePreparedWorkflow({ workflow,}: { workflow: WalletOperationWorkflow;}) { const execution = useExecuteWorkflow(workflow);
async function execute() { const result = await execution.executeWorkflow(); if (result.status === 'invalid') { console.log('Protocol state changed:', result.issues); } else if (result.status === 'failed') { console.error('Validation could not complete:', result.error); } }
return ( <> <button onClick={execute} disabled={execution.isPreflighting || execution.isExecuting}> {execution.isPreflighting ? 'Checking current state…' : execution.isExecuting ? 'Waiting for wallet…' : 'Execute'} </button> {execution.wasCancelled && <p>Execution cancelled.</p>} </> );}Throws
Error when rendered outside <AnvilProvider>, by way of useAnvilSDK.
executeWorkflow itself does not reject: every outcome, including failure, comes back as a
WorkflowExecutionResult.