【发布时间】:2022-10-06 15:27:04
【问题描述】:
我想得到一个合约地址的待处理交易,我尝试了很多方法但没有奏效
方法1:这似乎擅长对待处理的交易进行排序,但我无法从我的地址获得任何交易,我不知道为什么。请帮我
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)
方法 2:这有助于我从我的地址获取交易,但它获得的所有交易都已确认,而不是待处理
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)
标签: python transactions token web3py pending-transition