0

I'm building web-wallet on javascript, and I want to show not only available balance, but also pending amount. From web3js v1.xx documentation I've learned that I can do

web3.eth.subscribe('pendingTransactions' [, callback]);

the problem, however, that this subscription execute callbacks for all transactions from the pool one by one and I couldn't figure out how to filter it for specific address only. subscription.type === 'pendingTransactions' doesn't accept subscription.options = {address:...} as 'logs' does.

My question: is there any way on javascript cheaply (in term of traffic) understand whether there are pending transactions related to the particular address? Both incoming and outcoming. To be able to do something like that:

const spendableBalance = web3.getBalance('0x123456..');
const txs[{txHash: string, from: address, to: address, valueWei: number }] 
          = web3.getPendingTransactions('0x123456..', newStatusCallback)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.