import { type Account, type Chain, type GetChainContractAddressErrorType, type Hash, type WriteContractErrorType } from 'viem'; import { type ChainWithContracts, type RequireClientContracts } from '../../../clients/chain.js'; import { UnsupportedNameTypeError } from '../../../errors/general.js'; import type { Prettify, WriteTransactionParameters } from '../../../types/index.js'; import { type ClientWithOverridesErrorType } from '../../../utils/clientWithOverrides.js'; import type { L2RegistrationParameters, MakeL2CommitmentTupleErrorType } from '../../../utils/registrar/registerHelpers.js'; import { type WrappedLabelLengthCheckErrorType } from '../../../utils/v1/nameWrapper/wrapper.js'; export type RegisterNameWriteParametersParameters = L2RegistrationParameters; export type RegisterNameWriteParametersReturnType = ReturnType>; export type RegisterNameWriteParametersErrorType = UnsupportedNameTypeError | WrappedLabelLengthCheckErrorType | GetChainContractAddressErrorType | MakeL2CommitmentTupleErrorType; export declare const registerNameWriteParameters: (client: RequireClientContracts, registrationParams: RegisterNameWriteParametersParameters) => { readonly address: `0x${string}`; readonly abi: readonly [{ readonly inputs: readonly [{ readonly name: "commitment"; readonly type: "bytes32"; }, { readonly name: "validFrom"; readonly type: "uint64"; }, { readonly name: "blockTimestamp"; readonly type: "uint64"; }]; readonly name: "CommitmentTooNew"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "commitment"; readonly type: "bytes32"; }, { readonly name: "validTo"; readonly type: "uint64"; }, { readonly name: "blockTimestamp"; readonly type: "uint64"; }]; readonly name: "CommitmentTooOld"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "duration"; readonly type: "uint64"; }, { readonly name: "minDuration"; readonly type: "uint64"; }]; readonly name: "DurationTooShort"; readonly type: "error"; }, { readonly inputs: readonly []; readonly name: "InvalidOwner"; readonly type: "error"; }, { readonly inputs: readonly []; readonly name: "MaxCommitmentAgeTooLow"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "label"; readonly type: "string"; }]; readonly name: "NameNotAvailable"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "label"; readonly type: "string"; }]; readonly name: "NameNotRenewable"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "label"; readonly type: "string"; }]; readonly name: "NotValid"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "paymentToken"; readonly type: "address"; }]; readonly name: "PaymentTokenNotSupported"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "token"; readonly type: "address"; }]; readonly name: "SafeERC20FailedOperation"; readonly type: "error"; }, { readonly inputs: readonly [{ readonly name: "commitment"; readonly type: "bytes32"; }]; readonly name: "UnexpiredCommitmentExists"; readonly type: "error"; }, { readonly type: "function"; readonly name: "register"; readonly inputs: readonly [{ readonly name: "label"; readonly type: "string"; }, { readonly name: "owner"; readonly type: "address"; }, { readonly name: "secret"; readonly type: "bytes32"; }, { readonly name: "subregistry"; readonly type: "address"; }, { readonly name: "resolver"; readonly type: "address"; }, { readonly name: "duration"; readonly type: "uint64"; }, { readonly name: "paymentToken"; readonly type: "address"; }, { readonly name: "referrer"; readonly type: "bytes32"; }]; readonly outputs: readonly [{ readonly name: "tokenId"; readonly type: "uint256"; }]; readonly stateMutability: "nonpayable"; }]; readonly functionName: "register"; readonly args: readonly [string, `0x${string}`, `0x${string}`, `0x${string}`, `0x${string}`, bigint, `0x${string}`, `0x${string}`]; readonly chain: Omit & { contracts: { ensEthRegistrar: import("viem").ChainContract; usdc: import("viem").ChainContract; }; } & { blockExplorers?: { [key: string]: { name: string; url: string; apiUrl?: string | undefined; }; default: { name: string; url: string; apiUrl?: string | undefined; }; } | undefined; blockTime?: number | undefined; contracts?: import("viem").Prettify<{ [key: string]: import("viem").ChainContract | { [sourceId: number]: import("viem").ChainContract | undefined; } | undefined; } & { ensRegistry?: import("viem").ChainContract | undefined; ensUniversalResolver?: import("viem").ChainContract | undefined; multicall3?: import("viem").ChainContract | undefined; erc6492Verifier?: import("viem").ChainContract | undefined; }> | undefined; ensTlds?: readonly string[] | undefined; id: number; name: string; nativeCurrency: { name: string; symbol: string; decimals: number; }; experimental_preconfirmationTime?: number | undefined; rpcUrls: { [key: string]: { http: readonly string[]; webSocket?: readonly string[] | undefined; }; default: { http: readonly string[]; webSocket?: readonly string[] | undefined; }; }; sourceId?: number | undefined; supportsTransactionReplacementDetection?: boolean | undefined; testnet?: boolean | undefined; } & import("viem").ChainConfig | undefined>; readonly account: Account; }; export type RegisterNameParameters | undefined> = Prettify>; export type RegisterNameReturnType = Hash; export type RegisterNameErrorType = RegisterNameWriteParametersErrorType | ClientWithOverridesErrorType | WriteContractErrorType; /** * Registers a name on ENS * @param client - {@link Client} * @param options - {@link RegisterNameOptions} * @returns Transaction hash. {@link RegisterNameReturnType} * * @example * import { createPublicClient, createWalletClient, erc20Abi, http, custom } from 'viem' * import { sepolia } from 'viem/chains' * import { addEnsContracts } from '@ensdomains/ensjs' * import { getChainContractAddress } from '@ensdomains/ensjs/chain' * import { getRegisterPrice } from '@ensdomains/ensjs/public' * import { randomSecret } from '@ensdomains/ensjs/utils' * import { commitName, registerName } from '@ensdomains/ensjs/wallet' * * const sepoliaWithEns = addEnsContracts(sepolia) * const publicClient = createPublicClient({ * chain: sepoliaWithEns, * transport: http(), * }) * const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' }) * const wallet = createWalletClient({ * account, * chain: sepoliaWithEns, * transport: custom(window.ethereum), * }) * const secret = randomSecret() * const params = { * label: 'example', * owner: account, * duration: 31536000, // 1 year * secret, * } * * const commitmentHash = await commitName(wallet, params) * await publicClient.waitForTransactionReceipt({ hash: commitmentHash }) // wait for commitment to finalise * await new Promise((resolve) => setTimeout(resolve, 60 * 1_000)) // wait for commitment to be valid * * // Registration is paid in an ERC-20 token (USDC by default), so approve * // the registrar to spend the price first * const usdc = getChainContractAddress({ chain: sepoliaWithEns, contract: 'usdc' }) * const registrar = getChainContractAddress({ chain: sepoliaWithEns, contract: 'ensEthRegistrar' }) * const { base, premium } = await getRegisterPrice(publicClient, { * label: params.label, * duration: BigInt(params.duration), * paymentToken: usdc, * }) * const approveHash = await wallet.writeContract({ * address: usdc, * abi: erc20Abi, * functionName: 'approve', * args: [registrar, base + premium], * }) * await publicClient.waitForTransactionReceipt({ hash: approveHash }) * * const hash = await registerName(wallet, params) * // 0x... */ export declare function registerName | undefined>(client: RequireClientContracts, { label, owner, duration, secret, resolverAddress, subregistryAddress, referrer, paymentToken, ...txArgs }: RegisterNameParameters): Promise; //# sourceMappingURL=registerName.d.ts.map