'trouble getting pending transaction receipt for Binance Smart Chain
I can not get transaction receipt for BSC chain. I tried 3 different approaches but I failed.
Here is my code:
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())
I can get new pending Transaction hashes but i get error calling get_transaction_recipt function
this is the error
web3.exceptions.TransactionNotFound: Transaction with hash: <TransactinHash> not found.
I also tried
web3_pending_filter = web3.eth.filter('pending')
while True:
transaction_hashes = web3.eth.getFilterChanges(web3_pending_filter.filter_id)
but the result was empty list
I also tried this code:
list_of_block_transactions = web3.eth.getBlock('pending', full_transactions=True).transactions
for transaction in list_of_block_transactions:
get(transaction)
and I got list of latest block transaction in list_of_block_transactions. NOT PENDINGS!!
but when trying with ETH blockchain the result was ok and returned me with all transaction receipts
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
