Integration engineering

A transaction hash is not a successful swap

Use receipt status and actual output evidence to distinguish submitted, mined, successful and economically reconciled swaps.

A transaction hash identifies an attempt. A successful receipt establishes execution success. Neither automatically tells the interface the exact number of output tokens the intended recipient received.

Use separate milestones

Submitted means the application has broadcast evidence. Included means a receipt belongs to a block. Execution successful means the receipt reports success under the chain's transaction rules. Reconciled means the app has associated the resulting asset movement with the intended trade.

EIP-658 defines receipt status for execution success or failure. The JSON-RPC receipt method returns null when a receipt is unavailable; that can be a pending or unknown transaction rather than a final failure.

Find the output carefully

For an ordinary token output, inspect relevant transfer or protocol events and the intended recipient. Complex routes can emit many transfers, so summing every matching log can double count intermediate movement. Native output and unusual token behavior may require different evidence.

Balance differences can help, but concurrent unrelated transfers make them ambiguous. Prefer protocol-specific reconciliation tied to the transaction where possible. Never copy expectedOutput from the quote into an actualReceived field without labeling it as an estimate.

Handle failure without hiding its cost

A reverted transaction can still consume network fees. Record the failed receipt and gas information, while avoiding a claim that token output was delivered. Refresh balances from chain state rather than manually subtracting the entire input based on the old form.

Test successful execution with lower output than estimated, a failed receipt, no receipt and a third-party recipient. A receipt status of success should not cause the tracker to credit the connected account when the output went elsewhere.

Sources & verification (2)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. EIP-658: Embedding transaction status code in receipts

    Receipt success/failure status

    https://eips.ethereum.org/EIPS/eip-658
  2. JSON-RPC API

    Transaction submission, receipt retrieval and transaction fields

    https://ethereum.org/developers/docs/apis/json-rpc/

Continue reading

Swap API integration: quote, approve, simulate, submit