diff --git a/changelog/index.md b/changelog/index.md index de793d93..c96b7d5e 100644 --- a/changelog/index.md +++ b/changelog/index.md @@ -7,6 +7,19 @@ description: 'Product updates and announcements for BANK OF AI — all products, Product updates and announcements for BANK OF AI. +
+
Nov 24, 2026
+
+ +### TRON SDK 2.1.4 and Facilitator 2.3.3 + +
Docsx402
+ +- Updated TRON SDK installation and Facilitator deployment guidance, including TronWeb 6.5.2 and the new TRON `exact` validation rules. [Details](./x402/) + +
+
+
Nov 12, 2026
diff --git a/changelog/x402.md b/changelog/x402.md index 0790b309..9bbe7a0f 100644 --- a/changelog/x402.md +++ b/changelog/x402.md @@ -7,6 +7,20 @@ description: 'Release notes for the x402 payment protocol, SDK, and CLI.' Release notes for the x402 protocol, SDK, and [Wallet CLI guide](/wallet-cli/). +
+
Nov 24, 2026
+
+ +### TRON SDK 2.1.4 and Facilitator 2.3.3 + +
Docsx402
+ +- Both TRON SDK packages use TronWeb 6.5.2 and retain the exact `@x402/core@2.29.0` peer. TRON `exact` rejects invalid assets, nonpositive amounts, and mismatched transfer methods. Registered USDT and USDD use Permit2. [SDK feature matrix](/x402/sdk-features/) · [TRON transfer methods](/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method) +- Facilitator 2.3.3 adopts SDK 2.1.4. Required balance or allowance read failures block settlement, and its wallet adapter accepts 20-byte hex asset addresses for contract reads. [Facilitator deployment and API](/x402/core-concepts/facilitator/) + +
+
+
Nov 12, 2026
diff --git a/docs/x402/core-concepts/OfficialFacilitator.md b/docs/x402/core-concepts/OfficialFacilitator.md index b6aa65e5..556070b0 100644 --- a/docs/x402/core-concepts/OfficialFacilitator.md +++ b/docs/x402/core-concepts/OfficialFacilitator.md @@ -129,7 +129,7 @@ Therefore, it is **strongly recommended to apply for and configure an API Key** ### Key refreshes and temporary authentication failures -Facilitator v2.3.2 reads active keys from DevCenter into a cache; the built-in production configuration refreshes it every **5 seconds**. Both key creation and deletion affect authentication after the next successful refresh, rather than immediately. Each process refreshes independently; replicas need not apply changes together, and database read time also affects the delay. +The Facilitator reads active keys from DevCenter into a cache; the built-in production configuration refreshes it every **5 seconds**. Both key creation and deletion affect authentication after the next successful refresh, rather than immediately. Each process refreshes independently; replicas need not apply changes together, and database read time also affects the delay. While the cache is fresh, incorrect keys, keys not yet synced, and revoked keys after syncing are treated as anonymous rather than uniformly rejected with HTTP 401. A successful call does not prove that a key was recognized. In particular, transaction-hash and authorization-identity lookups apply seller filtering only for a **valid, recognized key**. diff --git a/docs/x402/core-concepts/facilitator.md b/docs/x402/core-concepts/facilitator.md index 9d4c42b4..da8f47ab 100644 --- a/docs/x402/core-concepts/facilitator.md +++ b/docs/x402/core-concepts/facilitator.md @@ -78,9 +78,9 @@ Quick usage examples can be found in [OfficialFacilitator](./OfficialFacilitator If you need full control over the settlement wallet, RPC endpoints, energy management, or which networks and schemes are registered — or you have specific privacy or compliance requirements — you can deploy your own Facilitator service. -The current source release is **v2.3.2** (2026-11-13): official `@x402/core`, `@x402/evm`, and `@x402/extensions` **2.29.0**, TRON mechanism and independent resource extension **2.1.2**, and an explicit `@bankofai/agent-wallet` **3.1.0-beta.1** pin. Source installations require Node.js **24.22.1+ (24.x) or 26.12.1+**; Docker and CI pin 24.22.2, and Node.js 22 is no longer supported. Installation overrides pin Zod to **4.6.7**; preserve that override when refreshing dependencies. See the [Facilitator v2.3.2 README](https://github.com/BofAI/x402-facilitator/blob/v2.3.2/README.md) for deployment details. +The current source release is **v2.3.3** (2026-11-24): official `@x402/core`, `@x402/evm`, and `@x402/extensions` **2.29.0**, TRON mechanism and independent resource extension **2.1.4**, and an explicit `@bankofai/agent-wallet` **3.1.0-beta.1** pin. Source installations require Node.js **24.22.1+ (24.x) or 26.12.1+**; Docker and CI pin 24.22.2, and Node.js 22 is no longer supported. Installation overrides pin Zod to **4.6.7**; preserve that override when refreshing dependencies. See the [Facilitator v2.3.3 README](https://github.com/BofAI/x402-facilitator/blob/v2.3.3/README.md) for deployment details. -This release uses a single **TronWeb 6.5.1** installation. The service's installation overrides pin its Axios to **1.21.1** and require follow-redirects **^1.16.3**; the release lockfile resolves follow-redirects to **1.16.3**. Hono Node Server is updated to **2.1.6**. Install from the release lockfile and preserve its overrides when updating dependencies. +This release uses a single **TronWeb 6.5.2** installation. The service's installation overrides pin its Axios to **1.21.1** and require follow-redirects **^1.16.3**; the release lockfile resolves follow-redirects to **1.16.3**. The lockfile resolves Hono Node Server to **2.1.6**. Install from the release lockfile and preserve its overrides when updating dependencies. This deployment section describes the complete `BofAI/x402-facilitator` service. The minimal SDK example at `examples/typescript/facilitator/basic` exposes only `/verify`, `/settle`, and `/supported` and does not require a database; the database and DevCenter requirements below apply to the complete service. @@ -153,7 +153,19 @@ Record-query failures use these codes: `404 not_found` when no record matches, ` > There is **no** `/fee/quote` endpoint, and the schemes carry no facilitator fee at all. Payment records are keyed on the on-chain authorization identity (`network` + `scheme` + `asset` + `payer` + `nonce`), not a client-supplied payment ID. -v2.3.0 also turns missing or non-object TRON `exact` authorizations into protocol verification rejections: `isValid: false` with `invalidReason: "invalid_exact_tron_payload_authorization"`, instead of HTTP 500. This compatibility handling does not suppress genuine RPC failures. +### TRON `exact` errors {#tron-exact-errors} + +Facilitator v2.3.3 uses SDK 2.1.4 to validate TRON `exact` payments. The SDK errors below use HTTP `200`. A `/verify` response includes `isValid: false` and `invalidReason`. A `/settle` response includes `success: false` and `errorReason`. If the payment is rejected before broadcast, `transaction` is an empty string. + +| Reason | Trigger | +|--------|---------| +| `invalid_exact_tron_asset` | The asset address is malformed or points to a known infrastructure contract. | +| `invalid_exact_tron_amount` | The amount is outside the positive `uint256` range or is formatted differently from a decimal integer string. | +| `invalid_exact_tron_asset_transfer_method` | The transfer method is unsupported for the asset or the authorization uses the other method. | +| `invalid_exact_tron_payload_authorization` | The payload lacks a complete authorization or contains both authorization formats. | +| `chain_read_failed` | A required balance or Permit2 allowance read failed. The SDK rejects the payment before broadcasting a new settlement transaction. | + +These codes describe the scheme result. The service's request and Permit2 replay checks can return their own errors before the SDK evaluates the payment. [TRON transfer methods](/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method). --- diff --git a/docs/x402/core-concepts/http-402.md b/docs/x402/core-concepts/http-402.md index 83bbb491..5015412d 100644 --- a/docs/x402/core-concepts/http-402.md +++ b/docs/x402/core-concepts/http-402.md @@ -41,7 +41,7 @@ When the server returns a `402 Payment Required` response, the decoded `PAYMENT- -> **Note:** On TRON, `accepted.asset` and `accepted.payTo` use Base58 addresses, but the addresses inside `permit2Authorization` (`permitted.token`, `spender`, `witness.to`, `from`) are converted to `0x` hex form for EIP-712/TIP-712 signing. +> The TRON example uses Base58 addresses for the asset and recipient. Addresses inside `permit2Authorization` (`permitted.token`, `spender`, `witness.to`, `from`) use 20-byte `0x` hex for TIP-712 signing. In SDK 2.1.4, the resource server includes the selected `extra.assetTransferMethod` in each TRON `exact` quote. [TRON transfer methods](/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method). ```json { diff --git a/docs/x402/core-concepts/network-and-token-support.md b/docs/x402/core-concepts/network-and-token-support.md index 0f83be99..5e192996 100644 --- a/docs/x402/core-concepts/network-and-token-support.md +++ b/docs/x402/core-concepts/network-and-token-support.md @@ -96,7 +96,7 @@ x402 supports **TRC-20, BEP-20, and ERC-20** tokens. TRON/BSC routes use their c > **Extensibility**: The protocol is highly extensible. By registering tokens through the TRON token registry (`registerToken` from `@bankofai/x402-tron`) or an explicit `{ asset, amount, extra }` price on the server route, you can support any custom TRC-20 or BEP-20 token. -> **Token selection for the `exact` scheme**: EIP-3009 tokens (for example official Base USDC) settle gaslessly via `transferWithAuthorization`. Plain ERC-20 tokens (for example BSC USDC/USDT and TRON USDT/USDD) settle via the Permit2 path and need a one-time `approve(Permit2)` — on TRON the client auto-broadcasts it on first payment (on EVM it never does; see the sponsoring paths below), or, on TRON when the server advertises `trc20ApprovalResourceSponsoring` (SDK 1.2.0+), signs it and lets the facilitator sponsor and broadcast it (since 2.1.0 only with the client extension from `@bankofai/x402-tron-extensions` registered). You set the per-token method on the server under `accepts[].price.extra`; the SDK surfaces it on the wire as `accepts[].extra`: EIP-3009 → `{ name, version }`; plain ERC-20 → `{ assetTransferMethod: "permit2" }`. A permit2 asset that also implements EIP-2612 carries `{ name, version }` alongside `assetTransferMethod`; omitting that pair is precisely how a server tells clients to skip EIP-2612. Both sponsoring paths live inside the permit2 branch, so neither applies to an EIP-3009 asset. On a permit2 asset the client signs a gasless EIP-2612 permit when a `readContract` capability is available (from the signer or a configured RPC), the server advertises the `eip2612GasSponsoring` extension, `extra` carries both `name` and `version`, and the current Permit2 allowance does not already cover the payment. Note the asymmetry: a *missing* read capability skips the permit entirely, whereas a read that *throws* is caught and signing proceeds. Otherwise the client *tries* ERC-20 approval gas sponsoring, which needs `readContract`, the separate `erc20ApprovalGasSponsoring` extension from the server, a signer that can sign raw transactions, and a transaction count (from the signer or a configured RPC), and again an allowance that does not already cover the payment; there the client signs an `approve` for `MaxUint256` — always the max, regardless of the payment amount — that the facilitator broadcasts. When neither path qualifies the payload carries no sponsoring extension at all. Among the shipped default assets the `supportsEip2612` flag is set on MegaETH MegaUSD (mainnet) and on Mezo mUSD and Radius SBC (mainnet and testnet). +> **Token selection for the `exact` scheme**: EIP-3009 tokens (for example official Base USDC) settle gaslessly via `transferWithAuthorization`. Plain ERC-20 tokens (for example BSC USDC/USDT and TRON USDT/USDD) settle via the Permit2 path and need a one-time `approve(Permit2)` — on TRON the client auto-broadcasts it on first payment (on EVM it never does; see the sponsoring paths below), or, on TRON when the server advertises `trc20ApprovalResourceSponsoring` (SDK 1.2.0+), signs it and lets the facilitator sponsor and broadcast it (since 2.1.0 only with the client extension from `@bankofai/x402-tron-extensions` registered). See [TRON transfer methods](#tron-exact-transfer-method) for the TRON selection rules. On EVM, Permit2 assets carry `extra.assetTransferMethod: "permit2"`. An EVM Permit2 asset that also implements EIP-2612 carries `{ name, version }` alongside `assetTransferMethod`; omitting that pair is precisely how a server tells clients to skip EIP-2612. Both sponsoring paths live inside the permit2 branch, so neither applies to an EIP-3009 asset. On a permit2 asset the client signs a gasless EIP-2612 permit when a `readContract` capability is available (from the signer or a configured RPC), the server advertises the `eip2612GasSponsoring` extension, `extra` carries both `name` and `version`, and the current Permit2 allowance does not already cover the payment. Note the asymmetry: a *missing* read capability skips the permit entirely, whereas a read that *throws* is caught and signing proceeds. Otherwise the client *tries* ERC-20 approval gas sponsoring, which needs `readContract`, the separate `erc20ApprovalGasSponsoring` extension from the server, a signer that can sign raw transactions, and a transaction count (from the signer or a configured RPC), and again an allowance that does not already cover the payment; there the client signs an `approve` for `MaxUint256` — always the max, regardless of the payment amount — that the facilitator broadcasts. When neither path qualifies the payload carries no sponsoring extension at all. Among the shipped default assets the `supportsEip2612` flag is set on MegaETH MegaUSD (mainnet) and on Mezo mUSD and Radius SBC (mainnet and testnet). --- @@ -145,6 +145,18 @@ The `exact` scheme pays the exact amount advertised. It covers two token transfe The `exact` scheme conforms to the **v2 wire format** published by the **x402 Foundation**: a stock v2 client can pay a protected endpoint on this SDK's server directly, and this SDK's client can pay any v2-compliant server — no project-specific translation required. Transfer authorization data is carried in `payload.authorization` on the EIP-3009 path and in `payload.permit2Authorization` on the Permit2 path. +#### TRON `exact` transfer methods {#tron-exact-transfer-method} + +In SDK 2.1.4, the resource server resolves `extra.assetTransferMethod` in this order. + +1. Use the explicit method in `accepts[].price.extra.assetTransferMethod` if it is valid for the token. For `eip3009`, the token must implement `transferWithAuthorization`. Supply the token's TIP-712 domain `name` and `version`. +2. If the method is omitted, use the registered token's method when one is set. The USDT and USDD contracts listed above resolve to `permit2`. Setting `eip3009` for those contracts fails validation. +3. If neither specifies a method, use `permit2` when it is the only method advertised in the facilitator's `/supported` entry at `extra.supportedAssetTransferMethods`. When both are advertised or the list is absent, use `eip3009`. The server rejects any resolved method excluded by the advertised list. + +The resource server writes the resolved method into the quote's `extra.assetTransferMethod`. A client or facilitator receiving a quote that still omits it uses the registered method, with `eip3009` as the fallback. + +Use a TRC-20 token contract address and a positive decimal integer string in atomic units for `amount`. The SDK rejects malformed addresses and infrastructure contracts such as Permit2, the settlement proxies, and batch contracts and collectors. Use Base58 addresses in route configuration. The wallet-backed facilitator also normalizes 20-byte `0x` asset addresses before its contract reads. [TRON Exact specification](https://github.com/BofAI/x402/blob/v2.1.4/specs/schemes/exact/scheme_exact_tron.md). + ### `upto` Scheme Usage-based billing. The client signs a Permit2 authorization for up to a **maximum** amount; the server decides the **real usage** per request and settles only that (≤ max). One signature shape, a different charge each request — ideal for **metered billing** (LLM token usage, compute time, bandwidth). Available on EVM and TRON (both Permit2). diff --git a/docs/x402/faq.md b/docs/x402/faq.md index 2632abba..5eaac674 100644 --- a/docs/x402/faq.md +++ b/docs/x402/faq.md @@ -173,11 +173,11 @@ The flow mirrors a human user: Install the published packages in your TypeScript app and build against npm, for example: ```bash -pnpm add @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.2 @x402/evm@2.29.0 @bankofai/agent-wallet +pnpm add @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.4 @x402/evm@2.29.0 @bankofai/agent-wallet pnpm add @x402/express@2.29.0 ``` -Use the framework package that matches your server (`@x402/express`, `@x402/hono`, `@x402/fastify`, or `@x402/next`), at the same `2.29.0` as `@x402/core` — `@bankofai/x402-tron` 2.1.2 requires exactly `@x402/core@2.29.0`. Add `@bankofai/x402-tron-extensions@2.1.2` only if you use TRON resource sponsoring. The [`examples/typescript`](https://github.com/BofAI/x402/tree/main/examples/typescript) workspace is a runnable reference for client → server → facilitator flows, not a prerequisite for application development. +Use the framework package that matches your server (`@x402/express`, `@x402/hono`, `@x402/fastify`, or `@x402/next`), at the same `2.29.0` as `@x402/core` — `@bankofai/x402-tron` 2.1.4 requires exactly `@x402/core@2.29.0`. Add `@bankofai/x402-tron-extensions@2.1.4` only if you use TRON resource sponsoring. The [`examples/typescript`](https://github.com/BofAI/x402/tree/main/examples/typescript) workspace is a runnable reference for client → server → facilitator flows, not a prerequisite for application development. For TronWeb HTTP dependency overrides in your own application, see [Dependency security](/x402/sdk-features/#dependency-security). diff --git a/docs/x402/getting-started/quickstart-for-human.md b/docs/x402/getting-started/quickstart-for-human.md index dad3569e..269cd2f0 100644 --- a/docs/x402/getting-started/quickstart-for-human.md +++ b/docs/x402/getting-started/quickstart-for-human.md @@ -36,7 +36,7 @@ x402 is a **TypeScript-only** SDK: the TRON mechanism ships as `@bankofai/x402-t ### Checklist Before You Start -- [ ] **Node.js 24.22.1+** and **pnpm 11.1+** installed +- [ ] **Node.js 24.22.1+ (24.x) or 26.12.1+** and **pnpm 11.1+** installed - [ ] A dedicated **test wallet** created (see below) - [ ] Test tokens claimed (free) - [ ] A target x402-protected API URL, such as the `/credit` endpoint from [Quickstart for Sellers](./quickstart-for-sellers.md) @@ -99,11 +99,11 @@ x402 is a **TypeScript-only** SDK: the TRON mechanism ships as `@bankofai/x402-t Install the published npm packages in your TypeScript application: ```bash -pnpm add @bankofai/agent-wallet @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.2 +pnpm add @bankofai/agent-wallet @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.4 pnpm add -D tsx # to run the TypeScript entry point below ``` -Use `npm install` or `yarn add` with the same package names if your project does not use pnpm. Keep `@x402/core` and `@x402/fetch` at exactly `2.29.0` — `@bankofai/x402-tron` 2.1.2 declares `@x402/core@2.29.0` as an exact peer dependency. +Use `npm install` or `yarn add` with the same package names if your project does not use pnpm. Keep `@x402/core` and `@x402/fetch` at exactly `2.29.0` — `@bankofai/x402-tron` 2.1.4 declares `@x402/core@2.29.0` as an exact peer dependency. For TronWeb HTTP dependency overrides in your own application, see [Dependency security](/x402/sdk-features/#dependency-security). diff --git a/docs/x402/getting-started/quickstart-for-sellers.md b/docs/x402/getting-started/quickstart-for-sellers.md index 99310c61..034d1d5a 100644 --- a/docs/x402/getting-started/quickstart-for-sellers.md +++ b/docs/x402/getting-started/quickstart-for-sellers.md @@ -33,7 +33,7 @@ x402 is a **TypeScript-only** SDK: the TRON mechanism ships as `@bankofai/x402-t In your terminal (Terminal on macOS/Linux, or PowerShell/Command Prompt on Windows), run the following commands to confirm the required tools are installed: ```bash -node --version # Requires Node.js 24.22.1 or higher +node --version # Requires Node.js 24.22.1+ (24.x) or 26.12.1+ pnpm --version # Requires pnpm 11.1 or higher git --version # Version control tool ``` @@ -140,11 +140,11 @@ Deposit a small amount of official USDC on Base Mainnet. The resource server onl Install official Core, the Express adapter and the TRON/EVM payment schemes in your TypeScript API project: ```bash -pnpm add express @x402/core@2.29.0 @x402/express@2.29.0 @bankofai/x402-tron@2.1.2 @x402/evm@2.29.0 +pnpm add express @x402/core@2.29.0 @x402/express@2.29.0 @bankofai/x402-tron@2.1.4 @x402/evm@2.29.0 pnpm add -D tsx # to run the TypeScript entry point below ``` -Use the framework package that matches your server (`@x402/express`, `@x402/hono`, `@x402/fastify`, or `@x402/next`), at the same `2.29.0` as `@x402/core` — `@bankofai/x402-tron` 2.1.2 declares `@x402/core@2.29.0` as an exact peer dependency. Install `@x402/evm` only for BSC/Base routes. Use `npm install` or `yarn add` with the same package names if your project does not use pnpm. +Use the framework package that matches your server (`@x402/express`, `@x402/hono`, `@x402/fastify`, or `@x402/next`), at the same `2.29.0` as `@x402/core` — `@bankofai/x402-tron` 2.1.4 declares `@x402/core@2.29.0` as an exact peer dependency. Install `@x402/evm` only for BSC/Base routes. Use `npm install` or `yarn add` with the same package names if your project does not use pnpm. For TronWeb HTTP dependency overrides in your own application, see [Dependency security](/x402/sdk-features/#dependency-security). @@ -285,6 +285,8 @@ express() | `accepts[].scheme` | Payment scheme | `"exact"` | | `routes` | Map of `"METHOD /path"` → `{ accepts }` | `"GET /credit"` | +The TRON example uses Permit2 for `"1 USDT"`. When pricing a custom token with `{ asset, amount, extra }`, set `price.extra.assetTransferMethod` to match the token contract and use a positive integer amount in atomic units. See [TRON transfer methods](/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method). + **How it works:** When an unpaid request reaches your API, the middleware automatically returns an HTTP `402 Payment Required` response with payment instructions. The client SDK pays automatically and re-sends the request — the process is nearly invisible to the end user. --- @@ -358,7 +360,7 @@ new HTTPFacilitatorClient({ }); ``` -> **Key refreshes and retries:** Key creation and deletion take effect after the next successful Facilitator cache refresh (every 5 seconds in the built-in production configuration, independently per process). While the cache is fresh, unrecognized keys use anonymous access, so a successful call does not prove authentication. In v2.3.2, keyed verification and settlement requests receive `503 api_key_auth_unavailable` if the cache expires while refreshes are failing. Retain the authentication header and retry with backoff; see [authentication availability](../../core-concepts/facilitator#api-key-cache-and-authentication-availability). +> **Key refreshes and retries:** Key creation and deletion take effect after the next successful Facilitator cache refresh (every 5 seconds in the built-in production configuration, independently per process). While the cache is fresh, unrecognized keys use anonymous access, so a successful call does not prove authentication. Keyed verification and settlement requests receive `503 api_key_auth_unavailable` if the cache expires while refreshes are failing. Retain the authentication header and retry with backoff; see [authentication availability](../../core-concepts/facilitator#api-key-cache-and-authentication-availability). > ⚠️ **Security reminder:** Your API Key is a service credential — **treat it like a password and never commit it to Git**. diff --git a/docs/x402/sdk-features.md b/docs/x402/sdk-features.md index 38f97011..641b81c4 100644 --- a/docs/x402/sdk-features.md +++ b/docs/x402/sdk-features.md @@ -9,17 +9,15 @@ This page tracks the feature support of the x402 SDK. > **SDK (TypeScript-only)**: x402 is a **TypeScript-only** SDK. It publishes the TRON mechanism and the TRON resource-sponsoring extension as the `@bankofai/x402-tron` and `@bankofai/x402-tron-extensions` npm packages and builds on the official x402 Foundation `@x402/*` packages for Core, EVM, the HTTP/MCP integrations and the generic extensions. The source is maintained in a pnpm/turbo monorepo, but applications should depend on the published packages. The previous-generation Python + TypeScript SDK archive (`legacy/`) was removed from the repository in 2.0.0, and the `typescript/packages/legacy/` compatibility packages in 2.1.0. > -> **Current release: 2.1.2** (2026-11-10). The payment call chain now runs on official `@x402/core` `2.29.0`, which `@bankofai/x402-tron` `2.1.2` declares as an exact peer dependency; use the matching official HTTP/MCP integration (`@x402/fetch`, `@x402/axios`, `@x402/express`, `@x402/fastify`, `@x402/hono`, `@x402/next` or `@x402/mcp`, all `2.29.0`). TRON resource sponsoring ships as the separate `@bankofai/x402-tron-extensions` `2.1.2`, which pins the exact mechanism version — upgrade the two TRON packages together. EVM uses official `@x402/evm` `2.29.0` and the generic extensions official `@x402/extensions` `2.29.0`; the local EVM package and `@bankofai/x402-extensions` were removed. `@bankofai/x402-core` and the `@bankofai/x402-*` HTTP/MCP adapters built on it are not interchangeable with the 2.1 mechanism — new TRON integrations use official Core and adapters. Upgrading from 2.0 is a source migration; see the [TRON 2.1 migration guide](https://github.com/BofAI/x402/blob/main/docs/migrations/tron-2.1.md). The SDK requires **Node.js 24.22.1+**; the runnable examples use `@bankofai/agent-wallet` **3.0+**. +> **Current release: 2.1.4** (2026-11-23). The payment call chain now runs on official `@x402/core` `2.29.0`, which `@bankofai/x402-tron` `2.1.4` declares as an exact peer dependency; use the matching official HTTP/MCP integration (`@x402/fetch`, `@x402/axios`, `@x402/express`, `@x402/fastify`, `@x402/hono`, `@x402/next` or `@x402/mcp`, all `2.29.0`). TRON resource sponsoring ships as the separate `@bankofai/x402-tron-extensions` `2.1.4`, which pins the exact mechanism version — upgrade the two TRON packages together. EVM uses official `@x402/evm` `2.29.0` and the generic extensions official `@x402/extensions` `2.29.0`; the local EVM package and `@bankofai/x402-extensions` were removed. `@bankofai/x402-core` and the `@bankofai/x402-*` HTTP/MCP adapters built on it are not interchangeable with the 2.1 mechanism — new TRON integrations use official Core and adapters. Upgrading from 2.0 is a source migration; see the [TRON 2.1 migration guide](https://github.com/BofAI/x402/blob/v2.1.4/docs/migrations/tron-2.1.md). The SDK requires **Node.js 24.22.1+ (24.x) or 26.12.1+**; the runnable examples use `@bankofai/agent-wallet` **3.0+**. > **2.1.1 schema migration:** official Core now uses native **Zod 4.6.6+**. If your application composes schemas from `@x402/core/schemas`, use Zod 4 and read validation details from `error.issues`; the Zod 3 `error.errors` alias is removed. Payment-option arrays (`accepts`) are limited to **1,024 entries**, with oversized collections rejected before element validation. Upgrade the exact Core peer and matching transports together with both TRON packages. ## Dependency security {#dependency-security} -The SDK **2.1.2** repository lockfiles use **TronWeb 6.5.1** for both TRON packages and all 11 TypeScript examples. TronWeb 6.5.1 uses the same input snapshot for validation and execution in signing and contract calls. The official Core peer remains **2.29.0**. +The SDK **2.1.4** repository lockfiles resolve both TRON packages and the TypeScript examples to **TronWeb 6.5.2**, which applies stricter validation to node transaction responses and broadcast acknowledgments. The mechanism declares `tronweb: ^6.5.2`, and the resource extension pins `6.5.2`. Check your application lockfile for the resolved versions. [2.1.4 release notes](https://github.com/BofAI/x402/blob/v2.1.4/RELEASE_NOTES.md). -The published mechanism declares `tronweb: ^6.5.1`, so a fresh application install can resolve **6.5.2**. The resource extension still pins **6.5.1**, so both versions may be installed together. - -The SDK repository resolves TronWeb's Axios to **1.21.0** and follow-redirects to **1.16.2** through pnpm workspace overrides. **These overrides do not propagate to applications installing the npm packages.** Apply overrides in your own project, refresh its lockfile, and inspect the resolved dependency tree. The application example below covers TronWeb's `^6.5.1` range, including both 6.5.1 and 6.5.2. For pnpm, merge these entries into your root `pnpm-workspace.yaml`: +The SDK workspace pins TronWeb's Axios to **1.21.0** and follow-redirects to **1.16.2**. Apply the overrides in your application root, refresh its lockfile, and inspect the resolved dependency tree. The pnpm example below also covers dependencies that still resolve TronWeb 6.5.1. Merge the entries into your root `pnpm-workspace.yaml`. ```yaml overrides: @@ -27,7 +25,7 @@ overrides: "axios@1.21.0>follow-redirects": "1.16.2" ``` -For other package managers, use their root-project override mechanism. An upstream TronWeb release that includes the patched dependencies is another option after verifying SDK compatibility. See the [2.1.2 release notes](https://github.com/BofAI/x402/blob/main/RELEASE_NOTES.md). +For other package managers, use their root-project override mechanism. --- @@ -97,6 +95,8 @@ x402 defines five named payment schemes. Four ship as a client + server + facili | `exact_gasfree` | ❌ | ✅ | TRON-only. Pay with USDT/USDD **without holding TRX for gas** — a relayer pays the on-chain energy via the GasFree API. | | `auth-capture` | ⚠️ Client only | ❌ | Refundable Base Commerce Payments authorization/capture flow. The published package does not yet include its server or facilitator implementation. | +TRON `exact` in SDK 2.1.4 validates the token address, positive atomic amount, and transfer method before the client signs. The facilitator also checks that the authorization matches the method and requires successful reads of the payer's balance and any required Permit2 allowance before settlement. [TRON transfer methods](/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method) · [Facilitator errors](/x402/core-concepts/facilitator/#tron-exact-errors) + ### Payment flows (new in 1.1.0) A scheme/network server now declares which payment flows it supports per asset-transfer method. `upfront` and `escrow` travel on the wire as `extra.paymentFlow`; `authorization` is the default and is omitted from `extra` — its absence is the signal: diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/index.md b/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/index.md index ecd81e21..c3bb20b2 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/index.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/index.md @@ -7,6 +7,19 @@ description: 'BANK OF AI 各产品的更新与公告——全部产品,按时 BANK OF AI 各产品的更新与公告。 +
+
2026-11-24
+
+ +### TRON SDK 2.1.4 与 Facilitator 2.3.3 + +
Docsx402
+ +- 同步 TRON SDK 安装与 Facilitator 部署说明,补充 TronWeb 6.5.2 依赖以及 TRON `exact` 的校验规则。[详情](./x402/) + +
+
+
2026-11-12
diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/x402.md b/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/x402.md index 57dacb11..b90b9212 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/x402.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs-changelog/current/x402.md @@ -7,6 +7,20 @@ description: 'x402 支付协议、SDK 与 CLI 的版本发布记录。' x402 协议、SDK 与 [Wallet CLI 指引](/zh-Hans/wallet-cli/) 的版本发布记录。 +
+
2026-11-24
+
+ +### TRON SDK 2.1.4 与 Facilitator 2.3.3 + +
Docsx402
+ +- 两个 TRON SDK 包使用 TronWeb 6.5.2,精确 peer 依赖仍为 `@x402/core@2.29.0`。TRON `exact` 会拒绝无效资产、非正数金额与不匹配的转账方式。注册表中的 USDT 和 USDD 使用 Permit2。[SDK 功能矩阵](/zh-Hans/x402/sdk-features/) · [TRON 转账方式](/zh-Hans/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method) +- Facilitator 2.3.3 采用 SDK 2.1.4。必需的余额或额度读取失败时会拒绝结算,钱包适配器支持使用 20 字节的十六进制资产地址读取合约。[Facilitator 部署与 API](/zh-Hans/x402/core-concepts/facilitator/) + +
+
+
2026-11-12
diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/OfficialFacilitator.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/OfficialFacilitator.md index 0c7c3fea..15f08e9e 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/OfficialFacilitator.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/OfficialFacilitator.md @@ -137,7 +137,7 @@ curl -X POST https://facilitator.bankofai.io/settle \ ### Key 刷新与暂时性认证故障 -Facilitator v2.3.2 从 DevCenter 读取活动 Key 并缓存;内置生产配置每 **5 秒**刷新一次。新建和删除 Key 都须等到下一次成功刷新后才会影响认证,不能视为即时生效。各进程独立刷新,多副本不保证同时生效,数据库读取耗时也会影响实际生效时间。 +Facilitator 从 DevCenter 读取活动 Key 并缓存;内置生产配置每 **5 秒**刷新一次。新建和删除 Key 都须等到下一次成功刷新后才会影响认证,不能视为即时生效。各进程独立刷新,多副本不保证同时生效,数据库读取耗时也会影响实际生效时间。 缓存仍有效时,错误、尚未同步或已同步撤销的 Key 会按匿名请求处理,不会统一返回 401;成功调用不代表 Key 已被识别。尤其是按交易哈希或授权身份查询记录时,只有**有效且已识别的 Key**才会应用卖家过滤。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/facilitator.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/facilitator.md index 7c821c8b..ae11d199 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/facilitator.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/facilitator.md @@ -78,9 +78,9 @@ Facilitator 是一种中间件服务,主要负责: 如果您希望完全掌控结算钱包、RPC 节点、能量管理,或注册哪些网络与方案,又或有特定的隐私/合规要求,可以选择自己部署 Facilitator 服务。 -当前源码版本为 **v2.3.2**(2026-11-13):使用官方 `@x402/core`、`@x402/evm`、`@x402/extensions` **2.29.0**,TRON 机制与独立资源扩展 **2.1.2**,并将 `@bankofai/agent-wallet` 精确锁定到 **3.1.0-beta.1**。源码安装要求 Node.js **24.22.1+(24.x)或 26.12.1+**;Docker 与 CI 固定为 24.22.2,不再支持 Node.js 22。安装配置将 Zod 固定到 **4.6.7**,升级依赖时应保留此覆盖。部署说明见 [Facilitator v2.3.2 README](https://github.com/BofAI/x402-facilitator/blob/v2.3.2/README.md)。 +当前源码版本为 **v2.3.3**(2026-11-24):使用官方 `@x402/core`、`@x402/evm`、`@x402/extensions` **2.29.0**,TRON 机制与独立资源扩展 **2.1.4**,并将 `@bankofai/agent-wallet` 精确锁定到 **3.1.0-beta.1**。源码安装要求 Node.js **24.22.1+(24.x)或 26.12.1+**;Docker 与 CI 固定为 24.22.2,不再支持 Node.js 22。安装配置将 Zod 固定到 **4.6.7**,升级依赖时应保留此覆盖。部署说明见 [Facilitator v2.3.3 README](https://github.com/BofAI/x402-facilitator/blob/v2.3.3/README.md)。 -v2.3.2 使用单份 **TronWeb 6.5.1**。服务自身的安装覆盖将其 Axios 固定为 **1.21.1**,follow-redirects 的要求为 **^1.16.3**,发布版本的锁文件实际解析到 **1.16.3**;Hono Node Server 升级到 **2.1.6**。请使用发布版本的锁文件安装,更新依赖时保留这些覆盖。 +v2.3.3 使用单份 **TronWeb 6.5.2**。服务自身的安装覆盖将其 Axios 固定为 **1.21.1**,follow-redirects 的要求为 **^1.16.3**,发布版本的锁文件实际解析到 **1.16.3**;Hono Node Server 在锁文件中解析到 **2.1.6**。请使用发布版本的锁文件安装,更新依赖时保留这些覆盖。 本节部署说明针对完整的 `BofAI/x402-facilitator` 服务。SDK 的最小示例 `examples/typescript/facilitator/basic` 仅暴露 `/verify`、`/settle` 与 `/supported`,无需数据库;下述数据库与 DevCenter 要求适用于完整服务。 @@ -153,7 +153,19 @@ v2.3.0 的 EVM 钱包桥按网络与钱包共享进程内 nonce 队列,保存 > **不存在** `/fee/quote` 端点,各方案也完全不收取 facilitator 费用。支付记录以链上授权身份(`network` + `scheme` + `asset` + `payer` + `nonce`)为键,而非客户端提供的 payment ID。 -v2.3.0 还将缺失或非对象的 TRON `exact` 授权转换为协议级验证拒绝:`isValid: false`、`invalidReason: "invalid_exact_tron_payload_authorization"`,而非 HTTP 500。该兼容处理不吞掉实际 RPC 错误。 +### TRON `exact` 错误 {#tron-exact-errors} + +Facilitator v2.3.3 使用 SDK 2.1.4 校验 TRON `exact` 付款。下表中的 SDK 错误通过 HTTP `200` 响应返回。`/verify` 响应包含 `isValid: false` 与 `invalidReason`。`/settle` 响应包含 `success: false` 与 `errorReason`,广播前拒绝时 `transaction` 为空字符串。 + +| 错误码 | 触发条件 | +|--------|----------| +| `invalid_exact_tron_asset` | 资产地址格式无效,或指向已知的基础设施合约。 | +| `invalid_exact_tron_amount` | 金额超出 `uint256` 的正数范围,或格式不是十进制整数字符串。 | +| `invalid_exact_tron_asset_transfer_method` | 资产不支持指定的转账方式,或授权格式与所选方式不匹配。 | +| `invalid_exact_tron_payload_authorization` | 载荷缺少完整的授权,或同时包含两种授权格式。 | +| `chain_read_failed` | 必需的余额或 Permit2 额度读取失败。SDK 会在广播新的结算交易前拒绝该笔付款。 | + +这些错误码由支付方案返回。服务层的请求校验和 Permit2 防重放检查也可能先返回各自的错误。参见 [TRON 转账方式](/zh-Hans/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method)。 --- diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/http-402.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/http-402.md index 868d8729..95ca0fbd 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/http-402.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/http-402.md @@ -41,7 +41,7 @@ x402 定义了一组标准化 HTTP 标头用于支付通信: -> **注意:** 在 TRON 上,`accepted.asset` 和 `accepted.payTo` 使用 Base58 地址,但 `permit2Authorization` 内部的地址(`permitted.token`、`spender`、`witness.to`、`from`)会转换为 `0x` hex 格式以进行 EIP-712/TIP-712 签名。 +> 下面的 TRON 示例使用 Base58 表示资产和收款地址。`permit2Authorization` 内部的地址(`permitted.token`、`spender`、`witness.to`、`from`)使用 20 字节的 `0x` 十六进制格式进行 TIP-712 签名。SDK 2.1.4 的资源服务端会在每条 TRON `exact` 报价中带上选定的 `extra.assetTransferMethod`。参见 [TRON 转账方式](/zh-Hans/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method)。 ```json { diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/network-and-token-support.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/network-and-token-support.md index 9906db85..0cd6718a 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/network-and-token-support.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/core-concepts/network-and-token-support.md @@ -90,7 +90,7 @@ x402 支持 **TRC-20、BEP-20 和 ERC-20** 代币。TRON/BSC 路由使用各自 > **扩展支持**:协议具有高度的可扩展性。通过 TRON 代币注册表(`@bankofai/x402-tron` 的 `registerToken`)或在 server 路由上使用显式的 `{ asset, amount, extra }` 价格,您可以轻松配置并支持任意自定义的 TRC-20/BEP-20 代币。 -> **关于 `exact` 方案的代币选择**:EIP-3009 代币(如 Base 官方 USDC)通过 `transferWithAuthorization` 无 gas 结算。普通 ERC-20 代币(如 BSC USDC/USDT、TRON USDT/USDD)通过 Permit2 路径结算,需要一次性 `approve(Permit2)`——在 TRON 上客户端首次付款时自动广播(EVM 上从不广播,见下文的代付路径);在 TRON 上,若 server 声明了 `trc20ApprovalResourceSponsoring`(SDK 1.2.0+),则改为客户端签名、由 facilitator 赞助并广播(从 2.1.0 起须注册 `@bankofai/x402-tron-extensions` 中的客户端扩展)。每种代币的结算方式由你在 server 端 `accepts[].price.extra` 里配置,SDK 会在协议数据中以 `accepts[].extra` 下发:EIP-3009 → `{ name, version }`;普通 ERC-20 → `{ assetTransferMethod: "permit2" }`。若某个 permit2 资产同时实现了 EIP-2612,`extra` 会在 `assetTransferMethod` 之外一并带上 `{ name, version }`;反过来,省略这对字段正是服务端告诉客户端「跳过 EIP-2612」的方式。两条代付路径都位于 permit2 分支内,因此对 EIP-3009 资产一概不适用。在 permit2 资产上,客户端签名无 gas 的 EIP-2612 permit 需要同时满足:具备 `readContract` 能力(由签名方或已配置的 RPC 提供)、服务端声明了 `eip2612GasSponsoring` 扩展、`extra` 里 `name` 与 `version` 都在、且当前 Permit2 额度尚不足以覆盖本次支付。注意这里的不对称:**缺少**读取能力会直接跳过 permit,而读取**抛错**则会被捕获、签名照常进行。否则客户端会*尝试* ERC-20 授权 gas 代付,这条路径要求 `readContract` 能力、服务端声明另一个独立的 `erc20ApprovalGasSponsoring` 扩展、签名方能签原始交易,并能获取交易计数(由签名方或已配置的 RPC 提供),同样也要求现有额度不足;此时由客户端签名一笔 `MaxUint256` 的 `approve`——始终是最大值,与支付金额无关——由 facilitator 负责广播。两条路径都不满足时,载荷里不会带任何代付扩展。内置默认资产中带 `supportsEip2612` 标记的是 MegaETH MegaUSD(主网)以及 Mezo mUSD 与 Radius SBC(主网与测试网均有)。 +> **关于 `exact` 方案的代币选择**:EIP-3009 代币(如 Base 官方 USDC)通过 `transferWithAuthorization` 无 gas 结算。普通 ERC-20 代币(如 BSC USDC/USDT、TRON USDT/USDD)通过 Permit2 路径结算,需要一次性 `approve(Permit2)`——在 TRON 上客户端首次付款时自动广播(EVM 上从不广播,见下文的代付路径);在 TRON 上,若 server 声明了 `trc20ApprovalResourceSponsoring`(SDK 1.2.0+),则改为客户端签名、由 facilitator 赞助并广播(从 2.1.0 起须注册 `@bankofai/x402-tron-extensions` 中的客户端扩展)。TRON 的选择规则见 [TRON 转账方式](#tron-exact-transfer-method)。在 EVM 上,Permit2 资产的 `extra.assetTransferMethod` 为 `"permit2"`。若该资产同时实现了 EIP-2612,`extra` 会在 `assetTransferMethod` 之外一并带上 `{ name, version }`;反过来,省略这对字段正是服务端告诉客户端「跳过 EIP-2612」的方式。两条代付路径都位于 permit2 分支内,因此对 EIP-3009 资产一概不适用。在 permit2 资产上,客户端签名无 gas 的 EIP-2612 permit 需要同时满足:具备 `readContract` 能力(由签名方或已配置的 RPC 提供)、服务端声明了 `eip2612GasSponsoring` 扩展、`extra` 里 `name` 与 `version` 都在、且当前 Permit2 额度尚不足以覆盖本次支付。注意这里的不对称:**缺少**读取能力会直接跳过 permit,而读取**抛错**则会被捕获、签名照常进行。否则客户端会*尝试* ERC-20 授权 gas 代付,这条路径要求 `readContract` 能力、服务端声明另一个独立的 `erc20ApprovalGasSponsoring` 扩展、签名方能签原始交易,并能获取交易计数(由签名方或已配置的 RPC 提供),同样也要求现有额度不足;此时由客户端签名一笔 `MaxUint256` 的 `approve`——始终是最大值,与支付金额无关——由 facilitator 负责广播。两条路径都不满足时,载荷里不会带任何代付扩展。内置默认资产中带 `supportsEip2612` 标记的是 MegaETH MegaUSD(主网)以及 Mezo mUSD 与 Radius SBC(主网与测试网均有)。 ## 安全签名 @@ -127,6 +127,18 @@ x402 定义了五种命名支付方案。其中四种按链族提供完整的 cl `exact` 方案遵循 **x402 Foundation** 发布的 **v2 链路格式**:标准 v2 客户端可直接向本 SDK 的服务端发起付款请求,本 SDK 客户端也可直接访问任何 v2 兼容的服务端——无需项目特定的转换。转账授权数据在 EIP-3009 路径下位于 `payload.authorization`,在 Permit2 路径下位于 `payload.permit2Authorization`。 +#### TRON `exact` 转账方式 {#tron-exact-transfer-method} + +从 SDK 2.1.4 起,资源服务端按以下顺序确定 `extra.assetTransferMethod`。 + +1. 优先使用 `accepts[].price.extra.assetTransferMethod` 中为代币显式指定的有效方式。使用 `eip3009` 时,代币合约须实现 `transferWithAuthorization`,配置中须提供代币 TIP-712 域的 `name` 和 `version`。 +2. 未显式指定时,采用代币注册表中配置的方式。上表中的 USDT 和 USDD 合约均使用 `permit2`,指定 `eip3009` 会校验失败。 +3. 如果两处均未指定,且 Facilitator 在 `/supported` 对应条目的 `extra.supportedAssetTransferMethods` 中只公布了 `permit2`,则使用 `permit2`。两种方式都已公布或没有公布列表时,使用 `eip3009`。若已公布列表,服务端会拒绝列表之外的转账方式。 + +资源服务端将选定的方式写入报价的 `extra.assetTransferMethod`。如果客户端或 Facilitator 收到的报价仍缺少该字段,则使用注册表中的方式,无注册值时默认采用 `eip3009`。 + +资产应为 TRC-20 代币合约地址,`amount` 应为按最小单位表示的十进制正整数字符串。SDK 会拒绝格式无效的地址,以及 Permit2、结算代理、批量结算合约和资金收集合约等基础设施地址。路由配置使用 Base58 地址。基于钱包的 Facilitator 在读取合约时也会规范化 20 字节的 `0x` 资产地址。参见 [TRON Exact 规范](https://github.com/BofAI/x402/blob/v2.1.4/specs/schemes/exact/scheme_exact_tron.md)。 + ### `upto` 方案 按量计费。客户端签署最高至最大金额的 Permit2 授权;服务端按每次请求决定**实际用量**并仅结算该部分(≤ max)。一次签名形状,每次请求不同收费——非常适合**按量计费**(LLM Token 消耗、计算时长、带宽)。EVM 和 TRON 均支持(均走 Permit2)。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/faq.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/faq.md index 1305e07a..1ad58463 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/faq.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/faq.md @@ -155,11 +155,11 @@ x402 定义了五种命名支付方案。其中四种可端到端使用;`auth- 在您的 TypeScript 应用中安装已发布的 npm 包并基于这些包开发,例如: ```bash -pnpm add @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.2 @x402/evm@2.29.0 @bankofai/agent-wallet +pnpm add @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.4 @x402/evm@2.29.0 @bankofai/agent-wallet pnpm add @x402/express@2.29.0 ``` -请根据服务框架选择对应包(`@x402/express`、`@x402/hono`、`@x402/fastify` 或 `@x402/next`),版本与 `@x402/core` 一致为 `2.29.0`——`@bankofai/x402-tron` 2.1.2 要求精确的 `@x402/core@2.29.0`。仅在使用 TRON 资源赞助时再安装 `@bankofai/x402-tron-extensions@2.1.2`。[`examples/typescript`](https://github.com/BofAI/x402/tree/main/examples/typescript) 工作区是 client → server → facilitator 流程的可运行参考,不是应用开发的前置条件。 +请根据服务框架选择对应包(`@x402/express`、`@x402/hono`、`@x402/fastify` 或 `@x402/next`),版本与 `@x402/core` 一致为 `2.29.0`——`@bankofai/x402-tron` 2.1.4 要求精确的 `@x402/core@2.29.0`。仅在使用 TRON 资源赞助时再安装 `@bankofai/x402-tron-extensions@2.1.4`。[`examples/typescript`](https://github.com/BofAI/x402/tree/main/examples/typescript) 工作区是 client → server → facilitator 流程的可运行参考,不是应用开发的前置条件。 业务项目还需自行配置 TronWeb 的 HTTP 依赖覆盖,见[依赖安全](/zh-Hans/x402/sdk-features/#dependency-security)。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-human.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-human.md index d5093076..8da96f0f 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-human.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-human.md @@ -36,7 +36,7 @@ x402 是**仅 TypeScript** 的 SDK:TRON 机制以 `@bankofai/x402-tron` 发布 ### 开始前清单 -- [ ] 已安装 **Node.js 24.22.1+** 和 **pnpm 11.1+** +- [ ] 已安装 **Node.js 24.22.1+(24.x)或 26.12.1+** 和 **pnpm 11.1+** - [ ] 已创建专用**测试钱包**(见下文) - [ ] 已领取测试代币(免费) - [ ] 有一个目标 x402 保护的 API URL(例如按[卖家快速入门](./quickstart-for-sellers.md)启动的 `/credit` 接口) @@ -99,11 +99,11 @@ x402 是**仅 TypeScript** 的 SDK:TRON 机制以 `@bankofai/x402-tron` 发布 在您的 TypeScript 应用中安装已发布的 npm 包: ```bash -pnpm add @bankofai/agent-wallet @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.2 +pnpm add @bankofai/agent-wallet @x402/core@2.29.0 @x402/fetch@2.29.0 @bankofai/x402-tron@2.1.4 pnpm add -D tsx # 运行下面的 TypeScript 入口文件 ``` -如果您的项目不使用 pnpm,也可以用 `npm install` 或 `yarn add` 安装同名包。`@x402/core` 与 `@x402/fetch` 请保持精确的 `2.29.0`——`@bankofai/x402-tron` 2.1.2 将 `@x402/core@2.29.0` 声明为精确版本的 peer 依赖。 +如果您的项目不使用 pnpm,也可以用 `npm install` 或 `yarn add` 安装同名包。`@x402/core` 与 `@x402/fetch` 请保持精确的 `2.29.0`——`@bankofai/x402-tron` 2.1.4 将 `@x402/core@2.29.0` 声明为精确版本的 peer 依赖。 业务项目还需自行配置 TronWeb 的 HTTP 依赖覆盖,见[依赖安全](/zh-Hans/x402/sdk-features/#dependency-security)。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-sellers.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-sellers.md index 011f6dbc..6432689e 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-sellers.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/getting-started/quickstart-for-sellers.md @@ -33,7 +33,7 @@ x402 是**仅 TypeScript** 的 SDK:TRON 机制以 `@bankofai/x402-tron` 发布 在终端(macOS/Linux 的 Terminal,或 Windows 的 PowerShell/命令提示符)中运行以下命令,确认所需工具已安装: ```bash -node --version # 需要 Node.js 24.22.1 或更高版本 +node --version # 需要 Node.js 24.22.1+(24.x)或 26.12.1+ pnpm --version # 需要 pnpm 11.1 或更高版本 git --version # 版本控制工具 ``` @@ -140,11 +140,11 @@ git --version # 版本控制工具 在您的 TypeScript API 项目中安装官方 Core、Express 适配器以及 TRON/EVM 支付 scheme: ```bash -pnpm add express @x402/core@2.29.0 @x402/express@2.29.0 @bankofai/x402-tron@2.1.2 @x402/evm@2.29.0 +pnpm add express @x402/core@2.29.0 @x402/express@2.29.0 @bankofai/x402-tron@2.1.4 @x402/evm@2.29.0 pnpm add -D tsx # 运行下面的 TypeScript 入口文件 ``` -请根据服务框架选择对应包(`@x402/express`、`@x402/hono`、`@x402/fastify` 或 `@x402/next`),版本与 `@x402/core` 一致为 `2.29.0`——`@bankofai/x402-tron` 2.1.2 将 `@x402/core@2.29.0` 声明为精确版本的 peer 依赖。`@x402/evm` 仅在使用 BSC/Base 路由时需要。如果项目不使用 pnpm,也可以用 `npm install` 或 `yarn add` 安装同名包。 +请根据服务框架选择对应包(`@x402/express`、`@x402/hono`、`@x402/fastify` 或 `@x402/next`),版本与 `@x402/core` 一致为 `2.29.0`——`@bankofai/x402-tron` 2.1.4 将 `@x402/core@2.29.0` 声明为精确版本的 peer 依赖。`@x402/evm` 仅在使用 BSC/Base 路由时需要。如果项目不使用 pnpm,也可以用 `npm install` 或 `yarn add` 安装同名包。 业务项目还需自行配置 TronWeb 的 HTTP 依赖覆盖,见[依赖安全](/zh-Hans/x402/sdk-features/#dependency-security)。 @@ -283,6 +283,8 @@ express() | `accepts[].scheme` | 付款方式 | `"exact"` | | `routes` | `"METHOD /path"` → `{ accepts }` 的映射 | `"GET /credit"` | +TRON 示例中的 `"1 USDT"` 会使用 Permit2。若通过 `{ asset, amount, extra }` 为自定义代币定价,请根据代币合约能力设置 `price.extra.assetTransferMethod`,并使用正整数的最小单位金额。详见 [TRON 转账方式](/zh-Hans/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method)。 + **工作原理:** 当未付款请求到达您的 API 时,中间件自动返回 HTTP `402 Payment Required` 响应并携带付款要求。client SDK 自动完成付款并重发请求——对终端用户几乎不可见。 --- @@ -356,7 +358,7 @@ new HTTPFacilitatorClient({ }); ``` -> **Key 刷新与重试:** 新建或删除 Key 在 Facilitator 下一次成功刷新缓存后才生效(内置生产配置每 5 秒刷新,各进程独立维护)。缓存仍有效时,未识别的 Key 按匿名请求处理,成功调用不代表认证成功。v2.3.2 在缓存过期且无法刷新时,对带 Key 的验证和结算请求返回 `503 api_key_auth_unavailable`。请保留认证头并退避重试,详见[认证可用性说明](../../core-concepts/facilitator#api-key-缓存与认证不可用)。 +> **Key 刷新与重试:** 新建或删除 Key 在 Facilitator 下一次成功刷新缓存后才生效(内置生产配置每 5 秒刷新,各进程独立维护)。缓存仍有效时,未识别的 Key 按匿名请求处理,成功调用不代表认证成功。在缓存过期且无法刷新时,对带 Key 的验证和结算请求返回 `503 api_key_auth_unavailable`。请保留认证头并退避重试,详见[认证可用性说明](../../core-concepts/facilitator#api-key-缓存与认证不可用)。 > ⚠️ **安全提醒:** API Key 是服务凭据——**像密码一样保管,切勿提交到 Git**。 diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/sdk-features.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/sdk-features.md index ff32771d..0d520189 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/sdk-features.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/x402/sdk-features.md @@ -9,17 +9,15 @@ description: 'x402 TypeScript SDK 的功能支持矩阵:基于官方 @x402/* C > **SDK(仅 TypeScript)**:x402 是一个**仅 TypeScript** 的 SDK。TRON 机制与 TRON 资源赞助扩展以 `@bankofai/x402-tron` 与 `@bankofai/x402-tron-extensions` npm 包发布,Core、EVM、HTTP/MCP 集成和通用扩展则直接使用 x402 Foundation 官方的 `@x402/*` 包。源码由 pnpm/turbo monorepo 维护,但应用应依赖已发布的包。上一代 Python + TypeScript SDK 的 `legacy/` 归档已在 2.0.0 中从仓库移除,`typescript/packages/legacy/` 下的兼容包也已在 2.1.0 中移除。 > -> **当前版本:2.1.2**(2026-11-10)。付款调用链改为基于官方 `@x402/core` `2.29.0`,`@bankofai/x402-tron` `2.1.2` 将其声明为精确版本的 peer 依赖;请搭配对应的官方 HTTP/MCP 集成(`@x402/fetch`、`@x402/axios`、`@x402/express`、`@x402/fastify`、`@x402/hono`、`@x402/next` 或 `@x402/mcp`,均为 `2.29.0`)。TRON 资源赞助由独立的 `@bankofai/x402-tron-extensions` `2.1.2` 提供,它锁定机制包的精确版本——两个 TRON 包需一起升级。EVM 直接使用官方 `@x402/evm` `2.29.0`,通用扩展使用官方 `@x402/extensions` `2.29.0`;本地 EVM 包与 `@bankofai/x402-extensions` 已移除。`@bankofai/x402-core` 及基于它的 `@bankofai/x402-*` HTTP/MCP 适配器不能与 2.1 机制混用——新的 TRON 集成请使用官方 Core 与适配器。从 2.0 升级需要迁移源码,见 [TRON 2.1 迁移指南](https://github.com/BofAI/x402/blob/main/docs/migrations/tron-2.1.md)。SDK 要求 **Node.js 24.22.1+**;可运行示例使用 `@bankofai/agent-wallet` **3.0+**。 +> **当前版本:2.1.4**(2026-11-23)。付款调用链改为基于官方 `@x402/core` `2.29.0`,`@bankofai/x402-tron` `2.1.4` 将其声明为精确版本的 peer 依赖;请搭配对应的官方 HTTP/MCP 集成(`@x402/fetch`、`@x402/axios`、`@x402/express`、`@x402/fastify`、`@x402/hono`、`@x402/next` 或 `@x402/mcp`,均为 `2.29.0`)。TRON 资源赞助由独立的 `@bankofai/x402-tron-extensions` `2.1.4` 提供,它锁定机制包的精确版本——两个 TRON 包需一起升级。EVM 直接使用官方 `@x402/evm` `2.29.0`,通用扩展使用官方 `@x402/extensions` `2.29.0`;本地 EVM 包与 `@bankofai/x402-extensions` 已移除。`@bankofai/x402-core` 及基于它的 `@bankofai/x402-*` HTTP/MCP 适配器不能与 2.1 机制混用——新的 TRON 集成请使用官方 Core 与适配器。从 2.0 升级需要迁移源码,见 [TRON 2.1 迁移指南](https://github.com/BofAI/x402/blob/v2.1.4/docs/migrations/tron-2.1.md)。SDK 要求 **Node.js 24.22.1+(24.x)或 26.12.1+**;可运行示例使用 `@bankofai/agent-wallet` **3.0+**。 > **2.1.1 Schema 迁移**:官方 Core 现使用原生 **Zod 4.6.6+**。应用若组合 `@x402/core/schemas` 中的 Schema,须使用 Zod 4,并通过 `error.issues` 读取校验详情;Zod 3 的 `error.errors` 别名已移除。付款选项数组(`accepts`)最多 **1,024 项**,超长集合会在逐项校验前被拒绝。升级两个 TRON 包时,同时升级精确版本的 Core peer 及对应传输包。 ## 依赖安全 {#dependency-security} -SDK **2.1.2** 仓库的锁文件中,两个 TRON 包及全部 11 个 TypeScript 示例使用 **TronWeb 6.5.1**。该版本在签名与合约调用中使用同一份输入快照进行校验和执行;官方 Core peer 仍为 **2.29.0**。 +SDK **2.1.4** 仓库的锁文件将两个 TRON 包及 TypeScript 示例解析到 **TronWeb 6.5.2**。该版本加强了对节点交易响应和广播确认的校验。机制包声明 `tronweb: ^6.5.2`,资源扩展固定使用 `6.5.2`。实际安装版本以应用的锁文件为准。参见 [2.1.4 发布说明](https://github.com/BofAI/x402/blob/v2.1.4/RELEASE_NOTES.md)。 -已发布的机制包声明 `tronweb: ^6.5.1`,因此业务项目全新安装时可能解析到 **6.5.2**。资源扩展仍固定为 **6.5.1**,两个版本可能同时存在。 - -SDK 仓库通过 pnpm 工作区覆盖,将 TronWeb 的 Axios 解析为 **1.21.0**、follow-redirects 解析为 **1.16.2**。**这些覆盖不会传递给安装 npm 包的应用。** 业务项目须自行配置覆盖、刷新锁文件并检查实际依赖树。下方业务项目示例覆盖 TronWeb 的 `^6.5.1` 范围,包括 6.5.1 与 6.5.2。使用 pnpm 时,将以下条目合并到根目录的 `pnpm-workspace.yaml`: +SDK 工作区将 TronWeb 使用的 Axios 固定为 **1.21.0**,follow-redirects 固定为 **1.16.2**。请在应用根目录配置覆盖,刷新锁文件并检查实际依赖树。下面的 pnpm 配置也涵盖仍使用 TronWeb 6.5.1 的依赖,可将其合并到项目根目录的 `pnpm-workspace.yaml`。 ```yaml overrides: @@ -27,7 +25,7 @@ overrides: "axios@1.21.0>follow-redirects": "1.16.2" ``` -其他包管理器请使用项目根级别的依赖覆盖机制。也可在验证 SDK 兼容性后,使用已包含修复依赖的上游 TronWeb 版本。详见 [2.1.2 发布说明](https://github.com/BofAI/x402/blob/main/RELEASE_NOTES.md)。 +其他包管理器请使用项目根目录的依赖覆盖机制。 --- @@ -97,6 +95,8 @@ x402 定义了五种命名付款方案。其中四种按链族提供 client + se | `exact_gasfree` | ❌ | ✅ | 仅 TRON。用 USDT/USDD 付款**无需持有 TRX 支付 gas**——由 relayer 通过 GasFree API 支付链上 energy。 | | `auth-capture` | ⚠️ 仅 Client | ❌ | 可退款的 Base Commerce Payments 授权/扣款流程。当前发布包尚未提供对应的 server 或 facilitator 实现。 | +SDK 2.1.4 会在客户端签名前校验 TRON `exact` 的资产地址、正整数最小单位金额与转账方式。Facilitator 还会核对授权格式是否匹配选定方式,并在结算前读取付款方余额及适用的 Permit2 额度。 [TRON 转账方式](/zh-Hans/x402/core-concepts/network-and-token-support/#tron-exact-transfer-method) · [Facilitator 错误](/zh-Hans/x402/core-concepts/facilitator/#tron-exact-errors) + ### 付款流程(1.1.0 新增) scheme/network server 现在会按资产转账方式声明自己支持哪些付款流程。`upfront` 与 `escrow` 会通过 `extra.paymentFlow` 在协议中传递;`authorization` 是默认流程,不会写入 `extra`——字段缺失即代表它: diff --git a/package.json b/package.json index ffcde952..005d0a05 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@x402-tron/docs", - "version": "1.5.8", + "version": "1.5.9", "description": "x402-tron documentation", "license": "MIT",