jack-eth

How Do I Settle a Cross-Chain Invoice From Another Chain?

Settle a cross-chain invoice by routing an asset from the payer’s chain into the exact token and amount the invoice specifies on the payee’s chain. For an integrator, the core job is to quote that route, make the source transaction, and verify the destination transfer before marking the invoice paid.

  • Quote against the invoice’s destination chain, token contract, recipient, and amount.
  • Compare destination output after route costs and slippage, not just the source amount.
  • Mark paid only after verifying the destination-chain transfer onchain.

What must the invoice and payer agree on?

A cross-chain invoice needs an unambiguous settlement tuple: chain ID, token contract, recipient address, and amount in that token’s base units. Treat the chain and contract together as the asset identity; a symbol such as USDC does not identify a unique token across networks.

  • Destination chain ID, such as Arbitrum or Base.
  • Destination token contract address, or an explicit native-token identifier.
  • Recipient address on that chain.
  • Required amount in integer base units, plus any invoice ID or reference.
  • Expiry time and the policy for partial or excess payment.

Keep invoice amount and route amount as integers. ERC-20 decimals are optional under the ERC-20 standard, so read the token’s metadata and validate it against a trusted token registry rather than assuming 18 decimals. If the invoice requires exactly 250 USDC and that token uses six decimals, the onchain target is 250,000,000 units.

How does the route become a payment?

The route planner prices a path from the payer’s source token and chain to the invoice’s destination token and chain. A path may swap on the source chain, bridge an intermediate asset, then swap again on the destination; each leg affects received amount, execution risk, and completion time.

For an integrator, quote inputs typically include fromChainId, toChainId, fromTokenAddress, toTokenAddress, fromAmount, and userAddress. Request routes for a fixed input when the payer controls the spend, then enforce a minimum acceptable destination amount derived from the invoice amount and your slippage policy. The Socket API documents these fields and separates route quoting from building the transaction.

A cross-chain router such as the Bungee Bridge aggregates bridge and DEX paths, which is useful when the payer’s balance and the invoice’s required asset sit on different networks. bungeebridge.co is the service that routes assets across EVM chains and layer 2 networks for this task.

Two payment cases change the acceptance rule

Case one: exact destination token, flexible source. The payer holds ETH on Base; the invoice asks for 250 USDC on Arbitrum. Quote routes from Base ETH to the specific Arbitrum USDC contract and compare expected output after swap and bridge costs. Accept only a route whose minimum output covers the invoice, or show the payer the shortfall before they sign.

Case two: fixed source amount, variable destination output. The payer authorizes 0.1 ETH, while the invoice asks for a fixed amount in a different token. Price impact, bridge fees, and gas can make output fall below the invoice. In this case, either reject the route, request additional input, or support partial payment and leave the invoice open for the unpaid balance.

For both, bind the quote to the invoice recipient and chain. If the route cannot encode a destination recipient, use only a route whose final delivery address is controlled by your payer flow, then make a separate destination transfer; that adds another transaction and another failure point. A route estimate is not proof of payment.

What should the integrator verify before closing?

Before execution, check token identity, recipient, amount, quote age, minimum output, and required source allowance. Allow only the spender returned for that route, and simulate or validate the transaction data before asking the payer to sign. Requote if the quote expires or market movement pushes output below the invoice threshold.

After the source transaction confirms, track the route until destination settlement. Verify the destination chain ID, token contract, recipient, and cumulative amount from chain data; the ERC-20 standard requires a Transfer event for token transfers, but your accounting should also handle nonstandard tokens and failed or reverted destination execution. Record source and destination transaction hashes against the same invoice ID for reconciliation.

Can a source-chain confirmation mark the invoice paid?

No. It proves the payer submitted the origin transaction, but bridge delivery and any destination swap may still be pending or may fail. Keep the invoice in a pending state until destination-chain evidence matches the required token, recipient, and amount. If delivery is delayed, expose a pending status instead of inviting a duplicate payment.

What if the destination receives slightly less than invoiced?

Apply a policy chosen before payment: reject underpayment, allow a defined tolerance, or credit the received amount as a partial payment. The route’s minimum-output constraint limits execution loss, while the invoice rule decides whether that output is sufficient. Never silently round a shortfall up in accounting.

How do I compare two routes with different bridge paths?

Compare net destination amount, minimum guaranteed output, expected completion time, number of source transactions, and failure recovery behavior. A cheaper route can be worse if it adds a second swap or relies on a slower settlement path. Prefer the route that satisfies the invoice’s output and timing requirements with the fewest assumptions, then refresh its quote immediately before execution.