Skip to content

Instantly share code, notes, and snippets.

@zhe-t
Last active March 9, 2024 20:23
Show Gist options
  • Save zhe-t/f3c2beb2aac8cc38dfd121dd3054ddc5 to your computer and use it in GitHub Desktop.
Save zhe-t/f3c2beb2aac8cc38dfd121dd3054ddc5 to your computer and use it in GitHub Desktop.
Reserve lookup address for .sol domains
import fetch from "node-fetch";
export interface DomainLookupResponse {
s: string;
result: {
key: string;
domain: string;
}[];
}
export async function getDomainFromAddress(address: string): Promise<string | null> {
const url = `https://sns-sdk-proxy.bonfida.workers.dev/domains/${address}`;
try {
const response = await fetch(url);
const json = await response.json() as DomainLookupResponse;
return json.result[0].domain;
} catch (e) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment