37 lines
911 B
JavaScript
37 lines
911 B
JavaScript
![]() |
import { Tool } from "langchain/tools"
|
||
|
|
||
|
export class SolanaResolveDomainTool extends Tool {
|
||
|
name = "solana_resolve_domain"
|
||
|
description = `Resolve ONLY .sol domain names to a Solana PublicKey.
|
||
|
This tool is exclusively for .sol domains.
|
||
|
DO NOT use this for other domain types like .blink, .bonk, etc.
|
||
|
|
||
|
Inputs:
|
||
|
domain: string, eg "pumpfun.sol" (required)
|
||
|
`
|
||
|
|
||
|
constructor(solanaKit) {
|
||
|
super()
|
||
|
this.solanaKit = solanaKit
|
||
|
}
|
||
|
|
||
|
async _call(input) {
|
||
|
try {
|
||
|
const domain = input.trim()
|
||
|
const publicKey = await this.solanaKit.resolveSolDomain(domain)
|
||
|
|
||
|
return JSON.stringify({
|
||
|
status: "success",
|
||
|
message: "Domain resolved successfully",
|
||
|
publicKey: publicKey.toBase58()
|
||
|
})
|
||
|
} catch (error) {
|
||
|
return JSON.stringify({
|
||
|
status: "error",
|
||
|
message: error.message,
|
||
|
code: error.code || "UNKNOWN_ERROR"
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|