primaryName.signClaim
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.
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
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
- The claim is for the ens-contracts
L2ReverseRegistrar: every mainnet L2 shares one, so one signature covers all ofchainIds; testnets share another. - It expires
expiresInseconds (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 inchains, 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).
addressnames a contract the signer owns (Ownable): the claim says so, and the registrar checks the ownership on each L2.- Before signing, checks that
nameresolves to the address on each chain (its address for that chain, or its default EVM address);verify: falseskips this. - The claim is plain JSON: send it to a relaying server as is.
Signature
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
| 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
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
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS | invalid input. |
InvalidInputError | INVALID_COIN_TYPE | chainIds is empty, includes the ENS chain, or mixes mainnet L2s and testnets. |
InvalidInputError | INVALID_DURATION | expiresIn is not between 1 and 3600 seconds. |
UnsupportedError | UNSUPPORTED_ON_DEPLOYMENT | a chain without an L2 reverse registrar. |
NotFoundError | PRIMARY_NAME_MISMATCH | the name does not resolve to the address on a chain. |
ConfigError | WALLET_NOT_CONFIGURED | no signing account is known. |
UserRejectedError | USER_REJECTED | the user rejects the request. |
WalletError | CHAIN_MISMATCH, ACCOUNT_NOT_FOUND | the wallet is on another chain or has no account to sign with. |
UnsupportedError | 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.
Examples
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 } })// 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 })See also
primaryName.setto submit the claim
Was this page helpful?