【问题标题】:trouble getting pending transaction receipt for Binance Smart Chain无法获取 Binance Smart Chain 的待处理交易收据
【发布时间】:2022-10-21 18:21:11
【问题描述】:

我无法获得 BSC 链的交易收据。我尝试了 3 种不同的方法,但都失败了。

这是我的代码:

def get_transaction_recipt(txid):
    recipt = web3.eth.getTransactionReceipt(txid)
    print(recipt)

async def get_event():
    async with connect('wss://bsc.getblock.io/mainnet/?api_key=<api-key>') as ws:
        await ws.send('{"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}')
        subscription_response = await ws.recv()
        print(subscription_response)

        while True:
            try:
                message = await asyncio.wait_for(ws.recv(), timeout=60)
                txid = (json.loads(message)['params']['result']) # 

                threading.Thread(target=get_data, args=[txid]).start()
                pass
            except:
                pass
            
if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    while True:
        loop.run_until_complete(get_event())
    

我可以获得新的待处理事务哈希,但调用 get_transaction_recipt 函数时出错

这是错误

web3.exceptions.TransactionNotFound: Transaction with hash: <TransactinHash> not found.

我也试过

web3_pending_filter = web3.eth.filter('pending')
while True:
   transaction_hashes = web3.eth.getFilterChanges(web3_pending_filter.filter_id)

但结果是空列表

我也试过这段代码:

list_of_block_transactions = web3.eth.getBlock('pending', full_transactions=True).transactions
for transaction in list_of_block_transactions:
   get(transaction)

我在块交易列表中得到了最新块交易的列表。没有待处理!!

但是当尝试使用 ETH 区块链时,结果还可以,并返回给我所有的交易收据

【问题讨论】:

    标签: python web3py binance-smart-chain


    【解决方案1】:

    在不查看您的代码的情况下,您似乎试图获取尚未发生的交易的收据。块需要在可用之前关闭。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-08
      • 2021-06-19
      • 2017-07-15
      • 2021-08-03
      • 2021-09-22
      • 2021-07-23
      相关资源
      最近更新 更多