3

I am trying to build a bot that listens to events on AMMs for various chains and I am running into issues when trying to build out my algorithm for the avalanche network. When calling the getLogs function for a particular event, the program will randomly crash with the following error

ValueError: {'code': -32000, 'message': 'requested to block ... after last accepted block ...'}

My program is only ever retrieves logs up to the latest block so I am not sure why this error is occurring (I assume it has something to do with the way avax nodes reach consensus).

How can I verify if a block is accepted prior to running getLogs?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Matg
  • 91
  • 6

1 Answers1

0

You have to get ABI of the smart contract and also its address in order to run it.

contract = web3.eth.contract(address=ContractAddress, abi=abi)
my_filter = contract.events.<YOUR_EVENT>.createFilter(fromBlock='latest')
entries = my_filter.get_all_entries()
TylerH
  • 20,799
  • 66
  • 75
  • 101
0xNihilus
  • 9
  • 1