import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { Connection } from "@solana/web3.js"; const connection = new Connection(process.env.NEXT_PUBLIC_SOLANA_RPC_URL!); export async function extractTxInfo(transactionSignature: string) { const result = await connection.getParsedTransaction(transactionSignature, 'confirmed'); if (!result) { throw new Error('Transaction not found'); } const transferInstruction = result.transaction.message.instructions.find( (instr) => 'parsed' in instr && instr.programId.equals(TOKEN_PROGRAM_ID) ); if (!transferInstruction || !('parsed' in transferInstruction)) { throw new Error('Transfer instruction not found'); } const { info: { amount, authority } } = transferInstruction.parsed; return { authority, amount }; }