feat(samples): add human-present crypto-solana scenario (AP2 + Solana Pay reference binding)#228
Conversation
… Pay reference) Mirrors the crypto-algo scenario but settles on Solana using SPL USDC transfers bound to the AP2 PaymentMandate via the Solana Pay 'reference' pubkey primitive. Reference binding is stronger than memo-based binding (wallet-universal) and stronger than amount uniqueness (deterministic, collision-free). The merchant generates a fresh ed25519 pubkey per checkout, embeds it in the Solana Pay URL as a non-signer account, and resolves the settling tx via getSignaturesForAddress(reference). Scenario is structurally identical to cards/ and crypto-algo/ — PAYMENT_METHOD env var plus the same merchant/credentials-provider/MPP/shopping-agent quartet. Ready to extend with CRYPTO_SOLANA-specific branching in credentials_provider_agent/tools.py when the AP2 core adds a payment method registry entry.
- MD031/MD040: add blank lines + language tags around fenced code blocks - MD030: normalise list markers to single-space (- foo) - MD060: add pad spaces around table pipes for compact style - cspell: declare Solana-specific terms via inline <!-- cspell:words ... --> block (Hedera, Solflare, keypair, mainnet, devnet, ALGOVOI, algv, Helius, Backpack, Triton, Phantom) rather than touching the repo-wide wordlist
There was a problem hiding this comment.
Code Review
This pull request introduces a new sample scenario for human-present transactions using on-chain Solana USDC, including a detailed README on the Solana Pay reference binding mechanism and a shell script to orchestrate the necessary agents. Feedback was provided regarding the order of environment variable sourcing in the startup script to prevent unintended overrides from local configuration files and to improve the robustness of the cleanup process by initializing process tracking earlier.
| export PAYMENT_METHOD=CRYPTO_SOLANA | ||
|
|
||
| AGENTS_DIR="samples/python/src/roles" | ||
| LOG_DIR=".logs" | ||
|
|
||
| if [ ! -d "$AGENTS_DIR" ]; then | ||
| echo "Error: Directory '$AGENTS_DIR' not found." | ||
| echo "Please run this script from the root of the repository." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -f .env ]; then | ||
| set -a | ||
| source .env | ||
| set +a | ||
| fi |
There was a problem hiding this comment.
The PAYMENT_METHOD environment variable is set at line 12, but then .env is sourced at line 25. If the user has PAYMENT_METHOD defined in their .env file, it will override the scenario-specific value (CRYPTO_SOLANA), potentially causing the script to execute with the wrong payment logic. It is safer to source the .env file first and then set scenario-specific overrides. Additionally, initializing the pids array early ensures that the cleanup trap (line 80) is always safe even if the script fails during early setup (e.g., line 20).
| export PAYMENT_METHOD=CRYPTO_SOLANA | |
| AGENTS_DIR="samples/python/src/roles" | |
| LOG_DIR=".logs" | |
| if [ ! -d "$AGENTS_DIR" ]; then | |
| echo "Error: Directory '$AGENTS_DIR' not found." | |
| echo "Please run this script from the root of the repository." | |
| exit 1 | |
| fi | |
| if [ -f .env ]; then | |
| set -a | |
| source .env | |
| set +a | |
| fi | |
| if [ -f .env ]; then | |
| set -a | |
| source .env | |
| set +a | |
| fi | |
| export PAYMENT_METHOD=CRYPTO_SOLANA | |
| AGENTS_DIR="samples/python/src/roles" | |
| LOG_DIR=".logs" | |
| pids=() | |
| if [ ! -d "$AGENTS_DIR" ]; then | |
| echo "Error: Directory '$AGENTS_DIR' not found." | |
| echo "Please run this script from the root of the repository." | |
| exit 1 | |
| fi |
Same pattern as the README inline block; covers ALGOVOI, algv, mainnet, devnet, Helius.
Adds a new human-present A2A scenario:
samples/python/scenarios/a2a/human-present/crypto-solana/.What this adds
A parallel to the existing
cards,x402, and opencrypto-algo(PR #218) scenarios — but settling on Solana using on-chain USDC (SPL Token) with Solana Payreferencepubkey binding for deterministic tx↔mandate correlation.Why
referencebinding matters hereSolana has no native transaction memo field (unlike Algorand / Hedera), and the SPL Memo Program is inconsistently supported across wallets (Phantom exposes it, Backpack and most agentic wallets do not). The canonical Solana Pay primitive for binding a settling transaction to a specific order is a
referencepubkey — a fresh ed25519 public key included as a read-only, non-signer account on the transfer instruction:After settlement, the merchant (or AP2 Merchant Payment Processor Agent) resolves the transaction deterministically via
getSignaturesForAddress(<reference>). This is:For agent-initiated commerce (AP2's core use case), this removes a social trust layer that card and x402 flows don't have to worry about.
Scope of this PR
Minimal and additive. Mirrors the existing
cards/andcrypto-algo/scenario structure:samples/python/scenarios/a2a/human-present/crypto-solana/README.md— full scenario walkthrough + asset table + mandate-chain diagramsamples/python/scenarios/a2a/human-present/crypto-solana/run.sh—PAYMENT_METHOD=CRYPTO_SOLANA+ merchant / credentials-provider / MPP / shopping-agent startup (identical control flow tocrypto-algoandcards)No changes to the Python agent code in
samples/python/src/roles/. Downstream branching onCRYPTO_SOLANAis a natural follow-up once the AP2 core adds a formal payment method registry entry — open to doing that in a follow-up PR once this scenario shell is merged.Assets supported
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vEs9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDUReference implementation
A production AP2 facilitator with Solana Pay reference verification is already live at https://api1.ilovechicken.co.uk (AlgoVoi). The verifier resolves
getSignaturesForAddress(reference), fetches the transaction, confirms SPL mint + amount + recipient against thePaymentMandatecontents, and requires the reference pubkey to appear in the tx's account keys. Source: AlgoVoi-Platform-Adapters (MCP adapter) — happy to share the facilitator's Solana verifier as a separate AP2 core contribution if useful.Relationship to existing PRs
crypto-algo— Algorand/VOI on-chain USDC). Together they cover non-EVM settlement across the two largest non-EVM chains alongside the existing EVM-focusedx402scenario.x402scenario (already merged) +crypto-algo(pending) +crypto-solana(this PR) = full AVM, EVM, and SVM coverage for human-present commerce in AP2.Testing
Run locally:
Happy to sign the Google CLA as per PR #218.