> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://ensforge.com/api/mcp` to find what you need.

# useWaitForHcaExecution

Wait for execution with bounded polling. Uses the SDK from `EnsforgeProvider`.

## Import

```tsx
import { useWaitForHcaExecution } from "@ensforge/react";
```

## Usage

:::code-group
```tsx [component.tsx]
import { useWaitForHcaExecution } from "@ensforge/react";
import type { HcaExecutionSubmission } from "@ensforge/core/hca";

function Component({ submission }: { submission: HcaExecutionSubmission }) {
  const mutation = useWaitForHcaExecution();

  return (
    <button
      disabled={mutation.isWaiting}
      onClick={() =>
        mutation.mutate({
          submission,
        })
      }
    >
      Submit
    </button>
  );
}
```

```tsx [provider.tsx]
// [!include ~/snippets/hca/provider.tsx]
```
:::

## Parameters

```ts
import type { EnsMutationOptions } from "@ensforge/react";
```

The hook accepts an optional `EnsMutationOptions` object.

### retry

`false | Schedule<unknown, Failure> | undefined`

An Effect schedule used to retry typed failures. It defaults to `false`. Only retry writes that are
known to be safe and idempotent.

### onExit

`(exit: Exit<Success, Failure>, parameters: Parameters) => void`

Receives the complete Effect `Exit` and the exact mutation parameters after execution. Use
`Exit.match` or `Exit.isSuccess` to handle both outcomes without losing typed failures.

See [Mutation Options](/react/api/mutation-options) for schedules, provider defaults, and per-call
`onExit` handlers.

## Mutation Parameters

```ts
import type { WaitForHcaExecutionParameters } from "@ensforge/sdk/hca";
```

### submission

`HcaExecutionSubmission<unknown>`

Previously returned or explicitly recovered execution submission.

### confirmations

`number | undefined`

Required receipt confirmations.

### timeout

`number | undefined`

Maximum time to wait, in milliseconds.

### pollingInterval

`number | undefined`

Initial status polling interval, in milliseconds.

### maxPollingInterval

`number | undefined`

Upper bound for the status polling interval, in milliseconds.

### execution

`ExecutionAdapter<unknown, unknown, unknown> | undefined`

Compatible execution adapter. Omit for direct owner execution when supported.

## Return Type

```ts
type Result = ReturnType<typeof useWaitForHcaExecution>;
```

Returns an [`EnsMutationResult`](/react/api/mutation-result).

| Property       | Description                                                    |
| -------------- | -------------------------------------------------------------- |
| `mutate`       | Starts the mutation and optionally reports its `Exit`.         |
| `mutateAsync`  | Starts the mutation and returns a Promise.                     |
| `mutateEffect` | Starts the mutation and returns an Effect with typed failures. |
| `data`         | Latest successful value, or `undefined`.                       |
| `error`        | Latest typed failure, an unexpected `Error`, or `null`.        |
| `cause`        | Complete Effect cause for the latest failure.                  |
| `isInitial`    | The mutation has not executed since creation or reset.         |
| `isWaiting`    | The mutation Effect is currently running.                      |
| `isSuccess`    | The latest execution succeeded.                                |
| `isFailure`    | The latest execution failed.                                   |
| `parameters`   | Parameters used by the latest execution.                       |
| `interrupt`    | Interrupts the active Effect.                                  |
| `reset`        | Restores the mutation to its initial state.                    |
| `result`       | Underlying Effect `AsyncResult`.                               |

## Effect Atom

```ts
import { createWaitForHcaExecutionMutationAtom } from "@ensforge/react/atoms";
import { sdk } from "./client";

const atom = createWaitForHcaExecutionMutationAtom(sdk);
```

## Action

* [`waitForHcaExecution`](/core/api/actions/hca/wait-for-hca-execution)
* [`sdk.hca.waitForHcaExecution`](/sdk/api/hca/wait-for-hca-execution)
