> **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.

# enableHcaSessionWithRefund

Enable a session with an explicitly bounded refund.

## Import

```ts
import { Ensforge } from "@ensforge/sdk";
```

## Usage

:::code-group
```ts [index.ts]
import { sdk } from "./client";
import { session } from "./session";

const result = await sdk.hca.enableHcaSessionWithRefund({
  ...session.parameters,
  refund: {
    token: "0x4567890123456789012345678901234567890123",
    maxExchangeRate: 1_000_000n,
    maxGasOverhead: 100_000n,
    maxAmount: 1_000_000n,
  },
});
```

```ts [client.ts]
// [!include ~/snippets/hca/client.ts]
```

```ts [session.ts]
import { execution } from "./execution";
import { sdk } from "./client";

export const session = await execution.extensions.sessions.prepare(sdk.config, {
  hca: "0x1234567890123456789012345678901234567890",
  resolver: "0x3456789012345678901234567890123456789012",
  validUntil: Math.floor(Date.now() / 1000) + 3600,
});
```
:::

## Parameters

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

### refund

`HcaSessionRefund`

Explicit bound for session execution refunds.

### hca

`` `0x${string}` ``

HCA address to inspect or operate on.

### permissionId

`` `0x${string}` ``

Permission identifier of the prepared or enabled session.

### sessionKey

`` `0x${string}` ``

Address of the session signer. The private key is not passed to the action.

### validUntil

`number`

Session expiry as a Unix timestamp in seconds.

### resolver

`` `0x${string}` ``

Resolver address used by the registration or session policy.

### salt

`bigint | undefined`

Account derivation salt. Defaults to the deployment profile canonical salt.

### walletClient

`WalletClient | undefined`

Viem wallet override. Defaults to the configured wallet resolver.

### account

`` `0x${string}` | Account | undefined ``

Wallet account override for the operation.

## Return Type

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

## Effect

Use `.effect` when composing the method in an Effect program. The success and error channels remain
fully typed.

```ts
import { Effect } from "effect";

const program = sdk.hca.enableHcaSessionWithRefund.effect({
  ...session.parameters,
  refund: {
    token: "0x4567890123456789012345678901234567890123",
    maxExchangeRate: 1_000_000n,
    maxGasOverhead: 100_000n,
    maxAmount: 1_000_000n,
  },
});

type Success = Effect.Success<typeof program>;
type Failure = Effect.Error<typeof program>;

const result = await Effect.runPromise(program);
```

## Call

```ts
const intent = sdk.hca.enableHcaSessionWithRefund.call({
  ...session.parameters,
  refund: {
    token: "0x4567890123456789012345678901234567890123",
    maxExchangeRate: 1_000_000n,
    maxGasOverhead: 100_000n,
    maxAmount: 1_000_000n,
  },
});
```

Preparing an intent does not submit a transaction.

## Error

The method rejects with the corresponding Core action errors. Use `.effect` to keep those failures
in the typed Effect error channel.

See [Error Handling](/sdk/guides/error-handling).

## Action

* [`enableHcaSessionWithRefund`](/core/api/actions/hca/enable-hca-session-with-refund)
* [Guide](/core/guides/hca)
