Use an official client
The client libraries for TypeScript, Python and Rust already do most of this checklist: pagination, prepared queries, retries withRetry-After, truncation checks and
amount encoding. If you use one, the items marked (client) are handled for you.
Correctness
Loop on next_block; never assume one response covers your range (client)
Loop on next_block; never assume one response covers your range (client)
maxObjects objects, or the head.
Continue from next_block until it passes the end you want.
PaginationRead the range you got, not the range you asked for
Read the range you got, not the range you asked for
toBlock past the head is lowered silently. Use from_block, to_block and next_block
from the response.Read every Arrow stream, then check the row count (client)
Read every Arrow stream, then check the row count (client)
bl.streams of them, and compare the total
rows with bl.objects to catch a truncated body. Reading ArrowTreat a dropped connection as a failure (client)
Treat a dropped connection as a failure (client)
Handle reorgs near the head
Handle reorgs near the head
finalized_block can change. Either only use finalized rows, or re-read the
unfinalized tail on every poll. Finality and reorgsPad addresses in topic filters
Pad addresses in topic filters
0x + 24 zeros + the address.Parse amounts as big integers
Parse amounts as big integers
value and other amounts are 128-bit (16 bytes in Arrow, decimal strings in JSON). They
overflow 64-bit integers and JavaScript numbers. Data typesResilience
Retry 429, 503, 5xx and network errors with backoff; never retry 4xx blindly (client)
Retry 429, 503, 5xx and network errors with backoff; never retry 4xx blindly (client)
Retry-After. 400, 401, 402 and 403 need a fix, not a retry.Handle unknown_query_id (client) and unknown_set
Handle unknown_query_id (client) and unknown_set
Make jobs resumable
Make jobs resumable
next_block after each page you’ve stored. On restart, continue from it.Alert on 402
Alert on 402
balance_exhausted and overage_limit_reached won’t fix themselves. Page a person, and
check GET /v1/account (free) before large jobs.Log X-Request-Id
Log X-Request-Id
Cost and speed
Use /query (Arrow), not /query/json (client)
Use /query (Arrow), not /query/json (client)
Select only the fields you use
Select only the fields you use
input, data, logsBloom and accessList are large. Use sighash instead of input if you
only need the function. Selecting fieldsFilter on indexed fields as narrowly as you can
Filter on indexed fields as narrowly as you can
Use blockTimestamp instead of a blocks stream
Use blockTimestamp instead of a blocks stream
Use sets and prepared queries for repeated filters (prepared queries: client)
Use sets and prepared queries for repeated filters (prepared queries: client)
Poll at the block time
Poll at the block time
Store finalized data; don't re-read it
Store finalized data; don't re-read it
Read responses promptly
Read responses promptly
Security
Keep keys on servers
Keep keys on servers
Plan key rotations
Plan key rotations
Separate projects for separate services
Separate projects for separate services