feat(rpc): x402/MPP crypto-micropayment lane for rpc.call#54
Open
johnpmitsch wants to merge 4 commits into
Open
feat(rpc): x402/MPP crypto-micropayment lane for rpc.call#54johnpmitsch wants to merge 4 commits into
johnpmitsch wants to merge 4 commits into
Conversation
The menu selector admits payment amounts as u128, but SPL TransferChecked encodes the amount as a u64. An amount the selector accepted that overflows u64 was silently mapped to a vague "missing/invalid amount" config error. Parse as u128 and narrow explicitly so the overflow surfaces as a clear message. Adds a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a crypto-micropayment payment lane to
rpc.call: pay per RPC request with a stablecoin instead of an account API key, against Quicknode's x402/MPP gateways. The SDK runs the402 -> sign -> resendhandshake, guards against overcharge, and surfaces a typed payment-error hierarchy across all four languages.What's new
payments/payments-svm/payments-tempo): x402/EVM (EIP-712TransferWithAuthorization), x402/Solana (SPLTransferChecked), and MPP/Tempo (native type-0x76tx). Internalenum Signer { Evm, Svm, Tempo }over aSecretStringwith a redactingDebug.api_keyis nowOption(SdkFullConfig::keyless()); the payment lane needs no account key.from_envstays strict.call_with_receiptreturnsRpcCallResponse { result, payment_receipt }.callis unchanged.max_amountis a required spend ceiling (the SDK refuses to sign above it);PaymentIndeterminateon a lost response after paying so callers don't blind-retry into a double charge.PaymentUnsupported/PaymentRejected/PaymentIndeterminatefanned out to the Python/Node/Ruby typed hierarchies (basePaymentError).Examples added (one per language)
Each opens a keyless SDK, configures a
paymentblock onrpc, reads the key fromQN_PAYMENT_KEY(never hard-coded), pays foreth_blockNumberon Base Sepolia testnet, and handlesPaymentIndeterminate/PaymentRejected.Rust —
crates/core/examples/rpc_payment.rsNode/TypeScript —
npm/examples/rpc_payment.tsPython —
python/examples/rpc_payment.py— same shape viaPaymentConfig(...)keyword args,except PaymentIndeterminateError/PaymentRejectedError.Ruby —
ruby/examples/rpc_payment.rb— same shape via a payment hash onrpc:,rescue QuicknodeSdk::Error::PaymentIndeterminateError.Notes
keyfield is readable (likeethers .privateKey). The SDK never prints the key in its own errors/Debug.