import { Address } from 'algosdk'; import { AlgorandClient } from '@algorandfoundation/algokit-utils'; import { Constraints } from '../contracts/NFDRegistryClient'; import { NfdInstanceClient } from '../contracts/NFDInstanceClient'; import { NfdRegistryClient } from '../contracts/NFDRegistryClient'; import { TransactionSigner } from 'algosdk'; import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'; /** * An application box, with its name decoded and its value included */ export declare interface AppBox { /** The box name, decoded as UTF-8 */ name: string; /** The box value */ value: Uint8Array; } declare type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; declare interface Auth { /** * Which part of the request do we use to send the auth? * * @default 'header' */ in?: 'header' | 'query' | 'cookie'; /** * A unique identifier for the security scheme. * * Defined only when there are multiple security schemes whose `Auth` * shape would otherwise be identical. */ key?: string; /** * Header or query parameter name. * * @default 'Authorization' */ name?: string; scheme?: 'basic' | 'bearer'; type: 'apiKey' | 'http'; } declare type AuthToken = string | undefined; /** * Base module class that all other modules will extend */ declare abstract class BaseModule { protected readonly client: NfdClient; protected readonly algorand: AlgorandClient; protected readonly registryId: bigint; private readonly _defaultSender; constructor(client: NfdClient); /** * Get the current signer * @returns The current signer or null if not set */ protected getSigner(): TransactionSignerAccount | null; /** * Ensure a signer is set before proceeding * @returns The current signer * @throws If no signer is set */ protected requireSigner(): TransactionSignerAccount; /** * Get a registry client * @param defaultSender - Optional default sender address * @returns The NFD registry client */ protected getRegistryClient(defaultSender?: string | Address): NfdRegistryClient; /** * Get an NFD instance client * @param nfdAppId - The NFD's application ID * @param defaultSender - Optional default sender address * @returns The NFD instance client */ protected getInstanceClient(nfdAppId: bigint, defaultSender?: string | Address): NfdInstanceClient; /** * Get the box name for an NFD in the registry * @param nfdName - The NFD name to get the box name for * @returns The box name as a Uint8Array */ protected getRegistryBoxNameForNFD(nfdName: string): Promise; /** * Get every box for an application, with values included * * Uses the `include=values` query parameter so that names and values arrive * together, which takes one request per page rather than one request per box. * Pages after the first are pinned to the round the first page was read at, so * a multi-page read is consistent. * * @param appId - The application ID to read boxes from * @returns Every box for the application * @throws If the node returns boxes without values, or does not advance the * pagination cursor */ protected getAllBoxes(appId: bigint): Promise; /** * Get an NFD's application ID from its name * @param name - The NFD name * @returns The NFD's application ID or null if not found */ protected getAppIdFromName(name: string): Promise; /** * Parse a name or app ID input into a bigint app ID * * Resolving a name costs one registry box read; a numeric input costs * nothing. Callers that only need the app ID should use this rather than a * full `resolve()`, which additionally reads global state and every box. * * @param nameOrAppId - The NFD name or application ID to parse * @returns The NFD's application ID as a bigint * @throws If the input is an invalid NFD name or the NFD does not exist */ protected parseAppId(nameOrAppId: string | number | bigint): Promise; /** * Get the protocol constraints from the NFD registry * @returns The protocol constraints * @throws If an error occurs while fetching the constraints */ protected getConstraints(): Promise; } declare type BodySerializer = (body: unknown) => unknown; declare type BuildUrlFn = ; query?: Record; url: string; }>(options: TData & Options) => string; /** * Check if the caller is authorized to mint a segment for the given parent NFD * @param nfd - The parent NFD object * @param callerAddress - The address of the caller attempting to mint a segment * @returns True if the caller is authorized to mint a segment, false otherwise */ export declare function canMintSegment(nfd: Nfd | null, callerAddress: string): boolean; /** * Check availability of an IPFS resource and return appropriate URL * Tries images.nf.domains first, falls back to IPFS gateway * Only returns URLs for image content types * * @param url - IPFS URL to check * @returns URL to use (either images.nf.domains or fallback gateway) */ export declare const checkIpfsAvailability: (url: string) => Promise; declare type Client = Client_2 & { interceptors: Middleware; }; declare const client: Client; declare type Client_2 = { /** * Returns the final request URL. */ buildUrl: BuildUrlFn; getConfig: () => Config; request: RequestFn; setConfig: (config: Config) => Config; } & { [K in HttpMethod]: MethodFn; } & ([SseFn] extends [never] ? { sse?: never; } : { sse: { [K in HttpMethod]: SseFn; }; }); declare interface ClientOptions { baseUrl?: string; responseStyle?: ResponseStyle; throwOnError?: boolean; } declare interface Config extends Omit, Config_2 { /** * Base URL for all requests made by this client. */ baseUrl?: T['baseUrl']; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. * * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. */ next?: never; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. * You can override this behavior with any of the {@link Body} methods. * Select `stream` if you don't want to parse response data at all. * * @default 'auto' */ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ responseStyle?: ResponseStyle; /** * Throw an error instead of returning it in the response? * * @default false */ throwOnError?: T['throwOnError']; } declare interface Config_2 { /** * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ bodySerializer?: BodySerializer | null; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. * * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: RequestInit['headers'] | Record; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: Uppercase; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject * style, and reserved characters are percent-encoded. * * This method will have no effect if the native `paramsSerializer()` Axios * API function is used. * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ requestValidator?: (data: unknown) => Promise; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g., converting ISO strings into Date objects. */ responseTransformer?: (data: unknown) => Promise; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ responseValidator?: (data: unknown) => Promise; } declare type ErrInterceptor = (error: Err, /** response may be undefined due to a network error where no response object is produced */ response: Res | undefined, /** request may be undefined, because error may be from building the request object itself */ request: Req | undefined, options: Options) => Err | Promise; /** * Extract the parent NFD name from a segment NFD name * @param segmentName - The segment NFD name (e.g., "xxx.yyy.algo") * @returns The parent NFD name (e.g., "yyy.algo") * @throws If the segment name is invalid */ export declare function extractParentName(segmentName: string): string; /** * Get the basename of an NFD (e.g., for "xxx.yyy.algo" returns "yyy") * @param name - The NFD name * @returns The basename of the NFD */ export declare function getNfdBasename(name: string): string; declare type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'; declare class Interceptors { fns: Array; clear(): void; eject(id: number | Interceptor): void; exists(id: number | Interceptor): boolean; getInterceptorIndex(id: number | Interceptor): number; update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; use(fn: Interceptor): number; } /** * Checks if a string is a valid IPFS URL * @param url The URL to check * @returns True if the URL is a valid IPFS URL */ export declare function isIpfsUrl(url: string): boolean; /** * Check if segment minting is unlocked for an NFD * @param nfd - The NFD object to check * @returns True if segment minting is unlocked, false otherwise * * Note: By default, segment minting is locked when a root NFD is created. * The segmentLocked property is only set to '0' when explicitly unlocked. * If the property doesn't exist or is set to any value other than '0', * segment minting should be considered locked. */ export declare function isSegmentMintingUnlocked(nfd: Nfd | null): boolean; /** * Check if name is a valid NFD segment * @param name - The NFD name to validate * @returns True if the name is a segment, false otherwise */ export declare function isSegmentName(name: string): boolean; /** * Check if name is a valid NFD root/segment * @param name - The NFD name to validate * @returns True if the name is valid, false otherwise */ export declare function isValidName(name: string): boolean; /** * Options for listing an NFD for sale */ export declare interface ListForSaleOptions { /** * Reserve the sale for a specific address */ reservedFor?: string; } /** * Module for NFD lookup and resolution operations */ export declare class LookupModule extends BaseModule { /** * Resolve an NFD by name or application ID by reading directly from the blockchain * @param nameOrAppId - The NFD name or application ID to resolve * @param options - Optional parameters * @returns The NFD record * @throws If the NFD name is invalid or not found */ resolve(nameOrAppId: string | number | bigint, options?: ResolveOptions_2): Promise; /** * Resolve an NFD and also return the boxes it was built from * * Callers that need a raw box value (rather than the parsed property) can * take it from the returned boxes instead of issuing a second read. * * @param nameOrAppId - The NFD name or application ID to resolve * @param options - Optional parameters * @returns The NFD record and every box on its instance app * @throws If the NFD name is invalid or not found */ resolveWithBoxes(nameOrAppId: string | number | bigint, options?: ResolveOptions_2): Promise; } declare type MethodFn = (options: Omit, 'method'>) => RequestResult; declare interface Middleware { error: Interceptors>; request: Interceptors>; response: Interceptors>; } /** * NFD record containing domain information and properties */ export declare type Nfd = NfdRecord; /** * Client for interacting with the NFD API * This class wraps the auto-generated API client to provide a more convenient interface */ export declare class NfdApiClient { private readonly _client; /** * Create a new NfdApiClient instance * @param registryId - The registry ID to determine which network to use */ constructor(registryId?: number | bigint); /** * Create a new NfdApiClient instance configured for MainNet * @returns A new NfdApiClient instance */ static mainNet(): NfdApiClient; /** * Create a new NfdApiClient instance configured for TestNet * @returns A new NfdApiClient instance */ static testNet(): NfdApiClient; /** * Get the raw generated API client * @returns The raw API client */ get client(): typeof client; /** * Set the base URL for the API client * @param baseUrl - The base URL to use for API requests */ setBaseUrl(baseUrl: string): void; /** * Resolve an NFD by name or application ID using the API */ resolve(nameOrId: string, options?: ResolveOptions): Promise; /** * Perform a reverse lookup to find NFDs associated with Algorand addresses * @param addresses - Array of Algorand addresses to look up * @param options - Options for the lookup * @returns Record mapping addresses to their associated NFDs * @remarks * This method returns a record where each key is an Algorand address and the value is the NFD associated with that address. * If an address is not associated with any NFDs, the value will be an empty object. */ reverseLookup(addresses: string[], options?: ReverseLookupOptions): Promise>; /** * Search for NFDs using the API */ search(options?: SearchOptions): Promise; /** * Get name suggestions for NFD registration * @param name - The name (even partial) to search for * @param options - Suggestion options including the buyer address * @returns Array of suggested NFD records */ suggest(name: string, options: SuggestOptions): Promise; /** * Start a verification request for an NFD property * @param name - The NFD name to verify a property for * @param sender - The NFD owner's address * @param field - The field to verify * @returns Verification request result with challenge and ID */ verifyRequest(name: string, sender: string, field: VerifyField): Promise; /** * Confirm a verification request * @param id - The verification request ID * @param challenge - The challenge value (optional depending on verification type) * @returns Verification confirmation result */ verifyConfirm(id: string, challenge?: string): Promise; /** * Internal method for cache parameter * @private */ private _getCacheParam; } /** * Client for interacting with NFDs (Non-Fungible Domains) through the smart contracts and the API */ export declare class NfdClient { private readonly _algorand; private readonly _registryId; private readonly _api; private readonly _lookup; private readonly _metadata; private readonly _minting; private readonly _purchasing; private _signer; constructor(config?: NfdClientConfig); /** * Create a new NfdClient instance configured for MainNet * @returns A new NfdClient instance */ static mainNet(): NfdClient; /** * Create a new NfdClient instance configured for TestNet * @returns A new NfdClient instance */ static testNet(): NfdClient; /** * Get the AlgorandClient instance * @returns The AlgorandClient instance */ get algorand(): AlgorandClient; /** * Get the registry ID * @returns The registry ID */ get registryId(): bigint; /** * Get the API client for interacting with the NFD API */ get api(): NfdApiClient; /** * Get the current signer * @returns The current signer or null if not set */ get signer(): TransactionSignerAccount | null; /** * Tracks the given signer against the given sender for later signing. * @param sender - The sender address to use this signer for * @param signer - The signer to sign transactions with for the given sender * @returns The `NfdClient` instance so method calls can be chained */ setSigner(sender: string | Address, signer: TransactionSigner): NfdClient; /** * Create a manager for a specific NFD * @param nameOrAppId - The NFD name or application ID to manage * @returns An NFD manager instance */ manage(nameOrAppId: string | number | bigint): NfdManager; /** * Get access to purchasing and claiming functionality * @returns A purchasing module instance */ purchasing(): PurchasingModule; /** * Resolve an NFD by name or application ID by reading directly from the blockchain * @param nameOrAppId - The NFD name or application ID to resolve * @param options - Optional parameters * @returns The NFD record * @throws If the NFD name is invalid or not found */ resolve(nameOrAppId: string | number | bigint, options?: ResolveOptions): Promise; /** * Get a price quote for minting an NFD * @param nfdName - The name of the NFD to get a quote for * @param params - Parameters for the quote * @returns A detailed price quote including base price, fees, and total * @throws If the quote cannot be generated */ getMintQuote(nfdName: string, params: NfdMintQuoteParams): Promise; /** * Mint a new NFD * @param nfdName - The name of the NFD to mint * @param params - Configuration options for minting * @returns The minted NFD record * @throws If the mint operation fails */ mint(nfdName: string, params: NfdMintParams): Promise; /** * Get a quote for purchasing an NFD * @param nameOrAppId - The NFD name or application ID to get a quote for * @returns A detailed purchase quote including price and eligibility * @throws If the quote cannot be generated or signer is not set */ getPurchaseQuote(nameOrAppId: string | number | bigint): Promise; /** * Claim an NFD that is reserved for the claimer * @param nameOrAppId - The NFD name or application ID to claim * @returns The claimed NFD record * @throws If the claim operation fails or signer is not set */ claim(nameOrAppId: string | number | bigint): Promise; /** * Buy an NFD from the secondary market * @param nameOrAppId - The NFD name or application ID to buy * @returns The purchased NFD record * @throws If the buy operation fails or signer is not set */ buy(nameOrAppId: string | number | bigint): Promise; /** * Resolve an address to find its associated NFD * @param address - The address to resolve * @param options - Options for the lookup * @returns The NFD associated with the address, or null if not found */ resolveAddress(address: string | Address, options?: ReverseLookupOptions): Promise; /** * Resolve multiple addresses to find their associated NFDs * @param addresses - Array of addresses to resolve * @param options - Options for the lookup * @returns Record mapping addresses to their associated NFD (one per address) */ resolveAddresses(addresses: Array, options?: ReverseLookupOptions): Promise>; /** * Search for all NFDs owned by a specific wallet address * @param address - The wallet address to search for * @param options - Additional search options to apply * @returns Search response containing owned NFDs * @remarks * By default, this method returns up to 20 results. You can override this by * specifying a different limit in the options parameter. */ searchByOwner(address: string | Address, options?: Omit): Promise; /** * Search for all NFDs that are currently for sale * @param options - Additional search options to apply * @returns Search response containing NFDs for sale * @remarks * By default, this method returns up to 20 results. You can override this by * specifying a different limit in the options parameter. */ searchForSale(options?: Omit): Promise; /** * Get the avatar image information for an NFD * @param nameOrAppId - The NFD name or application ID * @returns The avatar image result with raw value, HTTPS URL, verification status, and ASA ID * @remarks The URL will always be provided - either the actual avatar or a default fallback image */ getAvatarImage(nameOrAppId: string | number | bigint): Promise; /** * Get the avatar image information for an NFD * @param nfd - The NFD data object (for optimized parsing without additional resolve) * @returns The avatar image result with raw value, HTTPS URL, verification status, and ASA ID * @remarks The URL will always be provided - either the actual avatar or a default fallback image */ getAvatarImage(nfd: Nfd): Promise; /** * Get the banner image information for an NFD * @param nameOrAppId - The NFD name or application ID * @returns The banner image result with raw value, HTTPS URL, verification status, and ASA ID */ getBannerImage(nameOrAppId: string | number | bigint): Promise; /** * Get the banner image information for an NFD * @param nfd - The NFD data object (for optimized parsing without additional resolve) * @returns The banner image result with raw value, HTTPS URL, verification status, and ASA ID */ getBannerImage(nfd: Nfd): Promise; /** * Get name suggestions for NFD registration * @param name - The name (even partial) to search for * @param options - Suggestion options including the buyer address * @returns Array of suggested NFD records */ suggest(name: string, options: SuggestOptions): Promise; /** * Make an offer to purchase an NFD from its owner * @param nameOrAppId - The NFD name or application ID to make an offer on * @param amount - The offer amount in microAlgos * @param note - Optional note to the owner * @returns The NFD record * @throws If the offer fails or signer is not set */ makeOffer(nameOrAppId: string | number | bigint, amount: bigint | number, note?: string): Promise; /** * Start a verification request for an NFD property * @param name - The NFD name to verify a property for * @param field - The field to verify * @returns Verification request result with challenge and ID * @throws If the verification request fails or signer is not set */ verifyRequest(name: string, field: VerifyField): Promise; /** * Confirm a verification request * @param id - The verification request ID * @param challenge - The challenge value (optional depending on verification type) * @returns Verification confirmation result */ verifyConfirm(id: string, challenge?: string): Promise; } /** * Configuration options for the NFD client */ export declare interface NfdClientConfig { /** * An existing AlgorandClient instance */ algorand?: AlgorandClient; /** * The application ID of the NFD registry */ registryId?: number | bigint; } /** * Result of resolving an NFD's avatar or banner image */ export declare interface NfdImageResult { /** The raw value stored on-chain */ raw: string | null; /** A valid https:// URL (converted from ipfs:// if needed). For avatars, always provided (includes fallback). For banners, may be null. */ url: string | null; /** Whether the image is verified (stored in verified properties) */ verified: boolean; /** If verified, the ASA ID of the NFT image */ asaId: number | null; /** Whether this result uses a fallback default image (only for avatars) */ isFallback?: boolean; } /** * Manager for operations on a specific NFD */ export declare class NfdManager extends BaseModule { private _nfd; private _boxes; private readonly _nameOrAppId; constructor(client: NfdClient, nameOrAppId: string | number | bigint); /** * Get the NFD instance * @returns The NFD instance * @throws If the NFD cannot be resolved */ private getNfd; /** * Get the raw value of a box read during the last `getNfd()` * @param name - The box name * @returns The box value, or an empty array if the NFD has no such box */ private getResolvedBoxValue; /** * Drop the cached NFD so the next `getNfd()` re-reads it from chain. Clears * the cached boxes too, so they can never pair with a newer NFD. */ private invalidate; /** * Assert the NFD is neither listed for sale nor expired * * The instance contract gates most owner-driven writes behind * `notForSaleOrExpired()`, so a live listing or a lapsed expiration blocks * them until the owner cancels the sale or renews. Checking here turns an * opaque `assert` failure into an error that names the cause and the cure. * * @param nfd - The resolved NFD * @param action - What the caller was trying to do, for the message * @throws If the NFD is for sale or expired */ private assertNotForSaleOrExpired; /** * Assert the NFD is not mid-mint * * @param nfd - The resolved NFD * @param action - What the caller was trying to do, for the message * @throws If the NFD is still minting */ private assertNotMinting; /** * Split fields and values if any values exceed the byte limit * @param fieldsAndValues - Array of alternating field names and values * @returns Array of field names and values, potentially split into chunks * @private */ private splitFields; /** * Link an Algorand address to the NFD * @param address - The Algorand address to link * @returns The updated NFD * @throws If the address cannot be linked */ linkAddress(address: string | Address): Promise; /** * Unlink an Algorand address from the NFD * @param address - The Algorand address to unlink * @returns The updated NFD * @throws If the address cannot be unlinked */ unlinkAddress(address: string | Address): Promise; /** * Set user-defined metadata for the NFD * @param metadata - Object containing metadata key-value pairs to set * @returns The updated NFD * @throws If the metadata cannot be set */ setMetadata(metadata: Record): Promise; /** * Set a specific address as the primary address for the NFD * @param address - The Algorand address to set as primary * @returns The updated NFD * @throws If the address cannot be set as primary */ setPrimaryAddress(address: string | Address): Promise; /** * Set this NFD as the primary NFD for a specific address * @param address - The Algorand address to set this NFD as primary for * @returns The updated NFD * @throws If the NFD cannot be set as primary for the address */ setPrimaryNfd(address: string | Address): Promise; /** * Get the renewal price for the NFD (per year, in microAlgos) * @returns The renewal price per year in microAlgos * @throws If the price cannot be retrieved */ getRenewalPrice(): Promise; /** * Renew the NFD * * The contract derives the new expiration from the amount paid, capped by * the registry's `maxYearsAllowed`, so the upper bound is read from the * registry rather than assumed. * * @param years - Number of whole years to renew for (default 1) * @returns The updated NFD * @throws If `years` is not a whole number of at least 1, exceeds the * registry's maximum, or the renewal fails */ renew(years?: number): Promise; /** * List the NFD for sale on the marketplace * * The contract refuses to sell an NFD that still has properties, so every * user-defined and verified field has to be cleared first. Calling this on * an NFD already listed re-prices it. * * @param price - The sale price in microAlgos * @param options - Optional sale configuration * @returns The updated NFD * @throws If the NFD is expired, still minting, or still has properties, or * if the listing fails */ listForSale(price: bigint | number, options?: ListForSaleOptions): Promise; /** * Cancel the sale listing for the NFD * @returns The updated NFD * @throws If the NFD is not listed for sale, is expired or still minting, or * the cancellation fails */ cancelSale(): Promise; /** * Lock or unlock segment minting for the NFD * * Unlocking sets the price anyone may mint a segment at, and the contract * requires it to be at least the registry's `segmentPlatformCostInUsd`, so * the default of 0 is only valid when locking. * * @param lock - Whether to lock (true) or unlock (false) segment minting * @param usdPrice - The price in USD cents for minting segments (e.g., 300 = $3.00). Set to 0 if locking. * @returns The updated NFD * @throws If unlocking below the registry minimum, if the NFD is for sale or * expired, or if the operation fails */ lockSegment(lock: boolean, usdPrice?: number): Promise; /** * Lock or unlock vault opt-ins for the NFD * @param lock - Whether to lock (true) or unlock (false) vault opt-ins. * When locked, only the owner can opt the vault into assets. * When unlocked, anyone can opt the vault into assets. * @returns The updated NFD * @throws If the NFD is for sale or expired, or the operation fails */ lockVault(lock: boolean): Promise; /** * Opt the NFD vault into assets, and optionally transfer one of them * * `options.amount` sends that many base units of the asset to the vault in * the same group. Since the amount applies to one asset, it can only be * given alongside a single asset — call this once per asset to send several. * * The vault's minimum balance rises by {@link VAULT_OPT_IN_MBR} per asset, * and the contract requires the caller to fund it in the same group. That * payment is charged for every asset passed, whether or not the vault is * already opted into it, so filter out assets the vault already holds. * * @param assets - ASA IDs to opt the vault into. `0` (ALGO) needs no opt-in * and is only meaningful together with `amount`. * @param options - Options for the vault operation * @returns The updated NFD * @throws If `assets` is empty, if `amount` is given with more than one * asset, if the NFD is for sale or expired, or if the operation fails */ sendToVault(assets: number[], options?: SendToVaultOptions): Promise; /** * Resolve a vault receiver to an Algorand address * * `vaultSend`'s receiver argument is an ABI `address`, so an NFD name has to * be resolved to one first. `receiverType` picks which of the receiving * NFD's accounts to send to. * * @param receiver - An Algorand address, or an NFD name to resolve * @param receiverType - Which account of a receiving NFD to send to: * its deposit account (`'account'`) or its vault (`'nfdVault'`) * @returns The receiving Algorand address * @throws If the receiver is neither a valid address nor a resolvable NFD * name, or `'nfdVault'` is used with a plain address */ private resolveVaultReceiver; /** * Send assets from the NFD vault to a receiver * * `options.amount` applies to a single asset. Passing several assets means * "send the full balance of each", which the contract only accepts with no * amount — it closes the vault out of every asset in the list. * * @param assets - ASA IDs to send from the vault, or `[0]` to send ALGO * @param receiver - The receiving Algorand address, or an NFD name to * resolve to one * @param options - Options for the vault operation * @returns The updated NFD * @throws If `assets` is empty, if `amount` is given with more than one * asset, if ALGO is combined with other assets or sent without an amount, * if the NFD is for sale or expired, if the receiver cannot be resolved, * or if the operation fails */ sendFromVault(assets: number[], receiver: string, options?: SendFromVaultOptions): Promise; } /** * Configuration options for minting a new NFD */ export declare interface NfdMintParams { /** * The address of the buyer */ buyer: string; /** * Number of years until expiration (1-20) */ years: number; /** * Optional address to reserve the NFD for. If not provided, the buyer's address will be used. */ reservedFor?: string; } /** * Detailed price quote for minting an NFD */ export declare interface NfdMintQuote { /** Base price for the specified years in microAlgos */ basePrice: bigint; /** Fixed carry cost in microAlgos */ carryCost: bigint; /** Extra fee for minting in microAlgos */ extraFee: bigint; /** Total price including all fees in microAlgos */ totalPrice: bigint; /** Number of years the quote is for */ years: number; /** The NFD name being quoted */ nfdName: string; /** The address of the buyer */ buyer: string; /** Whether the NFD is a segment */ isSegment: boolean; } /** * Configuration options for getting an NFD price quote */ export declare interface NfdMintQuoteParams { /** * The address of the potential buyer */ buyer: string; /** * Number of years to get a quote for (default: 1) */ years?: number; } /** * NFDProperties contains the expanded metadata stored within an NFD contracts' global-state */ declare type NfdProperties = { /** * Internal properties */ internal?: { [key: string]: string; }; /** * User properties */ userDefined?: { [key: string]: string; }; /** * Verified properties */ verified?: { [key: string]: string; }; }; /** * Response structure for purchase quote requests */ export declare interface NfdPurchaseQuote { /** The NFD name being quoted */ nfdName: string; /** The address of the buyer */ buyer: string; /** Whether this NFD can be claimed (is reserved for the buyer) */ canClaim: boolean; /** Whether this NFD can be bought (is for sale) */ canBuy: boolean; /** The price to purchase in microAlgos (calculated amount for claims, sellAmount for purchases) */ price: bigint; /** The address the NFD is reserved for (if any) */ reservedFor?: string; /** The current sell amount in microAlgos (if for sale) */ sellAmount?: bigint; /** The current state of the NFD */ state: string; /** Whether the buyer is authorized to make this purchase */ authorized: boolean; /** Reason why purchase is not authorized (if applicable) */ authorizationError?: string; } /** * NFD contains all known information about an NFD record */ declare type NfdRecord = { /** * NFD Application ID */ appID?: number; /** * NFD ASA ID */ asaID?: number; /** * Whether the verified Avatar set in this NFD is newer (arc19) then is set into the NFD. This will only be present on direct NFD fetch and if true */ avatarOutdated?: boolean; /** * Verified Algorand addresses for this NFD */ caAlgo?: Array; /** * Cache-Control header */ 'cache-control'?: string; /** * Category of NFD */ category?: 'curated' | 'premium' | 'common'; /** * Round this data was last fetched from */ currentAsOfBlock?: number; /** * An Algorand Account address */ depositAccount?: string; /** * ETag */ etag?: string; expired?: boolean; /** * Not returned, used in tagging for response to indicate if-none-match etag matched */ 'match-check'?: string; /** * Tags set by the system for tracking/analytics */ metaTags?: Array; name: string; /** * An Algorand Account address */ nfdAccount?: string; /** * An Algorand Account address */ owner?: string; /** * NFD Application ID of Parent if this is a segment */ parentAppID?: number; properties?: NfdProperties; /** * An Algorand Account address */ reservedFor?: string; /** * Sale type of NFD */ saleType?: 'auction' | 'buyItNow'; /** * amount NFD is being sold for (microAlgos) */ sellAmount?: number; /** * An Algorand Account address */ seller?: string; /** * An Algorand Account address */ sigNameAddress?: string; /** * State of NFD */ state?: 'available' | 'minting' | 'reserved' | 'forSale' | 'owned' | 'expired'; /** * Tags assigned to this NFD */ tags?: Array; timeChanged?: string; timeCreated?: string; timeExpires?: string; timePurchased?: string; /** * Unverified (non-algo) Crypto addresses for this NFD */ unverifiedCa?: { [key: string]: Array; }; /** * Unverified Algorand addresses for this NFD */ unverifiedCaAlgo?: Array; }; declare type NfdRecordCollection = Array; /** The NFD registry app IDs for each network */ export declare enum NfdRegistryId { MAINNET = 760937186, TESTNET = 84366825 } declare type NfdSearchV2Response = NfdSearchV2Responses[keyof NfdSearchV2Responses]; declare type NfdSearchV2Responses = { /** * OK response. */ 200: NfdV2SearchRecords; }; /** * Collection of NFD browse results */ declare type NfdV2SearchRecords = { /** * Cache-Control header */ 'cache-control'?: string; /** * ETag */ etag?: string; /** * Not returned, used in tagging for response to indicate if-none-match etag matched */ 'match-check'?: string; nfds: NfdRecordCollection; /** * total number of results, with data containing paged amount based on offset/limit */ total: number; }; declare type ObjectStyle = 'form' | 'deepObject'; declare type OmitKeys = Pick>; declare type Options = OmitKeys, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit); /** * Error parser utility for Algorand transaction errors * Provides user-friendly error messages for common Algorand transaction errors */ /** * Parse an error message and return a user-friendly version * @param error - The error object or string to parse * @returns A user-friendly error message */ export declare function parseTransactionError(error: unknown): string; /** * Module for handling NFD purchasing operations (claiming and buying) */ export declare class PurchasingModule extends BaseModule { /** * Validate an Algorand address * @private */ private validateAddress; /** * Get a purchase quote for an NFD * @param nameOrAppId - The NFD name or application ID * @param buyer - The buyer address * @returns Detailed purchase quote including eligibility and pricing * @throws If the NFD cannot be resolved or quote cannot be generated */ getPurchaseQuote(nameOrAppId: string | number | bigint, buyer: string): Promise; /** * Claim an NFD that is reserved for the caller * @param nameOrAppId - The NFD name or application ID to claim * @returns The claimed NFD record * @throws If the claim operation fails */ claim(nameOrAppId: string | number | bigint): Promise; /** * Buy an NFD from the secondary market * @param nameOrAppId - The NFD name or application ID to buy * @returns The purchased NFD record * @throws If the buy operation fails */ buy(nameOrAppId: string | number | bigint): Promise; /** * Check if an NFD can be claimed by a specific address * @param nameOrAppId - The NFD name or application ID * @param claimer - The address to check claim eligibility for * @returns True if the NFD can be claimed, false otherwise */ canClaim(nameOrAppId: string | number | bigint, claimer: string): Promise; /** * Check if an NFD can be bought by a specific address * @param nameOrAppId - The NFD name or application ID * @param buyer - The address to check buy eligibility for * @returns True if the NFD can be bought, false otherwise */ canBuy(nameOrAppId: string | number | bigint, buyer: string): Promise; /** * Make an offer to purchase an NFD from its owner * @param nameOrAppId - The NFD name or application ID to make an offer on * @param amount - The offer amount in microAlgos * @param note - Optional note to the owner * @returns The NFD record * @throws If the offer fails */ makeOffer(nameOrAppId: string | number | bigint, amount: bigint | number, note?: string): Promise; } declare type QuerySerializer = (query: Record) => string; declare type QuerySerializerOptions = QuerySerializerOptionsObject & { /** * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ parameters?: Record; }; declare type QuerySerializerOptionsObject = { allowReserved?: boolean; array?: Partial>; object?: Partial>; }; declare type ReqInterceptor = (request: Req, options: Options) => Req | Promise; declare type RequestFn = (options: Omit, 'method'> & Pick>, 'method'>) => RequestResult; declare interface RequestOptions extends Config<{ responseStyle: TResponseStyle; throwOnError: ThrowOnError; }>, Pick, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> { /** * Any body that you want to add to your request. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ body?: unknown; path?: Record; query?: Record; /** * Security mechanism(s) to use for the request. */ security?: ReadonlyArray; url: Url; } declare type RequestResult = ThrowOnError extends true ? Promise ? TData[keyof TData] : TData : { data: TData extends Record ? TData[keyof TData] : TData; request: Request; response: Response; }> : Promise ? TData[keyof TData] : TData) | undefined : ({ data: TData extends Record ? TData[keyof TData] : TData; error: undefined; } | { data: undefined; error: TError extends Record ? TError[keyof TError] : TError; }) & { /** request may be undefined, because error may be from building the request object itself */ request?: Request; /** response may be undefined, because error may be from building the request object itself or from a network error */ response?: Response; }>; declare type ResInterceptor = (response: Res, request: Req, options: Options) => Res | Promise; declare interface ResolvedRequestOptions extends RequestOptions { headers: Headers; serializedBody?: string; } /** * Configuration options for resolving an NFD */ export declare interface ResolveOptions { /** * View of data to return * @default 'brief' */ view?: 'tiny' | 'brief' | 'full'; /** * Use if polling waiting for state change - causes notFound to return as 204 instead of 404 * @default false */ poll?: boolean; /** * Set to true to return a never-cached result * @default false */ nocache?: boolean; } /** * Options for resolving an NFD */ declare interface ResolveOptions_2 { /** * The view type to use for the response * - 'tiny': Only include internal, caAlgo, and url properties * - 'brief': Include internal, caAlgo, url, avatar, and reservedFor properties * - 'full': Include all properties */ view?: 'tiny' | 'brief' | 'full'; } /** * An NFD resolved from chain, together with the boxes it was built from */ export declare interface ResolveResult { /** The resolved NFD record */ nfd: Nfd; /** Every box on the NFD instance app, regardless of the view used */ boxes: AppBox[]; } declare type ResponseStyle = 'data' | 'fields'; /** * Configuration options for reverse lookup */ export declare interface ReverseLookupOptions { /** * View of data to return * @default 'tiny' */ view?: 'tiny' | 'thumbnail' | 'brief' | 'full'; /** * Whether to allow unverified addresses to match * @default false */ allowUnverified?: boolean; /** * Set to true to return a never-cached result * @default false */ nocache?: boolean; } /** * Configuration options for searching NFDs */ export declare interface SearchOptions { /** * Name or partial match of NFD name to filter on */ name?: string; /** * Filter by NFD category */ category?: Array<'curated' | 'premium' | 'common'>; /** * Filter by sale type */ saleType?: Array<'auction' | 'buyItNow'>; /** * Filter by NFD state */ state?: Array<'reserved' | 'forSale' | 'owned' | 'expired'>; /** * The parent NFD Application ID to find. Used for fetching segments of an NFD */ parentAppId?: number; /** * Filter by NFD length */ length?: Array<'1_letters' | '2_letters' | '3_letters' | '4_letters' | '5_letters' | '6_letters' | '7_letters' | '8_letters' | '9_letters' | '10+_letters'>; /** * Filter by NFD traits */ traits?: Array<'emoji' | 'pristine' | 'segment'>; /** * Filter by NFD owner address */ owner?: string; /** * Filter by NFD reserved for address */ reservedFor?: string; /** * Should NFDs reserved for an account be excluded * @default false */ excludeUserReserved?: boolean; /** * The start of an NFD name, fetching multiple NFDs that have that prefix */ prefix?: string; /** * Part of an NFD name, fetching multiple NFDs that have that substring (minimum 3 characters) */ substring?: string; /** * Verified property name to search on - specify value with verifiedValue */ verifiedProperty?: 'blueskydid' | 'discord' | 'telegram' | 'twitter' | 'github' | 'email' | 'domain' | 'nostrpubkey'; /** * Value to find in the verifiedProperty field specified with the verifiedProperty parameter */ verifiedValue?: string; /** * Whether to explicitly filter on segments being locked or unlocked */ segmentLocked?: boolean; /** * Whether to explicitly filter on NFD roots or segments */ segmentRoot?: boolean; /** * Minimum price of NFD in microAlgos */ minPrice?: number; /** * Maximum price of NFD in microAlgos */ maxPrice?: number; /** * Minimum price of NFD Segment in USD (cents) */ minPriceUsd?: number; /** * Maximum price of NFD Segment in USD (cents) */ maxPriceUsd?: number; /** * Fetch NFDs that changed after the specified timestamp */ changedAfter?: string; /** * Return only NFDs with an expiration time at or before the specified timestamp */ expiresBefore?: string; /** * Limit the number of results returned * @default 100 * @maximum 200 */ limit?: number; /** * Starting document offset in large list * @default 0 */ offset?: number; /** * Sort order for results * @default 'createdDesc' */ sort?: 'createdDesc' | 'timeChangedDesc' | 'soldDesc' | 'priceAsc' | 'priceDesc' | 'highestSaleDesc' | 'saleTypeAsc' | 'nameAsc' | 'expiresAsc' | 'expiresDesc'; /** * View of data to return * @default 'brief' */ view?: 'tiny' | 'thumbnail' | 'brief' | 'full'; /** * Set to true to return a never-cached result * @default false */ nocache?: boolean; } /** * Search response */ export declare type SearchResponse = Omit & { nfds: Nfd[]; }; /** * Options for sending assets from a vault */ export declare interface SendFromVaultOptions { /** * Amount to send, in base units of the asset. The amount applies to one * asset, so it can only be given alongside a single asset — passing several * assets sends the full balance of each and closes the vault out of them. * Required when sending ALGO (asset 0), which has no close-out path. * @default 0n */ amount?: bigint; /** * Optional note to include in the transaction */ note?: string; /** * Which account to send to when `receiver` is an NFD name: the NFD's * deposit account, or its vault. Ignored when `receiver` is already an * Algorand address, and an error to combine `'nfdVault'` with one. * @default 'account' */ receiverType?: 'account' | 'nfdVault'; } /** * Options for sending assets to a vault */ export declare interface SendToVaultOptions { /** * Whether to only opt the vault into the asset(s) without transferring * @default false */ optInOnly?: boolean; /** * Amount to send, in base units of the asset. The amount applies to one * asset, so it can only be given alongside a single asset — call * `sendToVault` once per asset to send several. Omit it to opt the vault * into the assets without transferring anything. */ amount?: bigint; /** * Optional note to include in the transaction */ note?: string; } declare interface SerializerOptions { /** * @default true */ explode: boolean; style: T; } declare type ServerSentEventsOptions = Omit & Pick & { /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Implementing clients can call request interceptors inside this hook. */ onRequest?: (url: string, init: RequestInit) => Promise; /** * Callback invoked when a network or parsing error occurs during streaming. * * This option applies only if the endpoint returns a stream of events. * * @param error The error that occurred. */ onSseError?: (error: unknown) => void; /** * Callback invoked when an event is streamed from the server. * * This option applies only if the endpoint returns a stream of events. * * @param event Event streamed from the server. * @returns Nothing (void). */ onSseEvent?: (event: StreamEvent) => void; serializedBody?: RequestInit['body']; /** * Default retry delay in milliseconds. * * This option applies only if the endpoint returns a stream of events. * * @default 3000 */ sseDefaultRetryDelay?: number; /** * Maximum number of retry attempts before giving up. */ sseMaxRetryAttempts?: number; /** * Maximum retry delay in milliseconds. * * Applies only when exponential backoff is used. * * This option applies only if the endpoint returns a stream of events. * * @default 30000 */ sseMaxRetryDelay?: number; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ sseSleepFn?: (ms: number) => Promise; url: string; }; declare type ServerSentEventsResult = { stream: AsyncGenerator ? TData[keyof TData] : TData, TReturn, TNext>; }; declare type SseFn = (options: Omit, 'method'>) => Promise>; declare interface StreamEvent { data: TData; event?: string; id?: string; retry?: number; } /** * Configuration options for suggesting NFD names */ export declare interface SuggestOptions { /** * The buyer's Algorand address (required for eligibility filtering) */ buyer: string; /** * Limit the number of results returned * @default 20 * @maximum 40 */ limit?: number; /** * View of data to return * @default 'brief' */ view?: 'brief' | 'full'; } declare interface TDataShape { body?: unknown; headers?: unknown; path?: unknown; query?: unknown; url: string; } /** * Whether verification was successful */ declare type VerifyConfirmResponseBody = { confirmed: boolean; }; /** * Result of confirming a verification */ export declare type VerifyConfirmResult = VerifyConfirmResponseBody; /** * Field types that can be verified on an NFD */ export declare type VerifyField = 'blueskydid' | 'twitter' | 'github' | 'domain' | 'email' | 'avatar' | 'banner'; /** * Data to use as part of verification */ declare type VerifyRequestResponseBody = { /** * Challenge to be used as part of verification process, with use specific to each field */ challenge: string; /** * ID of challenge, must be used in subsequent confirmation call but may be blank */ id: string; /** * If set, no confirmation is required, the verify call was sufficient */ validated?: boolean; }; /** * Result of starting a verification request */ export declare type VerifyRequestResult = VerifyRequestResponseBody; /** * Wrap a function with error parsing * @param fn - The function to wrap * @returns A wrapped function that parses errors */ export declare function withErrorParsing Promise>(fn: T): (...args: Parameters) => Promise>>; export { }