I want to get pending transaction of a contract address, I have tried many ways but didn't work
method 1: this seems to be good at sorting pending transaction but I can't get any transaction from my address, I don't know why. Please help me
def main():
block_filter = web3.eth.filter('pending')
log_loop(block_filter, 0)
def log_loop(block_filter, poll_interval):
while True:
for event in block_filter.get_new_entries():
if web3.eth.getTransaction(event)['from'] == my contract:
print(event)
method 2: this help me to get transaction from my address but all transaction it get is comfirmed, not pending
def main():
block_filter = web3.eth.filter({'fromBlock':'pending','toBlock':'pending', 'address':contract_address}) #this is not working, return nothing
#block_filter = web3.eth.filter({'fromBlock':0,'toBlock':'pending', 'address':contract_address}) #return confirmed transaction, not pending
#block_filter = web3.eth.filter({'fromBlock':'pending','toBlock':'latest', 'address':contract_address}) #return confirmed transaction, not pending
#block_filter = web3.eth.filter({'fromBlock':'latest','toBlock':'pending', 'address':contract_address}) #return error from > to
#block_filter = web3.eth.filter({'address':contract_address}) #return confirmed transaction, not pending
log_loop(block_filter, 0)
def log_loop(block_filter, poll_interval):
while True:
for event in block_filter.get_new_entries():
print(event)