'How to watch all transactions without filter for avalanche smart contract events?
I use the following code and Web3.py to listen for smart contract events but I want to listen for all transactions without a filter so that I can then decode the input data and filter based on methods not events.
def main():
contract = w3.eth.contract(address=A_CONTRACT, abi=A_ABI)
eventFilter = contract.events.EventName().createFilter(fromBlock="latest")
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(asyncio.gather(log_loop(eventFilter, 2)))
finally:
loop.close()
In the Avalanche Smart Contract ABI I have "events" and "functions". For example:
{
"anonymous": false,
"inputs": [
...
],
"name": "StartGame",
"type": "event"
},
...
{
"inputs": [
...
],
"name": "reinforceDefense",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
In Snow Trace Avalanche Blockchain explorer there is a methods column. For example,
Can use any library web3py web3js etc. How do I listen for all transactions to a smart contract (not just specific smart contract events)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

