34 lines
921 B
JavaScript
34 lines
921 B
JavaScript
import { Tool } from "langchain/tools"
|
|
|
|
export class SolanaParseTransactionHeliusTool extends Tool {
|
|
name = "solana_parse_transaction_helius"
|
|
description = `Parse a Solana transaction using Helius API.
|
|
Inputs:
|
|
- transactionId: string, the ID of the transaction to parse, e.g., "5h3k...9d2k" (required).`
|
|
|
|
constructor(solanaKit) {
|
|
super()
|
|
this.solanaKit = solanaKit
|
|
}
|
|
|
|
async _call(input) {
|
|
try {
|
|
const transactionId = input.trim()
|
|
const parsedTransaction = await this.solanaKit.heliusParseTransactions(
|
|
transactionId
|
|
)
|
|
return JSON.stringify({
|
|
status: "success",
|
|
message: "transaction parsed successfully",
|
|
transaction: parsedTransaction
|
|
})
|
|
} catch (error) {
|
|
return JSON.stringify({
|
|
status: "error",
|
|
message: error.message,
|
|
code: error.code || "NOt able to Parse transaction"
|
|
})
|
|
}
|
|
}
|
|
}
|