Transaction Indexing - Relay

Overview

Relay provides two key APIs for transaction indexing:

API 1: transactions/single

When to Use

Use this API for same-chain actions including:

Note: This is not required for same-chain swaps.

Purpose

API Reference

DocumentationImplementation Reference

Request Example

curl -X POST 'https://api.relay.link/transactions/single' \
  -H 'Content-Type: application/json' \
  -d '{\n  "tx": "{\"from\":\"0x03508bB71268BBA25ECaCC8F620e01866650532c\",\"to\":\"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359\",\"data\":\"0xa9059cbb00000000000000000000000036329d1ff4b31ec85280a86e7cf58fca7c005ed000000000000000000000000000000000000000000000000000000000000f4240\",\"value\":\"0\",\"chainId\":137,\"gas\":\"94464\",\"maxFeePerGas\":\"34643644476\",\"maxPriorityFeePerGas\":\"34180692255\",\"txHash\":\"0x935be17e13f1dc4aee15e75cc9c119f2d639e58b061a54246843f2ddf1052f7c\"}",\n  "chainId":"137",\n  "requestId":"0xcb6bec4106d2bc6f692831e00445f843fa39239ca61bc304486b0c96e1d531a9"\n}'

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

API Reference

DocumentationImplementation Reference

Request Example

curl -X POST 'https://api.relay.link/transactions/index' \
  -H 'Content-Type: application/json' \
  -d '{\n  "txHash": "0x9f2c5e8b1d4a7f0c3e6b9d2f5a8c1e4b7d0a3f6c9e2b5d8a1f4c7e0b3d6a9f2c",\n  "chainId": 8453\n}'

Integration

Call this API immediately after submitting a transaction, before waiting for confirmation.

If you receive a 404 for a freshly broadcast Bitcoin transaction, wait for at least one block confirmation and retry.

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

  1. transactions/single is essential for same-chain operations that aren’t automatically monitored
  2. transactions/index is for accelerating indexing of transactions with internal deposits
  3. Call these APIs immediately after transaction submission for optimal indexing performance
  4. 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.