96 Commits

Author SHA1 Message Date
Ryan R. Fox
e35becffdc
refactor(paywall): tighten faucet refactor per forensic review + SVM-dev framing (#2160)
Address forensic review-quorum findings and conform SVM paywall to upstream pattern:

- Drop dead solana:TESTNET FAUCET_URLS entry (Circle faucet does not
  dispense USDC on Solana Testnet; Option B renders "No faucet configured."
  for any unmapped chain).
- Revert all Solana Testnet recognition added by prior refactor pass
  (SOLANA_NETWORK_REFS.TESTNET constant, getNetworkDisplayName branch,
  isTestnetNetwork OR-branch). The paywall now recognizes one non-mainnet
  SVM network — Devnet — matching upstream/main. No SVM dev expects
  paywall Testnet support; upstream doesn't provide it.
- Unify "Need {tokenName} on {chainName}?" copy in SolanaPaywall and
  AvmPaywall payment-required headers (were hardcoded "USDC"; matches
  EvmPaywall).

Closes #2159
2026-05-16 18:15:13 +02:00
phdargen
92f23c21a1
bump next (#2313)
* bump next

* changeset

* fix format

* fix lint

* fix paywall
2026-05-15 20:01:11 +02:00
nora.noh
114b6b19bb
feat(evm): add HPP mainnet (chain ID 190415) and HPP Sepolia (chain ID 181228) support with USDC.e (#2309)
Add USDC.e (Bridged USDC) as the default stablecoin for HPP mainnet
(chain ID 190415) and HPP Sepolia (chain ID 181228) across all three SDKs:

- TypeScript: DEFAULT_STABLECOINS map in @x402/evm + regenerated NETWORK_DECIMALS in @x402/paywall
- Go: ChainIDHPP / ChainIDHPPSepolia constants, NetworkConfigs entries
- Python: NETWORK_CONFIGS dict in x402.mechanisms.evm

Contract details (verified on-chain):
- Token: USDC.e (Bridged USDC, FiatTokenV2_2)
- Address: 0x401eCb1D350407f13ba348573E5630B83638E30D (identical on both networks)
- EIP-712 domain: name="Bridged USDC", version="2"
- Decimals: 6
- EIP-3009: transferWithAuthorization supported

Chain details:
- HPP is an Arbitrum Orbit L2 operated by the HPP team
- Mainnet (190415): https://mainnet.hpp.io | Explorer: https://explorer.hpp.io
- Sepolia (181228): https://sepolia.hpp.io | Explorer: https://sepolia-explorer.hpp.io
- Portal: https://portal.hpp.io

USDC.e is the official bridged USDC issued by HPP, submitted by the HPP chain
team (chain-endorsed asset per DEFAULT_ASSETS.md).
2026-05-15 12:12:02 +02:00
phdargen
9a718b002d
Fix py publishing (#2295)
* fix uv build

* exclude-newer = 3 days
2026-05-13 22:37:58 +02:00
phdargen
a24dc9437d
chore: version python package (#2293) 2026-05-13 17:33:27 +02:00
phdargen
dd6d7e6fc2
Harden workflows (#2287)
* add --ignore-scripts

* update to pnpm 11 and node 22

* align dep

* fix axios headers

* pin workflow actions

* fix paywall

* remove cache from publishing

* add hedera publishing

* remove e2e workflow

* increase minminimumReleaseAge to 3days
2026-05-13 17:33:05 +02:00
Vedant Anand
8eee9646af
fix(python): use named constants for erc20-approval gas fee defaults (#2278)
The Permit2 erc20-approval client was hardcoding 1_000_000_000 / 100_000_000
as gas fee fallbacks. TypeScript already exposes these as
DEFAULT_MAX_FEE_PER_GAS / DEFAULT_MAX_PRIORITY_FEE_PER_GAS in evm/constants;
add the matching Python constants and use them. No behavior change.

Also adds the first unit tests for sign_erc20_approval_transaction covering
the fallback and successful estimate paths.
2026-05-13 14:36:04 +02:00
Ryan R. Fox
ee7c1562d0
chore: bump viem floor to ^2.48.11 across monorepo + refresh lockfiles (#2242)
Tightens the viem floor in every package.json that lists viem (41 refs
across 40 files), refreshes all three lockfiles so every direct viem
resolution reads 2.48.11, and regenerates the paywall bundled templates
so the EVM/SVM/AVM bundles match the new viem chain database.

## Why floor-tightening matters

PR #2013 bumped lockfiles to 2.47.14, but later PRs (#2061, #2197, ...)
added sub-packages with ^2.39.x / ^2.43.x floors. pnpm re-resolved on
subsequent installs and the solver picked the lowest acceptable version
across constraints. ^-ranges with low floors do NOT preserve a bump --
lockfile refreshes erode the floor.

This PR fixes that incomplete tightening from #2013 by raising every
floor to ^2.48.11. The same regression will recur if any future PR adds
a viem-using sub-package with a lower floor. Gate criterion: new
packages must use ^2.48.11 (or tighter) for viem.

## Acceptance verification

- pnpm install --frozen-lockfile clean across typescript/,
  examples/typescript/, and e2e/.
- pnpm format:check, lint:check, build, test green for typescript/.
- pnpm format:check, lint:check green for examples/typescript/.
- All direct viem resolutions read 2.48.11 in all three workspaces.
- Paywall bundled templates regenerated via
  pnpm --filter @x402/paywall run build:paywall.
2026-05-08 16:19:24 +02:00
Аркадий Стена
e0ba324d0f
feat: add TVM exact-payment mechanism to Python SDK (#1944)
* feat: add TVM exact-payment mechanism to Python SDK

- add TVM exact client, server, and facilitator implementations
- add TVM signers, codecs, provider, and settlement helpers
- add unit and integration coverage for TON testnet/mainnet flows
- add Python examples and e2e wiring for TVM

* Enable TVM exact flows in Python e2e and tighten facilitator validation

Add TVM support to the Python e2e clients and servers, switch TVM usage to direct `ExactTvm*Scheme` registration after removing the old register helpers, and refresh docs/examples for testnet setup.
Also reject exact TVM settlements with excessively large attached TON amounts and cover the new validation with tests.

* fix: clarify minimum balance of the facilitator

* refactor(tvm): release settlement cache entry on confirmed settlement

  On-chain seqno advances after a successful relay, so any retry of the same settlement BOC will fail at the W5 contract's seqno check regardless of the dedup reservation. Drop the entry as soon as the confirmation worker records success, so the invariant becomes "every is_duplicate=False is paired with a release" and TTL pruning is left as a crash safety-net only.

* feat(tvm): add TonAPI provider support

* feat(tvm): update e2e tests  to make them compatible with new providers

* fix(tvm): update timeouts

* fix(tvm): increase http client timeout

* fix(tvm): align unit tests

* revert(e2e): remove .env-local config load

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 16:13:22 +02:00
Ethan Oroshiba
d235050d95
feat: log bazaar EXTENSION-RESPONSES header in resource servers (#2161)
* add extension responses header logging

* add changelogs and log whole sanitized header

* remove envelope attachment

* use list instead of map

* update changelog entries

* add facilitator examples
2026-05-07 18:03:04 +02:00
Tyler Frederick
e7150b3601
feat(evm): add Radius Network and Radius Testnet SBC as default stablecoin (Permit2 + EIP-2612) (#2038)
* feat(evm): add Radius Network and Radius Testnet default stablecoin (Permit2 + EIP-2612)

Add SBC as the default stablecoin for Radius Network (eip155:723487)
and Radius Testnet (eip155:72344) across Go, TypeScript, and Python SDKs.

SBC does not support EIP-3009, so Permit2 is the required transfer
method. SBC does support EIP-2612 permit() for gasless approval.

* docs: add Radius default-stablecoin entries to user-facing docs

* chore(paywall): update generated Radius decimals
2026-05-07 12:56:42 +02:00
pc_club_builder
3f1cd58e70
fix(python): exclude MCP tests from wheel (#2155) 2026-05-07 12:38:37 +02:00
aayushijain-cb
608034f15a
feat: add service metadata on resource to all 3 SDKs (#2200)
* docs: add repo move note to README (#40)

* add service metadata on resource to all 3 SDKs

* lint

* changelog

* review: harden iconUrl validators + tighten signatures

* review: constrain serviceName/tags to printable ASCII

* add checks to harden iconurl + tag/name validators

* update v2 spec + python lint

* python format

---------

Co-authored-by: Ash <105402607+Must-be-Ash@users.noreply.github.com>
2026-05-06 14:13:33 -04:00
phdargen
45d7d19250
Batch-settlement TS sdk (#2061)
* spec + sdk

* add auto recover and topUp; add filestorage

* add session manager

* fix nonce reset

* add cooperativeWithdraw to spec/contract

* add cooperative withdraw to sdk

* update sdk to match spec v1.2

* change to auto-generated getters

* improve server devx

* improve client devx

* added concurrent request example

* minor fixes

* add cas

* add streaming example

* rename files to batched*

* updated scheme name deferred -> batched

* update to new contracts

* align paymentresponse.extra for all payloads

* fix recovery after refund

* fix withdraw -> refund flag

* fix channel manager

* rename to batch-settlement

* align with cloudflare specs

* remove claim/refund without sign

* add tx sim

* improve specs

* specs ready

* add unit/integration tests

* fix tests

* improve typing, remove dead code

* add readmes

* add e2e tests

* fix fileStorage

* increase depositMultiplier for streaming

* refund without paid request

* refactor convertToTokenAmount

* refactor scheme

* fix recovery for refund flow

* refactor client scheme

* rename session -> channel

* remove chargedCumulativeAmount from deposit payload

* scheme hook adapters

* add enrichSettlementPayload/enrichSettlementResponse hooks

* move batch-settlement scheme to scheme hook adapters and enrichSettlementResponse

* refactor refund and other payloads

* add client hook adapters

* align payment-response shapes

* move corrective 402 info from errorDetails to requirements.extra.channelState

* fix corrective deposit flow

* update to latest deployment and change channelId computation to EIP-712

* add hook to handle route handler failures

* add atomic channel update and request context primitives

* guard channels with pending reservations

* fix concurrent claim/settle

* skip facilitator and verify locally if onchain state fresh

* add redis storage

* add fullstack next example with redis and fix settlementOverride for next package

* align payment-response for all payloads

* add permit2 support and fix extra enrichment for nested objects

* fix DEPOSIT_WITNESS_TYPE_STRING

* test client state-loss recovery scenario in e2e

* fix recovery for axios

* improve channel manager

* update client deposit policy

* clean up examples

* add to testnet facilitator

* update READMEs

* for the culture

* add changesets

* update to latest deployment

* align error codes

* remove receiverAuthorizer fallback
2026-05-04 16:43:57 -04:00
Ethan Oroshiba
7ec7815257
feat(bazaar): update WithBazaar SDK wrappers with search, unified auth, and Python alignment (#2094)
* update withBazaar

* Fix bazaar MCP discovery parity across TS/Python/Go; tighten e2e validation; update docs/examples.

* python format

* remove formatting-only changes

* remove formatting-only changes

* reinstate old comments

* clean up response shape

* revert pagination to object instead of top level fields

* address review comments
2026-04-30 02:19:09 +09:00
phdargen
af26d09182
chore: version python package (#2149) 2026-04-28 01:43:06 +09:00
Ryan R. Fox
484030b21e
chore(paywall): regenerate bundle + add recurrence guard (#2054)
The committed @x402/paywall bundle on main was last generated against an
older viem than the lockfile currently pins. pnpm install --frozen-lockfile
resolves viem 2.47.12 (via #2013), but the bundled src/evm/gen/template.ts
(and its Python + Go siblings) were built against an earlier resolution
that pre-dated chain definitions for Mezo, MegaETH, Stable, Radius (each
with a testnet variant), and 33 others. EvmPaywall.tsx throws
"Unsupported chain ID" at init for any eip155:<id> whose chain isn't in
the bundled viem/chains.

This PR:
  1. Regenerates all nine auto-generated template files (TypeScript,
     Python, and Go for EVM/SVM/AVM) against the current lockfile. No
     source changes on any runtime path.
  2. Teaches build:paywall to emit output matching the repo's formatters
     (prettier / ruff), so generated files stay clean under pnpm run
     format + uvx ruff format.
  3. Adds a PR-time drift check
     (.github/workflows/check_paywall_template.yml) so a future lockfile
     or @x402/evm change that invalidates the bundle fails loudly
     instead of shipping silently.

Scope is limited to @x402/paywall because it is the only package in this
repo that bakes viem chain definitions into a built artifact.

Verified on a fork-internal test PR running on ubuntu-latest
(Node 24, pnpm 10.7.0): check_format, check_lint, check_go, check_python,
check_package_lock, and the new check_paywall_template drift check all
pass. Additional local evidence:

  - Chain-presence in regenerated bundle: Mezo 31612/31611, MegaETH
    4326/6343, Stable 988/2201, Radius 723487/72344, Base/Arbitrum/
    Polygon all present (mainnet/testnet ordering).
  - Cross-platform determinism: a clean-slate rebuild on macOS produces
    byte-identical output to ubuntu-latest CI.
  - Tarball install into a throwaway consumer: all expected chain IDs
    present in the published dist/esm/evm/index.js.
  - Browser smoke test (Chrome, served from a local HTTP server):
    EvmPaywall mounts without Unsupported-chain throw for
    eip155:31611 (Mezo Testnet) and eip155:723487 (Radius); DOM
    renders the expected token/chain labels.

Fixes #1971.
2026-04-26 22:47:13 +09:00
Ryan R. Fox
032295b8ce
fix(paywall): use dynamic token decimals instead of hardcoding 6 (#1980)
* fix(paywall): use dynamic token decimals instead of hardcoding 6

The EVM paywall displays incorrect amounts for any token that does not
use 6 decimal places. An 18-decimal token priced at 0.001 raw units
renders as $1,000,000,000 because the code divides by 10^6 everywhere.

Root cause: the paywall was built assuming USDC (6 decimals) is the
only payment token. This assumption appears in three places:

1. Server-side HTML generation (index.ts) divides the raw amount by
   a hardcoded 10^6 to produce the display value injected into the
   template.

2. Client-side balance display (EvmPaywall.tsx) calls formatUnits
   with a hardcoded 6 and reads the token address from a 3-chain
   USDC lookup table that returns 0 for any other chain.

3. The balance utility (utils.ts) only knows USDC addresses on
   Ethereum, Base, and Base Sepolia — every other chain silently
   shows a zero balance.

Fix:

Server-side (index.ts): look up the token's decimal precision from a
known-decimals map aligned with DEFAULT_STABLECOINS. Only non-6-decimal
chains need entries; everything else falls back to 6. This keeps the
server-side path simple with no RPC calls.

Client-side (EvmPaywall.tsx): read the token contract address from
the payment requirement's `asset` field (which the server already
populates) and query the standard ERC-20 decimals() function on-chain.
This works for any compliant token without maintaining a lookup table.

utils.ts: replace the USDC-specific getUSDCBalance (internal helper,
not part of the public API) with generic getTokenBalance and
getTokenDecimals functions that accept a token address parameter.
The function signature changes from 2 args to 3, but no external
consumer can import it — it is only used by the bundled React
component inside the paywall HTML template.

**Breaking change note:** the internal helper getUSDCBalance in utils.ts
is removed and replaced by getTokenBalance (different signature: takes
an explicit token address instead of looking it up by chain ID). This
function is not exported from the package's public API — it is only
consumed by the bundled EvmPaywall React component inside the paywall
HTML template. No server operator code calls it directly. However,
anyone who has forked the paywall and imports from the file path
(bypassing package exports) would need to update their import and
call site.

Regenerated Go, Python, and TS paywall templates.

**AI disclosure:** This PR was prepared with the assistance of a coding agent and
reviewed by Ryan R. Fox (an actual human) before submission.

* style: ruff format paywall templates

* fix(paywall): use DEFAULT_STABLECOINS lookup + BigInt formatUnits

Removes the parallel KNOWN_DECIMALS map in @x402/paywall/src/evm/index.ts
that mirrored DEFAULT_STABLECOINS from @x402/evm. The paywall now resolves
token decimals through the same registry that scheme implementations and
@x402/core's inline scheme dispatch already read from.

evmPaywall.generateHtml changes:
  * getDefaultTokenDecimals helper looks up requirement.network directly in
    @x402/evm's DEFAULT_STABLECOINS, with a 6 (USDC default) fallback when
    the network is unknown.
  * Atomic-to-display conversion uses Number(formatUnits(BigInt(amount),
    decimals)) instead of parseFloat(amount) / 10**decimals. parseFloat
    silently rounds sub-cent precision on real 18-decimal amounts before
    the divide; BigInt + formatUnits preserves precision through the
    conversion. BigInt also rejects non-integer atomic strings, which
    matches the spec's atomic-integer contract.

@x402/paywall package.json: @x402/evm moves from devDependencies to
dependencies because the new server-side import of DEFAULT_STABLECOINS is
on the runtime path emitted into dist/.

@x402/evm now publicly re-exports DEFAULT_STABLECOINS from
./shared/defaultAssets so consumers can read the canonical default-asset
registry directly. Both @x402/evm and @x402/paywall get a minor bump
for the additive public API.

Adds 6 unit tests:
  * getDefaultTokenDecimals returns 18 for Mezo Testnet (registry path)
  * getDefaultTokenDecimals returns 6 for Base mainnet, asserted alongside
    DEFAULT_STABLECOINS so an empty registry would fail the test
  * getDefaultTokenDecimals falls back to 6 for unknown networks
  * evmPaywall.generateHtml renders 1e15-atomic Mezo mUSD as
    'amount: 0.001,' end-to-end (regression test for the /1e6 bug)
  * evmPaywall.generateHtml renders 1e6-atomic Base USDC as 'amount: 1,'
  * evmPaywall.generateHtml throws on a non-integer atomic ('1.5'),
    pinning the BigInt strictness so a future revert to parseFloat fails

Closes #1979.

* refactor(paywall): generate evm decimals at build time, drop @x402/evm runtime dep

Addresses @phdargen's review: rather than promoting @x402/evm to a
runtime dependency of @x402/paywall, keep it a devDependency and
emit a codegen'd `src/evm/gen/decimals.ts` that mirrors just the
per-network `decimals` field of `DEFAULT_STABLECOINS`.

Pattern-consistent with the existing `src/evm/gen/template.ts` codegen
(HTML bundle) — same build step (`src/evm/build.ts`), same "AUTO-GENERATED
DO NOT EDIT" banner, same commit-the-generated-file workflow. The CI
drift check queued in #2054 (`check_paywall_template.yml`) will pick up
`decimals.ts` under the existing `typescript/packages/http/paywall/**`
trigger glob once that PR merges; in the meantime an in-process drift
invariant test in `network-handlers.test.ts` asserts `NETWORK_DECIMALS`
matches `DEFAULT_STABLECOINS` key-for-key.

Runtime behaviour is unchanged. `getDefaultTokenDecimals` now reads the
generated `NETWORK_DECIMALS` map instead of reading `DEFAULT_STABLECOINS`
at runtime; the same Mezo-18, Base-6, unknown→6 cases still hold, and
the existing 6 regression tests in `network-handlers.test.ts` pass
without modification. A seventh test pins the drift invariant described
above.

package.json: `@x402/evm` moved from `dependencies` to `devDependencies`.
Runtime module graph for `@x402/paywall` no longer pulls `@x402/evm`;
the only surviving `@x402/evm` references in paywall src are:
  * `browserAdapter.ts` — `import type { ClientEvmSigner }` (type-only,
    erased at build time)
  * `EvmPaywall.tsx` — `ExactEvmScheme` (bundled into `gen/template.ts`
    by esbuild, not part of the server-side runtime path)
  * `build.ts` and `network-handlers.test.ts` — build-time / test-time
    consumers; devDep is available in both.

Both the root `typescript/pnpm-lock.yaml` and `examples/typescript/pnpm-lock.yaml`
are updated to reflect the dep move — both workspaces reference the
paywall package manifest via `workspace:~`.
2026-04-26 13:57:49 +09:00
Ethan Oroshiba
71a223d35a
feat: add MCP Bazaar discovery support across TypeScript, Python, and Go SDKs (#2087)
* add mcp discovery support

* ci fixes and changelog

* rename changelog

* fix failing test

* fail in TS on transport mismatch, return extension info on settlement failure in python

* add e2e

* fix mcp payment payload parsing

* fix python parsing

* add transport to examples and docs
2026-04-22 11:50:32 -07:00
Ryan R. Fox
5543700fd7
docs: add Documentation Checklist + surface chain-contribution flow (#2049)
* docs: add Documentation Checklist + surface chain-contribution flow

DEFAULT_ASSETS.md's 'Adding a New Chain' numbered flow stopped at 'Update
all three SDKs' → 'Submit a PR' and did not mention the user-facing docs
surfaces that also enumerate every chain with default-asset support. As a
result, recent onboarding PRs have shipped with stale docs (e.g. the
Radius PR #2038 updated the SDKs but not the docs table or Go README).
The existing Cross-SDK Checklist at the bottom enumerates only the three
code registries, mirroring the same gap.

network-and-token-support.mdx has a parallel discoverability problem:
the pointer to DEFAULT_ASSETS.md used a repo-relative path that resolves
to a broken link on docs.x402.org, and the pointer sat inside the
'Default Assets for Dollar-String Pricing' intro rather than under
'Adding Support for New Networks' where a would-be contributor actually
looks. The 'Adding' section itself described only runtime registration
(server.register from consumer code) and did not mention the separate
upstream-contribution path, and it also contained a 'Running Your Own
Facilitator' subsection that is about facilitator infrastructure, not
about adding networks — a topical mismatch. The page also ordered the
'Facilitators' section before 'Adding Support for New Networks', which
inverts the natural read → use → extend → operate narrative.

Changes:

  * DEFAULT_ASSETS.md:
      - Promote 'Update user-facing documentation' to a numbered step in
        'Adding a New Chain' (new step 3, between 'Update all three SDKs'
        and 'Submit a PR'), with a cross-reference to the new checklist.
      - Append a new 'Documentation Checklist' section below the existing
        Cross-SDK Checklist, naming the two hot docs surfaces
        (network-and-token-support.mdx and go/mechanisms/evm/README.md)
        that must also be updated on a new chain onboarding.

  * docs/core-concepts/network-and-token-support.mdx:
      - Remove the oddly-placed 'See DEFAULT_ASSETS.md' link from the
        Dollar-String Pricing intro; replace with an in-page anchor
        pointing at the new contribution subsection.
      - Split 'Adding Support for New Networks' into two subsections:
        'Runtime Registration' (the existing content, unchanged) and
        a new 'Contributing a New Default Asset' subsection that links
        to DEFAULT_ASSETS.md via an absolute github.com URL (so the
        link works on the published docs site) and explicitly names
        the cross-SDK + docs checklist.
      - Move 'Running Your Own Facilitator' out of 'Adding Support for
        New Networks' into the existing 'Facilitators' section, where
        it belongs topically.
      - Swap top-level section order: 'Adding Support for New Networks'
        now precedes 'Facilitators', matching the read → use → extend →
        operate narrative.

No code changes. Documentation only.

* docs: revert DEFAULT_ASSETS.md, unify SDK READMEs to link docs

Address review feedback: the Mintlify agent (.github/workflows/update-docs.yml)
keeps docs/ in sync with code, so contributors should only update the three SDK
constants files. Remove the Documentation Checklist and Step 3 from
DEFAULT_ASSETS.md. Apply a consistent two-link block to all three SDK READMEs
(Go/TS/Python) pointing at the mdx default-assets list and the mdx
Adding Support for New Networks section. Soften the mdx Contributing a New
Default Asset blurb to drop manual mdx/README update instructions.
2026-04-21 12:45:06 +09:00
Carson Roscoe
b7db1d155c
chore: version python package (#2064) 2026-04-17 10:51:10 -07:00
Ethan Oroshiba
6991456a67
Map simulation and settlement failures to more detailed errors (#2062)
* map errors

* fix ci

* update python

* fix python ci
2026-04-17 10:47:19 -07:00
Carson Roscoe
c284d0d8ce
feat: upto evm python (#2023)
* feat: add upto to python SDK

* feat: add unit & integration tests

* feat: add upto python clients/servers/facilitator to e2e suite

* initial cleanup

* implement partial settlement

* improve parity with ts/go

* better parity and fix tests

* fix(python): sort imports and format test file to pass ruff lint

New error constants were appended after ERR_UNSUPPORTED_SCHEME instead
of in alphabetical order, causing I001 (import block un-sorted).

Made-with: Cursor

* add comment to e2e tests

* fix failing integration test

* changelog

* fix changelog name

---------

Co-authored-by: Ethan Oroshiba <ethan.oroshiba@gmail.com>
2026-04-16 12:38:54 -07:00
phdargen
b1176d302b
remove legacy examples (#1356)
* remove legacy examples

* add deprecation note
2026-04-14 07:57:19 -07:00
phdargen
db164fee84
chore: version python package (#2020) 2026-04-14 02:00:05 +09:00
Misha Kolesnik
077b294ce1
feat(svm): implement extra.memo support for exact scheme (#1688)
Implement the spec change from PR #1682, adding optional seller-defined
memo support to the SVM exact scheme across all three SDKs.

Client changes (TypeScript, Go, Python - both v1 and v2):
- When extra.memo is present, use its UTF-8 value as memo instruction data
- When absent, fall back to existing random 16-byte nonce behavior
- Validate memo does not exceed MAX_MEMO_BYTES (256) limit

Facilitator changes (TypeScript, Go, Python - both v1 and v2):
- When extra.memo is present in requirements, verify exactly one memo
  instruction exists and its data matches the expected value
- Return specific error codes: memo_count / memo_mismatch

Constants added:
- MAX_MEMO_BYTES / MaxMemoBytes (256) across all languages
- ERR_MEMO_MISMATCH, ERR_MEMO_COUNT (Python/Go)
- ErrMemoExceedsMaxSize (Go client)

Tests added:
- TypeScript: 4 memo tests in duplicateTx.test.ts
- Go: TestSellerMemo with 4 subtests in duplicate_tx_test.go
- Python: TestSellerMemo class with 4 tests in test_duplicate_tx.py

Closes #1682
2026-04-13 17:32:44 +09:00
Ryan R. Fox
37b83471b1
fix(paywall): read token name from payment requirements instead of hardcoding USDC (#1973)
The EVM paywall hardcodes "USDC" as the token label in all display
text. The payment requirements already carry the token name in
extra.name (populated by the server from the default asset registry),
but the paywall ignores it.

Read extra.name from the first payment requirement and use it for
all user-facing token text. Falls back to "USDC" when extra.name
is absent (backward compatible with EIP-3009 tokens).

5 display strings updated:
- Header: "please pay $X {tokenName}" (was "USDC")
- Testnet prompt: "Need {tokenName} on {chainName}?" (was "USDC")
- Balance: "$X {tokenName}" (was "USDC")
- Amount row: "$X {tokenName}" (was "USDC")
- Error: "Make sure you have {tokenName} on {chainName}" (was "USDC")

Regenerated Go, Python, and TS paywall templates.
2026-04-11 23:28:54 +09:00
Carson Roscoe
dd4eb584a2
chore: version typescript, python and go packages (#1915)
* chore: version typescript packages

* chore: version python package

* chore: version go package
2026-04-02 13:22:49 -07:00
Carson Roscoe
2250caec83
feat: refactor coinbase/x402 references to x402-foundation/x402 (#1912)
* feat: refactor coinbase/x402 references to x402-foundation/x402

* fix: format

* chore: changeset fragments for typescript, python and go
2026-04-02 12:59:07 -07:00
nico
bff876de23
feat(evm): add Stable testnet (chain ID 2201) network support (#1786)
* feat(evm): add Stable testnet (chain ID 2201) network support

* style(go): fix gofmt alignment for chain ID variable declarations

* fix(python): remove supported_assets from Stable network configs

* style(ts): reorder Stable configs above Polygon/Arbitrum in defaultAssets
2026-03-31 16:59:07 +09:00
Emre Dincoglu
9f52f9cc0e
Added USDC for arbOne and ArbSepolia (#1877) 2026-03-31 00:54:42 +09:00
Andrew Barnes
c76b21d0aa
test(python): add test coverage for MCP server_sync module (#1733)
* test(python): add missing sync test scenarios to existing test_server.py

Add edge case coverage for: missing/malformed _meta, no matching
requirements, MCPToolResult direct return, non-dict handler return,
structuredContent preservation, empty accepts validation, verification
failure without reason, and hook context field verification.

* fix: apply ruff format to test_server.py

* fix formatting: match existing test style, inline data construction, fix import order
2026-03-30 20:54:21 +09:00
Vijaygopal Balasa
8c80edd30e
feat: add Polygon mainnet (chain ID 137) default asset support (#1791)
Add native USDC (0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359) as the
default stablecoin for Polygon mainnet across all three SDKs:

- Go: ChainIDPolygon constant, v2 NetworkConfigs, v1 NetworkConfigs
- TypeScript: v2 stablecoins map in ExactEvmScheme
- Python: v2 NETWORK_CONFIGS with supported_assets

Update Go v1 unit tests that previously used "polygon" as a network
without a default asset config. Replace with "iotex" and add positive
test coverage for Polygon config and asset resolution.

Contract details (verified on-chain via PolygonScan):
- Token: Circle native USDC (FiatTokenV2_2)
- EIP-712 domain: name="USD Coin", version="2"
- EIP-3009: transferWithAuthorization supported
- x402 proxy deployed at canonical CREATE2 address
2026-03-30 16:00:22 +09:00
Ayush Ojha
1af1f69fc8
Fix race condition in lazy facilitator initialization (#1812)
* Fix race condition in lazy facilitator initialization for FastAPI and Flask middleware

Under concurrent requests, multiple coroutines/threads could see init_done=False
simultaneously and all call http_server.initialize(), causing redundant init calls
and inconsistent error propagation.

- FastAPI: guard with asyncio.Lock using double-checked locking pattern
- Flask: guard with threading.Lock using double-checked locking pattern
- Add concurrency tests proving single-flight initialization for both frameworks
- Add tests verifying failed init does not permanently block retries

Closes #1584

* fix: remove unused variables to pass ruff lint
2026-03-27 11:56:00 -05:00
Ethan Oroshiba
bb1f2f0225
fix: enforce method in discovery schemas and auto-populate from adapter (#1831)
* fix(go): add omitempty to QueryInput/BodyInput.Method to prevent spurious enum validation failure

When external JSON omits info.input.method (valid when method is not in the schema's
required list), Go zero-initializes the Method field to "" and re-marshaling produces
"method":"", which fails the enum constraint in ValidateDiscoveryExtension.

Adding omitempty ensures absent method fields remain absent after round-trip serialization.

Fixes #1830

Made-with: Cursor

* enforce method is required in TS and Python discovery extension schemas

Per spec, the method field must always be present in a discovery extension's
info.input. Add "method" to the required array in schemas built by the TS
and Python resource service builders, so ValidateDiscoveryExtension rejects
extensions missing method with a clear error.

Also reverts the Go omitempty workaround from the prior commit; the Go SDK
was already producing a validation error for absent method (via the enum
constraint), and the schema-level required enforcement is the correct fix.

Closes #1830

Made-with: Cursor

* style: format resourceService.ts type union per Prettier

Made-with: Cursor

* fix: auto-populate HTTP method from adapter in all SDKs

The SDK entry points (processHTTPRequest, requiresPayment,
processSettlement) now derive the HTTP method from the adapter
when it is not explicitly set on the request context. This ensures
direct x402HTTPResourceServer users do not need to manually assign
the method field — the SDK computes it at runtime, matching the
behavior middleware users already get.

Made-with: Cursor

* test: add declare → enrich → validate flow tests for bazaar extension

Verify the real middleware path: extensions are declared without method,
enrichDeclaration injects method from the HTTP context at request time,
and the enriched extension passes schema validation. Covers GET and
POST in all three SDKs (TypeScript, Go, Python).

Made-with: Cursor
2026-03-26 15:11:48 -05:00
nico
bbe45f5b7c
feat(evm): add Stable mainnet (chain ID 988) network support (#1775)
* feat(evm): add Stable mainnet (chain ID 988) network support

* chore: add changelog fragments for Stable mainnet support

* feat(evm): add Stable mainnet to Go v1 legacy network config
2026-03-24 15:02:20 +09:00
Ryan R. Fox
011e6802d7
feat: add Mezo Testnet mUSD as default asset (Permit2 + EIP-2612) (#1774)
Add mUSD (0x118917a40FAF1CD7a13dB0Ef56C86De7973Ac503) as the default
stablecoin for Mezo Testnet (eip155:31611) across all three SDKs:
- TypeScript: scheme.ts stablecoins map
- Go: constants.go NetworkConfigs map
- Python: constants.py NETWORK_CONFIGS dict

mUSD uses Permit2 transfer method (no EIP-3009) with EIP-2612 support.
EIP-712 domain: name='Mezo USD', version='1', decimals=18.
2026-03-24 14:39:16 +09:00
Carson Roscoe
067f29705f
feat: add dynamic routing to bazaar (#1664)
* feat: add dynamic routing to bazaar

* feat: fixed format/linter errors

* fix: access routeConfig.config.settlementFailedResponseBody after getRouteConfig return type change

getRouteConfig now returns { config: RouteConfig; pattern: string } instead of RouteConfig
directly. The buildSettlementFailureResponse call site was not updated, causing
settlementFailedResponseBody callbacks to be silently skipped after settlement failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: updated param logic

* feat: added typescript, python and go bazaar server examples

* feat: updated e2e bazaar facilitators

* fix: add pathParams if not set

* fix: lint in python

* fix: typescript examples lock

* feat: pr feedback

* feat: pr feedback

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 08:49:46 -07:00
phdargen
5135fab5e7
Fix extra: null incompatibility between python facilitator and TS zod schema (#1762)
* Fix extra: null incompatibility between Python facilitator and TypeScript Zod schema

* fix optional strings

* fixed outdated eth_account._utils.typed_transactions import
2026-03-23 08:41:51 -07:00
Carson Roscoe
db2bfac75f
chore: version python package (#1704) 2026-03-19 11:42:36 -07:00
Carson Roscoe
7b7e163c15
feat: python permit2 and gas sponsorship extensions (#1686)
* feat: implement permit2 in python

* feat: added eip2612 gas sponsoring extension

* feat: added erc20 approval gas sponsoring extension

* feat: added permit2 to exact evm with gas sponsorship support

* feat: updated unit/integration tests

* feat: updated e2e clients

* feat: updated e2e servers

* feat: updated e2e facilitator

* feat: added changelog fragment

* feat: updated specs

* fix: format/lint

* fix: format

* feat: pr feedback
2026-03-19 11:17:34 -07:00
Ziyang Liu
4c1e44fb2f
fix(python): handle invalid facilitator responses (#1506)
* fix(python): handle invalid facilitator responses

* fix(go,typescript): handle invalid facilitator responses

* fix(go): preserve empty supported responses

* fix(typescript): address core CI failures

* fix(http): address review feedback

* fix(typescript): address lint and format check failures
2026-03-16 11:24:38 -05:00
phdargen
62a4c16684
chore: version python package (#1635) 2026-03-17 00:01:29 +09:00
phdargen
1a6e08b291
EVM verify simulation and improved smart account handling (#1474)
* fix evm sim

* fix EIP-6492 deployment info check

* fix implementation-dependent verifyTypedData

* same for v1

* update multicall

* update errors

* refactor

* minor fixes

* add go equivalent

* add py equivalent

* fix #1388 for go/py

* fix #1139 for py/go

* fix go signer
2026-03-10 10:04:52 -07:00
phdargen
f43339a4f3
Fixed paywall config injection (#1550) 2026-03-10 10:03:22 -07:00
phdargen
34d2442cbf
fix encoding in paywall (#1531) 2026-03-09 23:48:30 +09:00
phdargen
65f12004b1
chore: version python package (#1470) 2026-03-06 11:38:07 +09:00
Notorious D.E.V.
7cd93d8bf5
Add in-memory cache for in-flight Solana txs (#1468)
* fix: add duplicate settlement mitigation for SVM across all SDKs

Introduce an in-memory SettlementCache to prevent a race condition on
Solana where the same payment transaction could be settled multiple
times before on-chain confirmation. The cache is shared across V1 and
V2 facilitator schemes so that cross-version duplicates are caught.

- Add SettlementCache with 120s TTL in TypeScript, Python, and Go
- Integrate cache check into facilitator settle paths (V1 and V2)
- Add unit tests for duplicate detection in all three languages
- Share cache across V1/V2 in Go facilitator example
- Add duplicate settlement spec to scheme_exact_svm.md
- Document SettlementCache in SVM READMEs for all three SDKs
- Document the race condition in go/FACILITATOR.md Security section
- Add merchant-facing guidance in docs/core-concepts/client-server.md
  and docs/core-concepts/facilitator.md for self-settling servers
- Fix JSDoc lint errors in TypeScript settlement-cache.ts

* refactor: optimize SettlementCache prune with early break on ordered entries

Leverage insertion-order guarantees of Map (TS) and dict (Python) to
break early once a non-expired entry is encountered, avoiding a full
scan of the cache on every isDuplicate call. Go is left unchanged since
map iteration order is not guaranteed.

Also adds prune-specific unit tests for all three SDKs covering:
- mixed expired/fresh entries
- all expired
- none expired
- insertion-order early-break correctness (Python)

* docs: add changelog entries for SVM duplicate settlement fix
2026-03-05 16:16:09 -08:00
phdargen
f4313370c2
Add assetTransferMethod and supportsEip2612 flag to defaultAssets (#1359)
* set assetTransferMethod for defaultAsset

* mock token fix

* use moneyparser

* py changes

* go changes

* fix get_asset_info

* add SupportsEip2612 flag

* add changelogs

* fix tests
2026-03-05 11:07:18 +09:00
phdargen
aeef1bff66
Custom settlement failures responses (#1430)
* py fix for 1176

* fix settle response body

* same for go/py

* fix format
2026-03-05 09:46:39 +09:00