# primaryName.signClaim

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

Signs a claim to a primary name on one or more L2s, with one signature and no transaction. Options, result, errors and examples for primaryName.signClaim.

Source: https://ensforge.com/docs/reference/sdk/primary-name/sign-claim

<ApiMeta kind="Signs" stability="stable" since="1.0.0" source="packages/sdk/src/actions/primaryName/signClaim/index.ts#L87" />

Signs a claim to a primary name on one or more L2s, with one signature and no transaction.
Anyone can then submit it on each chain with `primaryName.set`, so the account needs no gas or
wallet connection there.

## When to use [#when-to-use]

Use to set the same primary name on several L2s with one prompt, or to let a server relay it
(sponsoring the L2 gas).

## Details [#details]

- The claim is for the ens-contracts `L2ReverseRegistrar`: every mainnet L2 shares one, so one
  signature covers all of `chainIds`; testnets share another.
- It expires `expiresIn` seconds (at most one hour, the registrar's limit) after the latest block
  of the earliest of those chains: read on the chains the client has in `chains`, and on the
  ENS chain for the others.
- The account signs EIP-191 over the registrar's message. Smart accounts sign as themselves
  (ERC-1271, or ERC-6492 before they are deployed); the registrar checks the signature on each L2,
  where the account must exist (or be deployable).
- `address` names a contract the signer owns (`Ownable`): the claim says so, and the
  registrar checks the ownership on each L2.
- Before signing, checks that `name` resolves to the address on each chain (its address for
  that chain, or its default EVM address); `verify: false` skips this.
- The claim is plain JSON: send it to a relaying server as is.

## Signature [#signature]

```ts
function signClaim(client: Like, options: signClaim.Options): Promise<signClaim.ReturnType>
```

Call it as `ens.primaryName.signClaim(options)` on a client, or `Actions.primaryName.signClaim(client, options)`.

## Parameters [#parameters]

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `name` (required) | `string \| null` |  | Primary name, or `null` to clear it. Normalized automatically. |
| `chainIds` (required) | `readonly number[]` |  | The L2s the claim sets the primary name on, by chain ID. |
| `address` | `string` | the signing account | Address to name: the signer's own, or a contract the signer owns (`Ownable`). |
| `expiresIn` | `bigint` | `3600n` | Seconds until the claim expires, at most one hour. |
| `verify` | `boolean` | `true` | Check that `name` resolves to the address on each chain before signing. |
| `account` | `Account \| Address` | the client's account | Signer. |

## Returns [#returns]

Resolves to `{ readonly claim: Claim; readonly signature: Hex }`. The claim and its signature, for `primaryName.set` on each chain.

| Field | Type | Description |
| --- | --- | --- |
| `claim` | `Claim` |  |
| `signature` | `Hex` |  |

## Errors [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME), [`INVALID_ADDRESS`](/docs/reference/errors/INVALID_ADDRESS) | invalid input. |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_COIN_TYPE`](/docs/reference/errors/INVALID_COIN_TYPE) | `chainIds` is empty, includes the ENS chain, or mixes mainnet L2s and testnets. |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_DURATION`](/docs/reference/errors/INVALID_DURATION) | `expiresIn` is not between 1 and 3600 seconds. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`UNSUPPORTED_ON_DEPLOYMENT`](/docs/reference/errors/UNSUPPORTED_ON_DEPLOYMENT) | a chain without an L2 reverse registrar. |
| [`NotFoundError`](/docs/reference/errors/not-found-error) | [`PRIMARY_NAME_MISMATCH`](/docs/reference/errors/PRIMARY_NAME_MISMATCH) | the name does not resolve to the address on a chain. |
| [`ConfigError`](/docs/reference/errors/config-error) | [`WALLET_NOT_CONFIGURED`](/docs/reference/errors/WALLET_NOT_CONFIGURED) | no signing account is known. |
| [`UserRejectedError`](/docs/reference/errors/user-rejected-error) | [`USER_REJECTED`](/docs/reference/errors/USER_REJECTED) | the user rejects the request. |
| [`WalletError`](/docs/reference/errors/wallet-error) | [`CHAIN_MISMATCH`](/docs/reference/errors/CHAIN_MISMATCH), [`ACCOUNT_NOT_FOUND`](/docs/reference/errors/ACCOUNT_NOT_FOUND) | the wallet is on another chain or has no account to sign with. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`WALLET_BATCH_UNSUPPORTED`](/docs/reference/errors/WALLET_BATCH_UNSUPPORTED) | with `mode: "batch"` or a paymaster when the wallet cannot send calls as one batch. |

It can also fail with the errors every write can (`Errors.WriteError`: the common errors plus `InsufficientFundsError`, `TransactionError`, `UnsupportedError`, `UserRejectedError`, `WalletError`).

See [How errors work](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="One signature for several L2s"
const signed = await ens.primaryName.signClaim({ name: "alice.eth", chainIds: [10, 8453] })

await ens.primaryName.set({ ...signed, coin: { chainId: 10 } })
await ens.primaryName.set({ ...signed, coin: { chainId: 8453 } })
```

```ts title="A server relaying a claim"
// In the app: sign, and send the claim to your server.
const signed = await ens.primaryName.signClaim({ name: "alice.eth", chainIds: [8453] })
await fetch("/api/primary-name", { method: "POST", body: JSON.stringify(signed) })

// On the server (`body` is the posted JSON), with a client whose `chains` has a funded
// wallet for Base:
const { claim, signature } = JSON.parse(body)
await relayer.primaryName.set({ claim, signature })
```
</Tab>

<Tab>
```ts title="Signing with a standalone call"
import { Actions } from "@ensforge/sdk"

const signed = await Actions.primaryName.signClaim(ens, { name: "alice.eth", chainIds: [10] })
```
</Tab>

<Tab>
```ts title="Signing in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

const signed = yield* Actions.primaryName.signClaim(ens, { name: "alice.eth", chainIds: [10] })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`primaryName.set`](/docs/reference/sdk/primary-name/set) to submit the claim