-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Stellar Blockchain Support #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🟡 Heimdall Review Status
|
|
@marcelosalloum is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
2afc1ca to
ddc1969
Compare
ddc1969 to
be9ecee
Compare
|
FYI: I'm about to rebase this PR on the latest changes (x402 v2) |
be9ecee to
0829fba
Compare
0829fba to
487ebff
Compare
… Still mostly empty.
…DRESS, regexes, etc that will be used across multiple Stellar implementations.
…ervers/express, clients/axios
487ebff to
0e92a9a
Compare
|
Finished rebasing this code to use x402 v2 ✅. This PR is ready for review |
|
Hi @marcelosalloum, thanks a lot for your contribution! The first step for adding a new chain is usually to write a document that outlines the implementation for the exact payment scheme on your chain, see eg for EVM: https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md and the contributing guide https://github.com/coinbase/x402/blob/main/CONTRIBUTING.md#new-chains. Could you please provide such a document for Stellar? The team will then review it and give feedback. Once this is approved, we can proceed with the actual implementation. |
|
@phdargen: cool, thanks for the reply and references. I'll open a PR with the Stellar scheme and we can continue our discussion there. |
Description
This PR adds comprehensive Stellar blockchain support to the x402 (v2) payment protocol, enabling payments using Stellar's Soroban smart contracts alongside existing EVM and Solana implementations. The implementation follows the x402 v2 specification with CAIP-2 network identifiers and modernized protocol structure.
Note
This PR partially addresses the issue #633
Key Implementation Details
Payment Mechanism
Leverages Stellar's SEP-41 through Soroban smart contracts:
invokeHostFunctionoperation for SEP-41 token transfersNetwork Support
CAIP-2 Network Identifiers (per CAIP-28):
stellar:pubnet- Mainnet (requires custom RPC URL configuration)stellar:testnet- Testnet (default RPC: https://soroban-testnet.stellar.org)stellar:*- Wildcard pattern matching all Stellar networksRequired Payment Format
The Stellar exact scheme requires these fields in
PaymentRequirements:Critical field:
extra.maxLedgerOffsetspecifies the number of ledgers to add to the current ledger for transaction expiration. The client fetches the current ledger from RPC and calculates the absolutemaxLedger = currentLedger + maxLedgerOffset. This uses Stellar's ledger-based timeout (not timestamp-based like EVM). Default offset is 12 ledgers ≈ 60 seconds.Dynamic maxLedgerOffset
The facilitator provides a
maxLedgerOffsetvalue (default: 12 ledgers ≈ 60 seconds) that clients use to calculate transaction expiration:{ maxLedgerOffset: 12 }viagetExtra()in the/supportedendpointmaxLedgerOffsetthrough to payment requirementsmaxLedger = currentLedger + maxLedgerOffsetModified Components
TypeScript Packages Updated
TypeScript Packages:
@x402/core(docs),@x402/express,@x402/hono,@x402/next,@x402/fetch,@x402/axiosTypeScript Examples:
facilitator,servers/express,servers/hono,servers/custom,servers/advanced,clients/axios,clients/fetch,clients/customTesting & Quality Assurance
Unit Tests:
test/unit/- 117 tests across 9 test filesIntegration Tests:
test/integrations/- 8 tests across 1 test fileManual Testing
Tested with different combinations of the example applications:
examples/typescript/facilitator- Multi-chain facilitator (EVM + SVM + Stellar)examples/typescript/servers/*- Express, Hono, Next, and custom servers with Stellar routesexamples/typescript/clients/*- Axios, Fetch, and custom clients with Stellar paymentsKey Differences from EVM/SVM
Ledger-Based Expiration
maxLedgerOffsetfor signature expiration timing. Unlike timestamp-based systems, Stellar's smart contracts only support ledger-based expiration boundaries. It defaults to 12 ledgers ≈ 60 seconds (currently).validUntil(Unix timestamp)Auth Entry Signatures
transferWithAuthorizationwith signatureNetwork Configuration
https://soroban-testnet.stellar.org)Asset Decimals
Future Enhancements
Planned for subsequent PRs:
FeeBumpTransactionfor higher throughput and more reliable settlemente2efolder