Skip to content

Add an optional payment reference so integrators can reconcile payments #263

Description

@grantfox-oss

Problem

pay() and pay_many() take (from, id, token, amount) and emit SplitPaid { id, token, amount }. There is nowhere to attach an external identifier to a payment.

Why this matters

The product's stated use cases are marketplace sales, royalties, and team payouts. Every one of those needs to answer "which order/invoice/period was this payment for?" Right now an integrator paying a marketplace split for order A-1234 has no way to tag it. Their options are all bad:

  • Match on (amount, ledger) heuristically, which breaks the moment two orders have the same total.
  • Deploy one split per order, which is absurd for storage and defeats reusable routing.
  • Keep the mapping in their own database keyed by tx hash, which they can only learn after submission and which makes the on-chain record useless on its own.

For a payment rail, an unreferenced payment is hard to reconcile, and reconciliation is the whole job on the merchant's side.

Suggested fix

Add an optional reference to the pay path, for example reference: Option<BytesN<32>> (a hash or a padded external id), carried through into the SplitPaid event. Making it a topic would allow filtering by reference in getEvents, at the cost of a topic slot.

Consider whether deposit() should take one too, so escrowed funds can be attributed on the way in as well.

Note: Stellar classic has a transaction memo, but it is per-transaction, not per-operation, so it cannot tag individual splits inside a pay_many batch. That is a good argument for putting the reference in the contract call rather than relying on memos.

Acceptance criteria

  • pay and pay_many accept an optional reference; pay_many allows a distinct reference per split in the batch.
  • The reference appears in the emitted event and is picked up by the indexer and export-csv.mjs.
  • Omitting it is free and fully backward compatible for existing callers.
  • The SDK exposes it as an optional argument.
  • Tests cover: with reference, without reference, and per-split references in a batch.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26enhancementNew feature or requesthelp wantedExtra attention is neededrustPull requests that update rust code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions