0

I lunch a geth node in fast mode using geth --testnet --fast and I want to get incomming(pending) value for an account address using web3py, like web3.eth.subscribe('pendingTransactions') in web3js.

I use Filters and this post to set a filter for an address.

web3_filter = web3.eth.filter({'fromBlock': last_block_num - 100, 'toBlock': 'pending', 'address': ADDRESS})

but I can not watch incoming transactions. How I set a watch function to get pending value?

Parse data from txpool can solve the problem.

pending_value = 0
pendings = web3.geth.txpool.inspect()['pending']
for sender_s in pendings:
    detail_info = pendings[sender_s]
    for n in detail_info:
        data_fields = detail_info[n].split(' ')
        receiver = data_fields[0][:-1]
        if receiver == ADDRESS:
            pending_value += int(data_fields[1])

But this solution is not efficient and takes a long time when I use mainnet.

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.