Skip to content

TRON exact/permit2 facilitator re-broadcasts an already-settled payment when the same payload is resubmitted #122

Open

Description

@eightyun

Summary

@bankofai/x402-tron@2.1.2 (with @x402/core@2.29.0): after a successful settle, the pending-settlement record is deleted, so resubmitting the same payment payload builds and broadcasts a new settlement transaction. On-chain the Permit2 nonce is already consumed, so the transaction reverts — no double transfer, but the facilitator pays the energy/bandwidth fee for every replay.

Resource servers and clients legitimately retry the same PAYMENT-SIGNATURE after timeouts or ambiguous responses, so this turns ordinary retries into fee loss for the facilitator account.

Reproduction (Nile)

  1. Run the exact/permit2 facilitator (x402Facilitator + ExactTronScheme with createFacilitatorTronSigner).
  2. Settle a valid Permit2 payload → success: true, tx e6f7d422… (SUCCESS).
  3. Within the same process, call settle again with the identical payload and requirements.
  4. A second transaction is broadcast: 4a491674… → REVERT, 10,430 energy, 1.71 TRX fee; response errorReason: "invalid_transaction_state".

Cause

In the pending-settlement wrapper, a successful result deletes the record:

if (terminal || result.success || ...) {
  await this.store.delete(key);
  this.fallback.delete(key);
}

A later request with the same key finds no record and goes through submitPermit2Settlement again. There is no check that the Permit2 nonce is still unused (or a simulation) immediately before writeContract.

Suggestions

  • Keep a terminal record for successful settlements (at least until the authorization deadline) and return the original transaction on replay, or
  • Check the Permit2 nonce bitmap / simulate settle before broadcasting and fail without broadcasting when the nonce is spent.

Related observations (may be intentional)

  • The settle response reports payer as the 0x signing-form address from permit2Authorization.from rather than the TRON base58 address, and omits amount. Clients comparing receipts against the configured base58 payer need to account for this.
  • success: true is returned once the transaction is packed; at that moment the solidity node does not yet return the transaction. Documenting that success means "packed", not "solidified", would help integrators decide when to deliver.

Found while testing interoperability from a Go x402 client (https://github.com/eightyun/x402-tron-go). Happy to provide more detail.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions