74 Commits

Author SHA1 Message Date
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
Madison carter
313bc87c65
fix(python): camelCase serialization + auto-wrap LocalAccount (#1122)
Two fixes for the Python SDK:

1. Add serialize_by_alias=True to BaseX402Model so model_dump_json()
   produces spec-compliant camelCase by default. Users no longer need
   to pass by_alias=True manually. (Fixes #1120)

2. Auto-wrap eth_account LocalAccount in EthAccountSigner when passed
   to ExactEvmScheme or ExactEvmSchemeV1. This prevents the confusing
   ValueError from mismatched sign_typed_data signatures. (Fixes #1121)
2026-02-27 14:23:25 +09:00
Carson Roscoe
55a4396740
fix: v1 chain context leaking v2 sdk (#1345)
* fix: isolated v1 chain context into v1 subpaths of SDKs

* chore: added changeset fragments

* fix: format/lint python
2026-02-25 17:57:08 -08:00
Carson Roscoe
1fccd530c4
fix: decouple extraneous chain info from facilitator SDKs in go and python (#1337) 2026-02-25 11:33:55 -08:00
JumpboxTech
5b05f5bad6
feat(evm): add Monad mainnet (chain ID 143) network support (#1294)
Add Monad (chain ID 143) to the EVM network chain ID map across
TypeScript, Python, and Go SDKs. Monad has native Circle USDC with
EIP-3009 (transferWithAuthorization) support.

- TypeScript: add to EVM_NETWORK_CHAIN_ID_MAP
- Python: add to V1_NETWORKS, V1_NETWORK_CHAIN_IDS, NETWORK_CONFIGS, NETWORK_ALIASES
- Go: add ChainIDMonad, NetworkConfigs entries (CAIP-2 + legacy)

USDC on Monad: 0x754704Bc059F8C67012fEd69BC8A327a5aafb603
2026-02-23 13:22:53 +09:00
Carson Roscoe
7363a14802
chore: version python package (#1275) 2026-02-20 16:27:57 -05:00
Carson Roscoe
9947f34258
fix: python SVM client signer v1 (#1252)
* fix: python signing implementation for x402 v1

* fix: e2e gin server bazaar key usage
2026-02-19 14:40:45 -05:00
Carson Roscoe
3fb55d797e
feat: upgrade facilitator extension registration (#1241)
* feat: upgrade facilitator extension registration in go

* feat: upgrade facilitator extension registration in python

* feat: upgrade facilitator extension registration in typescript

* chore: added changelog fragments
2026-02-18 17:49:22 -05:00
Carson Roscoe
2a8458687a
fix: updated Go and Python validAfter to match Typescript (#1222)
* fix: updated Go and Python validAfter to match Typescript

* fix: unit tests
2026-02-17 15:20:08 -05:00
A. McDermott
e9d9b3a5ba
feat: Payment Identifier Extension SDK - Python (#1111)
* feat(python): add payment-identifier extension types and constants

- Add PaymentIdentifierInfo and PaymentIdentifierExtension Pydantic models
- Add constants: PAYMENT_IDENTIFIER, PAYMENT_ID_MIN_LENGTH, PAYMENT_ID_MAX_LENGTH, PAYMENT_ID_PATTERN
- Define PaymentIdentifierSchema type alias

* feat(python): add payment-identifier utility functions

- Add generate_payment_id() to create UUID v4-based payment IDs
- Add is_valid_payment_id() to validate ID format (16-128 chars, alphanumeric + hyphens/underscores)

* feat(python): add payment-identifier JSON Schema definition

- Add payment_identifier_schema compliant with JSON Schema Draft 2020-12
- Schema validates required boolean and optional id string field

* feat(python): add payment-identifier validation and extraction functions

- Add ValidationResult dataclass for validation results
- Add is_payment_identifier_extension() type guard
- Add validate_payment_identifier() for full extension validation
- Add extract_payment_identifier() to extract ID from PaymentPayload
- Add extract_and_validate_payment_identifier() combined function
- Add has_payment_identifier() to check extension presence
- Add is_payment_identifier_required() to check requirement flag
- Add validate_payment_identifier_requirement() for requirement compliance

* feat(python): add payment-identifier client utilities

- Add append_payment_identifier_to_extensions() to append payment ID to extensions dict
- Only appends if server declared the extension
- Generates new ID if not provided

* feat(python): add payment-identifier resource server utilities

- Add declare_payment_identifier_extension() to create extension declaration
- Add PaymentIdentifierResourceServerExtension class implementing ResourceServerExtension protocol
- Add payment_identifier_resource_server_extension singleton instance

* feat(python): add payment-identifier extension main module

- Export all public APIs from payment-identifier extension
- Add comprehensive usage documentation with examples for servers, clients, and idempotency

* feat(python): export payment-identifier extension from extensions module

- Add payment-identifier imports and exports to main extensions __init__.py
- Export all constants, types, functions, and classes for public API

* fix(python): resolve ValidationResult type mismatch in extensions module

- Export payment_identifier.ValidationResult as ValidationResult (matches payment_identifier function return types)
- Export bazaar.ValidationResult as BazaarValidationResult for explicit bazaar usage
- Both ValidationResult classes are structurally equivalent (same dataclass fields)
- Fixes type mismatch where payment_identifier functions returned payment_identifier.ValidationResult but ValidationResult imported from x402.extensions was bazaar.ValidationResult

* refactor(python): rename payment_identifier ValidationResult to PaymentIdentifierValidationResult

- Rename ValidationResult class to PaymentIdentifierValidationResult in payment_identifier/validation.py
- Update all function return types and usages throughout validation.py
- Update exports in payment_identifier/__init__.py
- Update imports/exports in extensions/__init__.py
- Keep ValidationResult from bazaar as default export for backward compatibility
- Export PaymentIdentifierValidationResult separately for explicit payment_identifier usage
- Makes naming consistent with BazaarValidationResult pattern

* test(python): add comprehensive test suite for payment_identifier extension

- Add test_types.py: Test constants and Pydantic models
- Add test_utils.py: Test ID generation and validation functions
- Add test_validation.py: Test all validation and extraction functions
- Add test_client.py: Test client-side utilities
- Add test_server.py: Test server-side utilities
- Tests cover all major functionality including edge cases and error handling
- Follows same structure as bazaar extension tests

* fix(python): fix payment_identifier test helper and assertions

- Fix create_extension_with_id helper to handle invalid IDs for testing
- Update test assertion to check for 'identifier' in error message
- All 67 tests now passing

* fix(python): add ValidationResult alias for backward compatibility

- Add ValidationResult = BazaarValidationResult alias after bazaar import
- Fixes AttributeError when importing ValidationResult from x402.extensions
- ValidationResult was imported as BazaarValidationResult but exported in __all__
- Now both ValidationResult and BazaarValidationResult are available

* test(python): add test to verify __all__ exports are importable

- Add test_exports.py to verify all items in __all__ can be imported
- Tests that ValidationResult alias works correctly
- Tests that 'import *' works as expected
- This would have caught the ValidationResult AttributeError bug

* fix(python): make jsonschema import lazy in payment_identifier validation

- Remove module-level jsonschema import that raised ImportError
- Import jsonschema lazily only when schema validation is needed
- Return validation error instead of raising ImportError at module level
- Allows payment_identifier extension to be imported without jsonschema
- Users can still use non-validation functions without optional dependency

* fix(python): fix linting errors

- Remove unused variable in test_types.py
- Fix import sorting in extensions/__init__.py
- Add noqa comment for intentional E402 (import after alias)

* Lint

* docs(python): add payment-identifier extension examples

Add client and server examples demonstrating how to use the
payment-identifier extension for idempotent payment processing.

Client example shows:
- Generating payment IDs with generate_payment_id()
- Using on_before_payment_creation hook to inject the ID
- Making duplicate requests to demonstrate cache behavior

Server example shows:
- Declaring extension support with declare_payment_identifier_extension()
- Extracting payment IDs with extract_payment_identifier()
- Caching responses after settlement for idempotency

* Lint

* Format

* Changelog
2026-02-11 18:46:46 -05:00
Carson Roscoe
dd49a43618
chore: version typescript/go/python packages (#1163)
* chore: version typescript packages

* chore: version python package

* chore: version go package

* chore: update lock files
2026-02-11 16:30:47 -05:00
Carson Roscoe
65d968c366
feat: e2e testing for mcp transport - Typescript, Python & Golang (#1149)
* feat: add mcp support to e2e test suite

* feat: add mcp go client to e2e tests

* feat: add mcp go server to e2e tests

* feat: add mcp python client to e2e tests

* feat: add mcp python server to e2e tests

* feat: add mcp typescript client to e2e tests

* feat: add mcp typescript server to e2e tests

* fix: go mcp sdk

* fix: python mcp sdk

* fix: typescript mcp sdk

* feat: refactor go mcp sdk

* feat: refactor python mcp sdk

* fix: format & lint python

* feat: format & lint go

* fix: python unit tests

* feat: added missing go changeset fragment

* feat: added Python export for MCPToolResult

* fix: pr feedback
2026-02-11 13:43:31 -05:00
Carson Roscoe
4861b61b80
Add MCP submodule to Python SDK (#1131)
* feat: added MCP module in Python

* feat: added tests

* feat: added mcp client example

* feat: added mcp server example

* feat: mcp client chatbot example

* feat: added changelog entry

* fix: readme

* feat: pr feedback
2026-02-10 13:39:59 -05:00
BREAD
0c6064ded7
feat(evm): add MegaETH mainnet support (#1089)
Add MegaETH (chain ID 4326) with USDM as the default stablecoin.

TypeScript, Go, and Python SDK support added.
Changelog fragments included for all SDKs.
2026-02-06 09:00:28 +09:00
Carson Roscoe
09b529ae00
feat: added x402MCPClient, x402MCPServer, middleware, and examples (#1056)
* feat: added x402MCPClient, x402MCPServer, middleware, and examples

* feat: expanded examples to simple & advanced mcp examples

* fix: format/lint

* feat: added npm deploy workflow and set version to 2.2.0-alpha

* feat: client side PR feedback

* feat: pr feedback

* fix: merge to main

* fear: pr feedback

* feat: added integration teast with SSE MCP

* feat: expose timeout, abort signal and reset timeout on progress options to x402MCPClient

* fix: rebased main

* fix: examples linting

* fix: remove unknown directive
2026-02-02 17:50:40 -08:00
Faris Habib
bd0157283d
Improve Solana payment throughput with memo-based uniqueness (#1048)
* add memo instruction to prevent duplicate trxn attacks

* fix python linting

* additional fixes for python/go memo and add tests

* cleanup code
2026-02-02 14:59:48 -08:00
Faris Habib
55feb97c07
Add Changelog Management (#1036)
* add changelog tooling + config

* add docs and baseline changelogs

* update gitignore

* align towncrier to agentkit verbage

* address PR review
2026-01-29 12:52:02 -08:00
Andrew Reder
3d142fd228
feat(coinbase-x402): add error messages to Verify/Settle schemas (#1030)
* add messages to error schemas

* refactor go error handling

* lint fix

* testing

* update ts and python

* update ts and python error returns
2026-01-27 13:28:37 -08:00
Carson Roscoe
ca7f38e5e7
chore: version python package (#1005) 2026-01-21 16:47:16 -08:00
Carson Roscoe
30a847d7d1
feat: New Python SDK with v2 support (#841)
* chore: renamed python/x402 to python/legacy

* feat: initial Python core SDK

* feat: added core HTTP wrappers

* feat: added core types

* feat: added evm mechanism for exact v1/v2

* feat: added httpx client

* feat: added requests client

* feat: added fastapi middleware

* feat: added flask middleware

* feat: added integration tests

* feat: added Python SDK to e2e tests

* python-v2: fix workflow checks (#863)

* fix format

* fix lint

* fix build

* fix pytest

* Fix syntax errors and missing imports in manual integration example (#902)

- Add missing imports (base64, json, Response, JSONResponse, PaymentPayload, FacilitatorClient)
- Fix function signature syntax error
- Fix dict initialization syntax (colon to equals)
- Add missing return statement after successful payment
- Remove trailing whitespace

* feat: add Python SDK v2 server examples (FastAPI, Flask)  (#879)

* feat: add fastapi example project configuration

* feat: add fastapi example with x402 payment middleware

* docs: add comprehensive README for fastapi example

* feat: add flask example project configuration

* feat: add flask example with x402 payment middleware

* docs: add comprehensive README for flask example

* feat: add test clients for fastapi and flask examples

* docs: add test client usage to READMEs

* chore - remove python-version and test-client.py

* docs - remove test client guide from README.md

* chore - remove license and classifier

* feat - add description and mime type

* feat - update .env-local

* feat: add Python v2 client examples (httpx & requests) (#857)

* feat: add Python v2 client examples (httpx & requests)

Add simple client examples demonstrating httpx (async) and requests (sync) usage with the x402 Python v2 SDK.

- examples/python/clients/example.py - Simple example showing both httpx and requests
- Uses EthAccountSigner with register_exact_evm_client helper
- Minimal configuration required

* refactor: split Python client examples into separate directories

Address PR review feedback:
- Separate httpx/ and requests/ directories
- Add pyproject.toml for uv sync support
- Add environment variable validation
- Add payment response header extraction
- Use context manager for requests session cleanup

Tested on Base Sepolia testnet:
- httpx: tx 0xce49f668aba01c4b0b1af2eb0d9a381f4c62295506a91f20af479e0e834ef350
- requests: tx 0xb83b6feefa5a744b7779ba5b37df33f9c7241f58119454d66102acd97a92f024

* Update examples/python/clients/httpx/main.py

Co-authored-by: phdargen <pdargent@icloud.com>

* Update examples/python/clients/requests/main.py

Co-authored-by: phdargen <pdargent@icloud.com>

---------

Co-authored-by: phdargen <pdargent@icloud.com>

* feat(python): Make v2 framework and client dependencies optional extras (#901)

* python-v2: add svm mechanism (#904)

* add svm mechanism

* add unit tests

* add integration tests

* update server examples

* add e2e tests

* update clients

* make EVM/SVM dependencies optional extras

* fix legacy uv paths

* V2 python bazaar (#929)

* add bazaar extension

* strip query params for discovery

* fix 862

* updated e2e tests

* Add advanced Python client examples (#947)

* Add advanced Python client examples

Implements 5 advanced patterns demonstrating x402 SDK v2 features:
- hooks.py: Payment lifecycle hooks (before, after, failure)
- preferred_network.py: Custom network preference selector
- builder_pattern.py: Network-specific registration with wildcards
- error_recovery.py: Error classification and recovery strategies
- custom_transport.py: Custom httpx transport with retry/timing

Includes:
- CLI entry point (index.py) for running examples
- Comprehensive test suite (40 unit tests)
- E2E integration tests
- README documentation

All tests passing.

* Remove tests and examples beyond TypeScript SDK parity

Address PR review feedback:
- Remove tests directory (tests belong in SDK, not examples)
- Remove custom_transport.py (runtime error, beyond TS parity)
- Remove error_recovery.py (duplicate of hooks.py, beyond TS parity)
- Update index.py, README.md, pyproject.toml accordingly

* Address PR feedback: add SVM support and use optional deps

- Update pyproject.toml to use x402[evm,svm,httpx] instead of
  listing dependencies separately
- Add Solana/SVM network examples to preferred_network.py
- Support both EVM and SVM signers for cross-chain flexibility
- Update .env-local with SOLANA_PRIVATE_KEY option

* Python-v2: facilitator example + e2e (#950)

* add facilitator example

* improve svm signer

* add description to DiscoveredResource

* add facilitator e2e

* add paywall builder (#953)

* Add Python custom client example (#954)

Demonstrates manual x402 v2 payment flow without convenience wrappers.

Shows the 6-step process:
1. Initialize client and register payment schemes
2. Make initial request, receive 402
3. Decode PAYMENT-REQUIRED header
4. Create signed payment payload
5. Retry with PAYMENT-SIGNATURE header
6. Handle success/failure response

Useful for integrating with non-standard HTTP libraries or implementing
custom retry logic.

* feat(v2-sdk): support async dynamic hooks for price and metadata (#900)

* feat(http): implement dual class design for sync/async support

- Add x402HTTPResourceServer (async) for FastAPI/Starlette
- Add x402HTTPResourceServerSync (sync) for Flask/Django
- Share common logic via _x402HTTPServerBase
- Remove dynamic description/resource (keep only dynamic price/payTo)
- Update Flask middleware to use sync server directly
- Integrate with enrich_extensions for bazaar support
- Add per-route hook_timeout_seconds configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(types): add missing Awaitable import and fix test import sorting

- Add Awaitable import to types.py for DynamicPayTo/DynamicPrice type hints
- Fix import block sorting in test_async_hooks.py and test_core.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: simplify API by removing unused types and making timeout opt-in

Address reviewer feedback from @phdargen:
- Remove SyncDynamicPayTo/SyncDynamicPrice (unused types that would require SyncPaymentOption to be useful)
- Change hook_timeout_seconds default to None (opt-in, matching TS/Go parity)
- Export x402HTTPResourceServerSync from http/__init__.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* python-v2: make create_facilitator_config work with both V1 and V2 (#968)

* make create_facilitator_config work with both V1 and V2

* fix lint

* feat: add Python SDK v2 server advanced example (FastAPI) (#952)

* feat - add pyproject.toml, uv.lock for advanced example

* feat - add bazaar extension

* feat - add hooks

* feat - add x402 extensions to pyproject.toml

* feat - add dynamic pricing feature

* feat - add dynamic pay-to and custom money parser features

* docs - add README for advanced server example

* style - apply lint

* chore - add comments for bazaar extension code

* fix: python v2 x402HTTPAdapter retry logic (#978)

* fix: fix consecutive payment bug in x402HTTPAdapter

- Replace instance-level _is_retry flag with per-request header
  to prevent state leakage between consecutive 402 requests.

* tests - add test case for consecutive payment with x402HTTPAdapter

* style - apply lint

* Python-v2: async lifecycle hooks (#975)

* add dual sync/async classes for server/client/facilitator

* update integration/e2e tests

* add unit tests for core, http and implement wrapHttpxWithPaymentFromConfig/wrapRequestsWithPayment

* refactor core server/client/facilitator

* refactor x402_http_server/facilitator_client/x402_http_client

* update exmamples

* add utility function that takes care of html-safe escaping

* add sdk readmes

* add retry unit tests to httpx client

* Update Python SDK Docs for v2 (#976)

* Porting docs and updating for v2 changes (#813)

* porting docs and updating for v2 changes

* update quickstart for sellers

* update quickstarts, miniapps, and mcp docs

* update doc links

* update FAQs

* fix getting started docs

* update core concepts

* remove miniapps guide

* update extensions

* fix bazaar code examples

* fix broken links and yaml file

* remove unnecessary protocol layer doc

* add migration guide

* update documentation for python v2 sdk

* testing pr preview

* docs(python): remove unused os imports and align with TS tab patterns

- Remove unused 'import os' from FastAPI and Flask examples in quickstart-for-sellers
- Update bazaar-discovery-layer Python example to use hardcoded '0xYourPrivateKey' to match TypeScript tab consistency

* update migration doc

* cleanup comments

* cleanup readme

* fix: Python facilitator e2e code

* fix: lint

---------

Co-authored-by: phdargen <p.dargent@cern.ch>
Co-authored-by: somesome <57699892+sohw400@users.noreply.github.com>
Co-authored-by: Logan Kang <kcs93023@gmail.com>
Co-authored-by: 1bcMax <viewitter@gmail.com>
Co-authored-by: phdargen <pdargent@icloud.com>
Co-authored-by: Vladimir Sotnikov <bubert9@gmail.com>
Co-authored-by: Shuhei <shuhei0866@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Faris Habib <faris.habib@coinbase.com>
2026-01-21 16:32:07 -08:00
Carson Roscoe
1a79feaf94
Development v2 (#705)
* chore: move packages, examples and e2e clients/servers/facilitators to legacy subfolders

* feat: added @x402/core to /typescript/packages

* feat: added @x402/evm to /typescript/packages/mechanism

* feat: added @x402/svm to /typescript/packages/mechanism

* feat: added @x402/extensions to /typescript/packages

* feat: added @x402/fetch to /typescript/packages/http

* feat: added @x402/axios to /typescript/packages/http

* feat: added @x402/paywall to /typescript/packages/http

* feat: added @x402/express to /typescript/packages/http

* feat: added @x402/hono to /typescript/packages/http

* feat: added @x402/next to /typescript/packages/http

* chore: update /typescript pnpm packaging

* feat: added core files to /go

* feat: added evm mechanism to /go

* feat: added svm mechanism to /go

* feat: added extensions to /go

* feat: added gin to /go/http

* feat: added tests to /go

* feat: rewrote e2e test suite system

* feat: added axios client to e2e suite

* feat: added fetch client to e2e suite

* feat: added go http client to e2e suite

* feat: added express server to e2e suite

* feat: added hono server to e2e suite

* feat: added next server to e2e suite

* feat: added gin server to e2e suite

* feat: added typescript facilitator to e2e suite

* feat: added go facilitator to e2e suite

* feat: added fetch example to examples/typescript/clients

* feat: added axios example to examples/typescript/clients

* feat: added advanced example to examples/typescript/clients

* feat: added custom example to examples/typescript/clients

* feat: added express example to examples/typescript/servers

* feat: added hono example to examples/typescript/servers

* feat: added advanced example to examples/typescript/servers

* feat: added custom example to examples/typescript/servers

* feat: added facilitator example to examples/typescript

* chore: update /examples/typescript pnpm packaging

* feat: added http client to examples/go/clients

* feat: added advanced client to examples/go/clients

* feat: added custom client to examples/go/clients

* feat: added gin server to examples/go/servers

* feat: added advanced server to examples/go/servers

* feat: added custom server to examples/go/servers

* feat: added facilitator to examples/go

* chore: updated github workflows

* fix: typescript examples fotmat/lint

* v2: next example (#706)

* fix legacy example builds

* add next example

* fix format

* upgrade to next 16

* fix legacy build

* fix e2e tests

* V2: next api wrapper (#707)

* add next route wrapper

* add protected api to example page

* add unit tests

* fix missing settle failure check

* added e2e tests for withX402

* add SettleResponse to ProcessSettleResultResponse

* add requirements to payment-header

* feat: add v2 support to x402.org facilitator

* feat: dynamically load bazaar extension in Next only when used

* fix: x402Facilitator in typescript calling onAfterVerify instead on onVerifyFailure on failure

* feat: add ERC1271 and ERC6492 support to Typescript facilitator

* feat: update typescript facilitator example & e2e test for ERC1271/ERC6492 support

* feat: add ERC1271 and ERC6492 support to Go facilitators

* feat: update go facilitator example & e2e test for ERC1271/ERC6492 support

* v2: express fixes + unit tests  (#712)

* add express fixes from v1

* add units test for express/hono

* added fetch/axios unit tests

* v2: Clean up paywall (#710)

* Remove cdpClientKey and sessionTokenEndpoint from PaywallConfig

Remove Onramp functionality from EvmPaywall

Remove Coinbase fields from paywall template generation

* Migrate site to @x402/next with v2 protocol support

* Clean up tests

* remove CDP onramp from core paywall

* Update templates and build process

* Format

* Lockfile

* mock templates for CI

* Format

* Generate new templates

* Format

* v2: facilitator sync fix (#716)

* update next/react versions

* update site to next 16, tailwind 4 and fix env vars

* fix initializeOnStart pattern

* security: bump quic-go dependency for security fix GHSA-47m2-4cr7-mhcw

* v2:fix ts advanced/custom examples (#717)

* fix ts examples

* add clients/advanced/preferred-network example

* feat: improved e2e cli for external facilitator testing

* feat: updated evm & svm signer interfaces in go

* feat: updated evm & svm signer interfaces in typescript

* feat: reverted SupportedKind's kinds structure in go

* feat: reverted SupportedKind's kinds structure in typescript

* feat: refactor facilitator SVM signer interface in typescript

* go example fixes (#719)

* feat: cleanup go bazaar extension

* V2: docs update (#729)

* ts example docs

* improve ts package docs

* feat: dynamic bazaar import for all server middleware

* feat: allow dynamic response building for 402 response in typescript

* feat: allow dynamic response building for 402 response in go

* feat: added withBazaar HTTPFacilitatorClient wrapper

* feat: added linting to go

* fix: lint go

* improve go example docs (#733)

* feat: Solana PR review feedback in typescript

* feat: Solana PR review feedback in go

* fix: locks & paywall gen after rebase off main

* fix: format

* docs: improve @x402/extensions README with comprehensive documentation (#731)

* First draft of contributor docs (#738)

Correct ts contributing

Clean up contribution guidelines

* feat: updated specs for v2

* fix: merge with main, fixed lock

* v2: go settlement failure and initOnStart fixes (#720)

* go settlement failure and initOnStart fixes

* update go unit tests

* update readmes

* feat: review & improve examples & READMEs

* v2: add multiple payment options for go (#743)

* add multiple payment options for go

* fix SyncFacilitatorOnStart

* v2: add hooks for advanced go example (#745)

* add hooks for advanced go example

* fix legacy ts deps

* feat: added server initialization validation

* feat: added @x402 package workflows

* v2: add miniapp and mcp examples (#746)

* add miniapp example

* fix format

* add mcp example

* fix format

* v2: add manifest to miniapp example (#751)

* add manifest to miniapp

* fix format

* feat: x402 website redesign (#750)

* port new website to public repo

* chore: update pnpm-lock.yaml with motion dependency

* feat: add x402 V2 launch blog post and update hero code snippet

- Add /writing/x402-v2-launch blog post page
- Add blog images (blog_intro.png, blog_x402_layers.png, homepage_build5.png)
- Enable Writing nav link in NavBar and Footer
- Update hero code snippet to show V2 SDK usage
- Fix CodeSnippet to support multi-line code

* feat: edit nav for mobile

* Revert "feat: edit nav for mobile"

This reverts commit 475999a2a84f1fab875cd0fe2bb74d44dba7e1bd.

* feat: add ecosystem page and minor home page tweaks

* feat: fix typography in ecosystem

* homepage qa fixes

* feat: add ecosystem icons and fix halftone

* cleanup assets

* fix: minor bug on faq

* feat: add hamburger menu to mobile

* Update README (#755)

* Update readme

* Install instructions and typos

* feat: update site sample code & reduce supported networks

* fix: v1 header in README updated to v2

---------

Co-authored-by: phdargen <p.dargent@cern.ch>
Co-authored-by: A. McDermott <amanda.p.mcdermott@gmail.com>
Co-authored-by: Vedant Anand <136731196+VedantAnand17@users.noreply.github.com>
Co-authored-by: Faris Habib <frs@hbb.dev>
Co-authored-by: erikreppel-cb <erik.reppel@coinbase.com>
2025-12-11 07:41:57 -08:00
A. McDermott
49a816418f
Bump packages to 1.0.0 (#740) 2025-12-09 19:12:01 -05:00
A. McDermott
64f91591c8
Bump minor versions (#739) 2025-12-09 16:54:08 -05:00