Overview

Relay provides two key APIs for transaction indexing:

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

curl -X POST http://api.relay.link/transactions/single \
  -H "Content-Type: application/json" \
  -d '{
    "tx": "{\"from\":\"0x742d35Cc6634C0532925a3b8d382F4d2d5d9a65e\",\"to\":\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\"data\":\"0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b8d382f4d2d5d9a65e0000000000000000000000000000000000000000000000000de0b6b3a7640000\",\"value\":\"0\",\"chainId\":8453,\"txHash\":\"0x7d1af7f8c6b5e9d4a2f3b8c7e6d9f2a5b4c7e8d1f6a3b9c2e5d8f1a4b7c0e3d6\"}",
    "chainId": "8453",
    "requestId": "0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b"
  }'

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

POST https://api.relay.link/transactions/index
Content-Type: application/json

{
  "txHash": "0x9f2c5e8b1d4a7f0c3e6b9d2f5a8c1e4b7d0a3f6c9e2b5d8a1f4c7e0b3d6a9f2c",
  "chainId": 8453
}

Integration

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

Decision Matrix

Transaction TypeAPI EndpointReason
Cross-chain transactionstransactions/indexAccelerates indexing before validation
Proxy contract transactionstransactions/indexDetects internal deposits via trace analysis
Same-chain swapstransactions/indexAccelerates indexing and detects internal deposits
Same-chain token transferstransactions/singleNot actively monitored by default indexer
ETH ↔ WETH wraps/unwrapstransactions/singleSame-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.