Skip to content

initial pilot implementation: 6 Anchor programs#1

Closed
A1igator wants to merge 1 commit into
mainfrom
aliabdoli/initial-pilot-implementation
Closed

initial pilot implementation: 6 Anchor programs#1
A1igator wants to merge 1 commit into
mainfrom
aliabdoli/initial-pilot-implementation

Conversation

@A1igator
Copy link
Copy Markdown
Contributor

@A1igator A1igator commented May 9, 2026

Summary

Adds the full pilot implementation in one commit. Architectural symmetry with base/commerce-payments (so each piece has a one-to-one EVM counterpart) plus x402r-specific extensions on top:

Program Role
auth-capture-escrow Pure escrow primitive (AuthCaptureEscrow analog). 6 lifecycle ixs (authorize/charge/capture/void/refund/reclaim) + 1 admin (initialize_protocol_fee_config). CPIs into ITokenCollector for fund movement.
spl-token-collector The pilot's only ITokenCollector impl. SPL Token transfers for collect_authorize + collect_refund. Future Token-2022 / cross-chain / streaming collectors slot in via the same interface.
payment-operator x402r factory + slot dispatch. Allocates per-merchant OperatorState PDAs at [b"operator", authority] (PDA address IS the operator pubkey). Wraps escrow ixs with pre-action conditions + post-action hooks via invoke_signed.
static-address-condition Generic ICondition reference impl.
receiver-condition Stateless ICondition: outer signer == payment_info.receiver.
payer-condition Stateless ICondition: outer signer == payment_info.payer.

reclaim lives only on the escrow and is called by the payer directly — bypasses the operator program because the deadline-based escape hatch must not be defeasible.

Licensing

  • Every Rust source file carries SPDX-License-Identifier: BUSL-1.1 and // CONTRACTS UNAUDITED: USE AT YOUR OWN RISK (matches x402r-contracts).
  • Every Cargo.toml declares license = "BUSL-1.1".
  • Same BUSL parameters as x402r-contracts: Change Date 2029-12-09, Change License MIT, Hackathon Promotional Rights grant retained.

Layout

programs/auth-capture-escrow      Escrow primitive
programs/spl-token-collector      ITokenCollector for SPL
programs/payment-operator         Factory + slot dispatch
programs/{static-address,receiver,payer}-condition  ICondition impls
tests/                            Vitest + Codama Kit client (TODO bodies)
fuzz/                             Trident fuzz harnesses
migrations/                       Deploy + program-ID pinning
codama/                           Codama generator

Status

Pilot, unaudited. Mainnet usage is at users' own risk.

Things that need to follow before this builds end-to-end:

  • anchor build to produce IDLs (toolchain not installed locally)
  • pnpm codama:generate to swap stubs in the @x402r/svm SDK (companion: @x402r/svm: implement authCapture for SVM (pilot) x402r-scheme#46)
  • Replace placeholder Anchor instruction discriminators with values from target/idl/*.json
  • Fill out the Vitest test bodies (currently expect.fail("TODO") scaffolding covering all flows + error paths)
  • Devnet + mainnet-beta deploy via migrations/deploy.ts + migrations/pin-program-ids.ts

Companion PRs (in x402r-scheme)

🤖 Generated with Claude Code

Faithful SVM port of base/commerce-payments authCapture primitives plus
x402r-specific extensions:

  programs/auth-capture-escrow      AuthCaptureEscrow analog: 6 lifecycle
                                    instructions + protocol-fee config init.
                                    CPIs into ITokenCollector for fund moves.

  programs/spl-token-collector      ITokenCollector for SPL Token. Two
                                    instructions: collect_authorize +
                                    collect_refund. Future Token-2022,
                                    bridge, streaming collectors slot in
                                    via the same interface.

  programs/payment-operator         x402r factory + slot dispatch. One
                                    program acting as factory of per-merchant
                                    OperatorState PDAs (whose addresses
                                    double as paymentInfo.operator). Wraps
                                    escrow ixs with pre-action conditions +
                                    post-action hooks via invoke_signed CPI.

  programs/static-address-condition Generic ICondition reference impl.
  programs/receiver-condition       Stateless ICondition (= payment_info.receiver).
  programs/payer-condition          Stateless ICondition (= payment_info.payer).

Plus tests/, fuzz/, migrations/, codama/ scaffolding.

Architectural symmetry table is in README.md. Spec lives at
x402r-scheme/specs/schemes/authCapture/scheme_authCapture_svm.md.

Pilot, unaudited. Mainnet usage at users' own risk.

Every Rust source file carries SPDX-License-Identifier: BUSL-1.1, matching
x402r-contracts. Each Cargo.toml declares license = "BUSL-1.1".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@A1igator
Copy link
Copy Markdown
Contributor Author

Superseded by the two-PR split for easier review: #2 (base commerce-payments port) and #3 (x402r extensions, stacked on #2). Closing this PR.

@A1igator A1igator closed this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant