TransactionData
unknown
jsx
2 years ago
1.3 kB
4
Indexable
export const fetchTransactionData = async (senderAddresses, receiverAddresses, userInput) => { const transactionQuery = ` query { ethereum(network: bsc) { transfers( options: { desc: "amount", limit: 100 } sender: { in: ${JSON.stringify(senderAddresses)} } receiver: { in: ${JSON.stringify(receiverAddresses)} } currency: { is: "${userInput}" } ) { transaction { hash } sender { address } receiver { address } amount currency { symbol } external } } } `; const transactionUrl = 'https://graphql.bitquery.io'; const transactionRequestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-KEY': '' // Replace with your actual API key }, body: JSON.stringify({ query: transactionQuery }) }; try { const transactionResponse = await fetch(transactionUrl, transactionRequestOptions); const transactionData = await transactionResponse.json(); return transactionData; } catch (error) { throw new Error('Failed to fetch transaction data from the API'); } };
Editor is loading...