useAddressFromName
Hook for fetching the account address associated with a given name, such as an Aptos name.
Usage
import { useAddressFromName } from "@aptos-labs/react";
export default function App() {
const { data: address, isLoading } = useAddressFromName({
name: "example.apt",
});
if (isLoading) {
return <div>Loading...</div>;
}
return <div>Address: {address?.toString()}</div>;
}
With AptosName
import { AptosName } from "@aptos-labs/ts-sdk";
export default function App() {
const { data: address, isLoading } = useAddressFromName({
name: new AptosName("example.apt"),
});
if (isLoading) {
return <div>Loading...</div>;
}
return <div>Address: {address?.toString()}</div>;
}
Parameters
Return Type
Name | Type | Default |
---|---|---|
data | FetchAddressFromNameResult | undefined The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. | |
error | Error | null The error object for the query, if an error was thrown.
| |
isError | boolean A derived boolean from the
| |
isPending | boolean Will be | |
isLoading | boolean Is
| |
isLoadingError | boolean Will be | |
isRefetchError | boolean Will be | |
isSuccess | boolean A derived boolean from the
| |
isPlaceholderData | boolean Will be | |
status | "error" | "success" | "pending" The status of the query.
| |
dataUpdatedAt | number The timestamp for when the query most recently returned the | |
errorUpdatedAt | number The timestamp for when the query most recently returned the | |
failureCount | number The failure count for the query.
| |
failureReason | Error | null The failure reason for the query retry.
| |
errorUpdateCount | number The sum of all errors. | |
isFetched | boolean Will be | |
isFetchedAfterMount | boolean Will be
| |
isFetching | boolean A derived boolean from the
| |
isInitialLoading | boolean | |
isPaused | boolean A derived boolean from the
| |
isRefetching | boolean Is
| |
isStale | boolean Will be | |
refetch | (options?: RefetchOptions | undefined) => Promise<QueryObserverResult<FetchAddressFromNameResult, Error>> A function to manually refetch the query. | |
fetchStatus | FetchStatus The fetch status of the query.
| |
promise | Promise<FetchAddressFromNameResult> A stable promise that will be resolved with the data of the query.
Requires the |