# getRegistrationPlan

Gets registration plan for registration and renewal.

## Import

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

## Usage

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

const result = await sdk.registration.getRegistrationPlan({
  name: "example.eth",
  duration: 365n * 24n * 60n * 60n,
  owner: "0x0000000000000000000000000000000000000001",
  secret: "0x0000000000000000000000000000000000000000000000000000000000000001",
});
```

```ts [client.ts]
// [!include ~/snippets/sdk/client.ts]
```
:::

## Parameters

```ts
import type { GetRegistrationPlanParameters } from "@ensforge/sdk/registration";
```

### name

`string`

ENS name to operate on. ensforge normalizes it before hashing or contract interaction.

### duration

`bigint`

Duration in seconds.

### blockNumber

`bigint | undefined`

Block number to read from. Cannot be combined with `blockTag`.

### blockTag

`"latest" | "earliest" | "pending" | "safe" | "finalized" | undefined`

Named block state to read from. Cannot be combined with `blockNumber`.

### owner

`EthereumAddress`

Address that should own the resulting name or resource.

### secret

`Bytes32`

32-byte registration secret.

### resolver

`EthereumAddress | undefined`

Resolver address used by the method.

### subregistry

`EthereumAddress | undefined`

Value used for `subregistry` by this method.

### records

`ReadonlyArray<Hex> | undefined`

Records selected, read, or written.

### reverseRecord

`0 | 1 | 2 | undefined`

Value used for `reverseRecord` by this method.

### referrer

`Bytes32 | undefined`

Value used for `referrer` by this method.

### paymentToken

`EthereumAddress | undefined`

Payment token used by a supported registrar.

## Return Type

```ts
type GetRegistrationPlanResult = Awaited<ReturnType<typeof getRegistrationPlan>>;
```

| Property           | Type                                                                                                                                                                                                                                                                                                                                                         | Description                                            |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ |
| `status`           | `"unavailable" \| "payment-token-required" \| "unsupported-payment-token" \| "ready" \| "commitment-required" \| "commitment-pending" \| "commitment-expired"`                                                                                                                                                                                               | Current query, transaction, batch, or workflow status. |
| `name`             | `string & Brand<"NormalizedName">`                                                                                                                                                                                                                                                                                                                           | Normalized ENS name.                                   |
| `paymentToken`     | `&#96;0x${string}&#96; \| undefined`                                                                                                                                                                                                                                                                                                                         | The paymentToken value returned by the operation.      |
| `parameters`       | `{ readonly protocol: "v1"; readonly registrar: &#96;0x${string}&#96;; readonly priceOracle: &#96;0x${string}&#96;; readonly minimumRegistrationDuration: bigint; readonly minimumRenewalDuration: bigint; readonly minimumCommitmentAge: bigint; readonly maximumCommitmentAge: bigint; readonly payment: { ...; }; } \| { ...; } \| undefined`             | The parameters value returned by the operation.        |
| `price`            | `{ readonly status: "available"; readonly name: string & Brand<"NormalizedName">; readonly protocol: "v1" \| "v2"; readonly registrar: &#96;0x${string}&#96;; readonly duration: bigint; readonly base: bigint; readonly premium: bigint; readonly total: bigint; readonly currency: { ...; } \| { ...; }; } \| { ...; } \| { ...; } \| { .... \| undefined` | The price value returned by the operation.             |
| `commitment`       | `{ readonly name: string & Brand<"NormalizedName">; readonly protocol: "v1" \| "v2"; readonly registrar: &#96;0x${string}&#96;; readonly commitment: &#96;0x${string}&#96;; } \| undefined`                                                                                                                                                                  | The commitment value returned by the operation.        |
| `commitmentStatus` | `{ readonly status: "not-found"; readonly protocol: "v1" \| "v2"; } \| { readonly status: "pending"; readonly protocol: "v1" \| "v2"; readonly submittedAt: bigint; readonly readyAt: bigint; readonly expiresAt: bigint; readonly remainingSeconds: bigint; } \| { ...; } \| { ...; } \| undefined`                                                         | The commitmentStatus value returned by the operation.  |

## Effect

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

```ts
import { Effect } from "effect";
import { sdk } from "./client";

const program = sdk.registration.getRegistrationPlan.effect(parameters);

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

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

## Request

Use `.request` to describe the read without executing it, then include it in a typed
[read batch](/core/guides/batching).

```ts
const request = sdk.registration.getRegistrationPlan.request(parameters);
```

## Error

```ts
import type { GetRegistrationPlanError } from "@ensforge/sdk/registration";
```

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

* [`getRegistrationPlan`](/core/api/actions/registration/get-registration-plan)
