registration.getPrice
Quotes the price of registering a .eth name, in an ERC-20 payment token. Options, result, errors and examples for registration.getPrice.
Quotes the price of registering a .eth name, in an ERC-20 payment token.
When to use
Use to show the cost before registering, or to see how a recently expired name's premium falls over time.
Details
baseis the yearly rent for the label length times the duration;premiumis charged for names that recently became available and decays to zero.- Amounts are in the token's smallest unit (USDC has 6 decimals);
tokengives its symbol and decimals. atprices the name at a future timestamp, e.g. to show when the premium ends.
Gotchas
- The ENSv2 registrar is paid in ERC-20 only; there is no ETH price.
Signature
function getPrice(client: Like, options: getPrice.Options): Promise<getPrice.ReturnType>Call it as ens.registration.getPrice(options) on a client, or Actions.registration.getPrice(client, options).
registration.getPrice.request(options) builds a deferred read for Actions.batch. See Look up many at once.
In React, use useRegistrationPrice.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | .eth second-level name. Normalized automatically. | |
duration (required) | bigint | Registration length in seconds, e.g. Duration.years(1). | |
paymentToken | PaymentToken | "usdc" | Token to pay with. |
at | bigint | the current block's timestamp | Unix timestamp to price at, for the premium of a recently expired name. |
Also takes the read options.
Returns
Resolves to getPrice.ReturnType. Rent, premium and their total, in token units.
| Field | Type | Description |
|---|---|---|
base | bigint | |
premium | bigint | |
total | bigint | |
token | TokenInfo |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS, DURATION_TOO_SHORT | invalid input. |
UnsupportedError | PAYMENT_TOKEN_UNSUPPORTED, UNSUPPORTED_ON_DEPLOYMENT | an unaccepted token or without ENSv2. |
NetworkError | RPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITED | the RPC request fails. |
It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).
See How errors work.
Examples
import { Duration } from "@ensforge/sdk"
const { total, token } = await ens.registration.getPrice({ name: "alice.eth", duration: Duration.years(1) })Example response
Recorded from Ethereum mainnet on 2026-11-18 at block 26443964. Values change as the chain does.
await ens.registration.getPrice({ name: "ensforge-example.eth", duration: 31_536_000n }){
"base": "8000021n",
"premium": "0n",
"total": "8000021n",
"token": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"symbol": "USDC",
"decimals": 6
}
}See also
registration.registerto register it
Was this page helpful?