Transaction Indexing
How to integrate Relay’s transaction indexing APIs
Overview
Relay provides two key APIs for transaction indexing:
- transactions/single - For indexing same-chain transfers, wraps, and unwraps
- transactions/index - For accelerating indexing of transactions with internal deposits
API 1: transactions/single
When to Use
Use this API for same-chain actions including:
- Token transfers
- Token wraps (e.g., ETH to WETH)
- Token unwraps (e.g., WETH to ETH)
Note: This is not required for same-chain swaps.
Purpose
- Ensures same-chain actions are properly indexed
- Relay’s indexer doesn’t actively monitor same-chain actions by default
- Critical for applications supporting same-chain token operations
API Reference
Documentation: https://docs.relay.link/references/api/transactions-single
Implementation Reference: https://github.com/reservoirprotocol/relay-kit/blob/main/packages/sdk/src/utils/transaction.ts#L122
Request Example
API 2: transactions/index
When to Use
Use this API for transactions that contain internal deposits that need to be detected through trace analysis. This is particularly important for teams using their own proxy contracts.
Purpose
- Accelerates the indexing process by triggering indexing before transaction validation completes
- Ensures Relay fetches transaction traces to detect internal deposits
- Recommended for custom proxy contract implementations
API Reference
Documentation: https://docs.relay.link/references/api/transactions-index
Implementation Reference: https://github.com/reservoirprotocol/relay-kit/blob/main/packages/sdk/src/utils/transaction.ts#L113
Request Example
Integration
Call this API immediately after submitting a transaction, before waiting for confirmation.
Decision Matrix
Transaction Type | API Endpoint | Reason |
---|---|---|
Cross-chain transactions | transactions/index | Accelerates indexing before validation |
Proxy contract transactions | transactions/index | Detects internal deposits via trace analysis |
Same-chain swaps | transactions/index | Accelerates indexing and detects internal deposits |
Same-chain token transfers | transactions/single | Not actively monitored by default indexer |
ETH ↔ WETH wraps/unwraps | transactions/single | Same-chain operations need explicit indexing |
Key Takeaways
- transactions/single is essential for same-chain operations that aren’t automatically monitored
- transactions/index is for accelerating indexing of transactions with internal deposits
- Call these APIs immediately after transaction submission for optimal indexing performance
- Choose the appropriate API based on your transaction type using the decision matrix above
For detailed implementation examples, refer to the Relay SDK source code links provided above.