Api reference
Filter Events
Filter blockchain events based on specified criteria.
Filter blockchain events based on specified criteria.
Endpoint
POST /filterEventDescription
Filters blockchain events based on specified criteria including event name, contract addresses, block ranges, and field values.
Request Body
{
"contracts": ["0x96AF30413A6999f9948c7c88b0dFf8B56Bf31EF6"],
"eventName": "Transfer",
"eventDef": "event Transfer(address indexed from, address indexed to, uint256 value)",
"fields": {
"from": "0x0000000000000000000000000000000000000000",
"to": ["0x106eB473f541E9485bB428aeC502c2FEa1467779"]
},
"fromBlock": "0x0",
"toBlock": "latest",
"rpc": "https://polygon-amoy.infura.io/v3/{key}"
}Response
{
"requestStatus": 200,
"txHashes": [
"0x81eb1ce8c61a966a1a9ca84bf3701f934977d36e76f5b255c43478a3d59936e0"
]
}Response Fields
requestStatus(integer): HTTP status code of the requesttxHashes(array): Array of transaction hashes containing the filtered events
Example Request
curl -X POST https://api.msa.omnes.tech/filterEvent \
-H "Content-Type: application/json" \
-d '{
"contracts": ["0x96AF30413A6999f9948c7c88b0dFf8B56Bf31EF6"],
"eventName": "Transfer",
"eventDef": "event Transfer(address indexed from, address indexed to, uint256 value)",
"fields": {
"from": "0x0000000000000000000000000000000000000000",
"to": ["0x106eB473f541E9485bB428aeC502c2FEa1467779"]
},
"fromBlock": "0x0",
"toBlock": "latest",
"rpc": "https://polygon-amoy.infura.io/v3/{key}"
}'const response = await fetch('https://api.msa.omnes.tech/filterEvent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
contracts: ['0x96AF30413A6999f9948c7c88b0dFf8B56Bf31EF6'],
eventName: 'Transfer',
eventDef: 'event Transfer(address indexed from, address indexed to, uint256 value)',
fields: {
from: '0x0000000000000000000000000000000000000000',
to: ['0x106eB473f541E9485bB428aeC502c2FEa1467779'],
},
fromBlock: '0x0',
toBlock: 'latest',
rpc: 'https://polygon-amoy.infura.io/v3/{key}',
}),
});
const result = await response.json();
console.log('Found transactions:', result.txHashes.length);import requests
url = "https://api.msa.omnes.tech/filterEvent"
payload = {
"contracts": ["0x96AF30413A6999f9948c7c88b0dFf8B56Bf31EF6"],
"eventName": "Transfer",
"eventDef": "event Transfer(address indexed from, address indexed to, uint256 value)",
"fields": {
"from": "0x0000000000000000000000000000000000000000",
"to": ["0x106eB473f541E9485bB428aeC502c2FEa1467779"]
},
"fromBlock": "0x0",
"toBlock": "latest",
"rpc": "https://polygon-amoy.infura.io/v3/{key}"
}
response = requests.post(url, json=payload)
result = response.json()
print(f"Found transactions: {len(result['txHashes'])}")Use Cases
- Event monitoring: Track specific contract events
- Transaction discovery: Find transactions containing specific events
- Analytics: Analyze event patterns across contracts
- Notification systems: Trigger actions based on events
Best Practices
- Use indexed fields: Filter on indexed event fields for better performance
- Limit block ranges: Use specific block ranges instead of scanning entire chain
- Add event ABIs: Use add event ABI endpoint to register custom events
- Handle large result sets: Paginate results for large event sets
Related Endpoints
- Add Event ABI - Register custom event ABIs
- Get Receipt - Get full transaction details with decoded logs
💡 Tip: Register custom event ABIs using the add event ABI endpoint to filter events from any contract, even if not pre-registered.