I am tring to get all holders of a particular contract through web3.py library.For RPC I am using infura.
the code is:
contract = web3.eth.contract(address=address,abi=abi)
name = contract.functions.name().call()
print(name)
def holdersEvent(_fromBlock, _toBlock):
try:
transferEvents = contract.events.Transfer.createFilter(fromBlock=_fromBlock, toBlock=_toBlock)
for i in range(len(transferEvents.get_all_entries())):
addressTo = transferEvents.get_all_entries()[i].args.to
print(addressTo)
except error:
#holdersEvent(_fromBlock, _toBlock)
print(_fromBlock," ",_toBlock)
latest = web3.eth.blockNumber
firstBlock = web3.eth.getTransactionReceipt(tx_hash).blockNumber
totalResult = latest - firstBlock
initial = firstBlock
if totalResult >2000:
while totalResult>=2000:
fromBlock = initial
toBlock = initial +2000
holdersEvent(fromBlock,toBlock)
totalResult = totalResult -2000
initial = toBlock
if totalResult != 0:
fromBlock = initial
toBlock = initial + totalResult
holdersEvent(fromBlock,toBlock)
else:
holdersEvent(firstBlock,latest)
under this I am facing the error as
ValueError: {'code': -32000, 'message': 'filter not found'}
How do I resolve this?