registration.renew
Renews one or more .eth names, ENSv1 or ENSv2, paying in an ERC-20 token. Parameters, return value, errors and examples for registration.renew in @ensforge/sdk.
Renews one or more .eth names, ENSv1 or ENSv2, paying in an ERC-20 token. Resolves once the transaction is submitted.
When to use
Use to extend names, including names in their grace period. Use renewSync to wait for the receipt.
Details
- ENSv2 names renew through the
ETHRegistrar, names still on ENSv1 throughETHRenewerV1(which also extends wrapped names); each route is onerenewBatchcall. - Token approvals are added for each contract whose allowance is short.
- Anyone can renew any name; the payer is the signer.
- A name listed twice is renewed once, for
duration.
Signature
function renew(
client: Like,
options: renew.Options & Write.Options,
): Promise<renew.ReturnType>Call it as ens.registration.renew(options) on a client, or Actions.registration.renew(client, options).
In React, use useRenew.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
names (required) | string | readonly string[] | One or more .eth second-level names. Normalized automatically. | |
duration (required) | bigint | Renewal length in seconds. | |
paymentToken | PaymentToken | "usdc" | Token to pay with. |
referrer | Hex | Referrer recorded by the registrar: 32 bytes, or an address (left-padded). |
Also takes the write options.
Returns
Resolves to Write.Result. Submitted transaction hashes and the plan that produced them.
| Field | Type | Description |
|---|---|---|
hash | Hex | Hash of the last transaction. |
hashes | readonly Hex[] | Every submitted transaction, in order. |
id | string | EIP-5792 bundle id when the calls were sent as one batch. |
plan | Plan | The plan the write executed: its steps, in order, as they were submitted. |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS, DURATION_TOO_SHORT | invalid input. |
NameStateError | NAME_NOT_RENEWABLE | a name is neither registered nor in its grace period. |
InsufficientFundsError | INSUFFICIENT_TOKEN_BALANCE | the signer cannot pay in the payment token. |
UnsupportedError | PAYMENT_TOKEN_UNSUPPORTED, UNSUPPORTED_ON_DEPLOYMENT | an unaccepted token or without ENSv2. |
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 { hash } = await ens.registration.renew({ names: ["alice.eth", "bob.eth"], duration: 31536000n })Plan methods
Each method takes the same options as registration.renew and sends nothing. See Preview before sending.
| Method | Description |
|---|---|
registration.renew.prepare(options) | Builds the plan without sending anything. |
registration.renew.simulate(options) | Simulates the plan with eth_call, reporting each step. |
registration.renew.estimateGas(options) | Estimates the gas and ETH the plan needs. |
Wait for the receipt with renewSync
Renews one or more .eth names, ENSv1 or ENSv2, paying in an ERC-20 token. Resolves once the receipt is in.
Use when the next step depends on the change being on-chain.
registration.renewSync takes the same options plus confirmations and timeout.
Resolves to renewSync.ReturnType. Receipts, the new expiry of each name and the amount paid.
const { receipt } = await ens.registration.renewSync({ names: ["alice.eth", "bob.eth"], duration: 31536000n })See also
registration.getRenewalPriceto quote it
Was this page helpful?