How to resolve ENS address
Here is how you can resolve ENS address using thirdweb SDK with typescript:
import { resolveAddress } from "thirdweb/extensions/ens";
const address = await resolveAddress({
client,
name: "vitalik.eth",
});
Here is how you can resolve ENS address using thirdweb SDK with React:
We will create a hook for use within our React application. You can use this hook to resolve ENS addresses within your application:
import { client } from "@/consts/client"; // import your thirdweb client
import { queryOptions, useQuery } from "@tanstack/react-query";
import { resolveAddress } from "thirdweb/extensions/ens";
// Get ENS name from a wallet address
export function useResolveENSAddress({
text,
enabled,
}: {
text: string;
enabled: boolean;
}) {
return useQuery(
queryOptions({
queryKey: ["ensText", text || "ensText"] as const,
queryFn: async () => {
if (!client) {
throw new Error("client is required");
}
return resolveAddress({ client, name: text });
},
enabled,
})
);
}
Can’t get this working? If you’ve followed the above and still have issues, contact our support team for help.
Did this answer your question?
😞
😐
🤩