Last active
March 9, 2024 20:23
-
-
Save zhe-t/f3c2beb2aac8cc38dfd121dd3054ddc5 to your computer and use it in GitHub Desktop.
Reserve lookup address for .sol domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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