This page will help you get started with Spotter API.
Using JSON-RPC Requests to Access WebSockets
The tg_listen
JSON-RPC method allows you to receive Spotter alerts.
To begin, use /genkey
command in Spotter telegram bot.
Authenticate
Authentication for this API is done using an API key token. The API key token should be included in the endpoint URL using the key
parameter.
wss://api.spotter.pessimistic.io/v1?key=API_KEY_TOKEN
Replace API_KEY_TOKEN
with the actual API key token provided to you.
You can generate new API key in telegram bot by command /genkey
Subscribe to new alerts
Next, prepare to send WebSocket requests to the API. You can use command line tools like wscat
or make requests from your project. Using wscat
, you can send requests as follows:
create subscription request
{
"jsonrpc": "2.0",
"method": "tg_listen",
"params": [],
"id": 1
}
response
{
"result": "0x44110d93799b5ab5",
"id": 1
}
example of incoming alert
{
"tx_hash": "0x35ad6c6f783c5327a52319f1cc8fc8eef0218d83adfa6bdbdda5367c1e0a6705",
"risk_score": "high",
"chain_id": "0x1",
"subscribe": {
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"chain_id": "0x1",
"calls": ["0x06fdde03"],
"funcs": [
"0x095ea7b3",
"0xd0e30db0"
]
}
}
- "tx_hash" - transaction hash
- "chain_id" - transaction chain id
- "risk_score"
-
"medium"or
"high" - "subscribe" - Contract subscribe with which the alert interacts
"address"
"signatures"
"calls"
"funcs"