diff --git a/e2e/clients/axios/README.md b/e2e/clients/axios/README.md index ff690e41..cfc7e861 100644 --- a/e2e/clients/axios/README.md +++ b/e2e/clients/axios/README.md @@ -1,6 +1,6 @@ # E2E Test Client: TypeScript Axios -This client demonstrates and tests the `@x402/axios` package with EVM, SVM, and Stellar payment support. +This client demonstrates and tests the `@bankofai/x402-axios` package with EVM, SVM, and Stellar payment support. ## What It Tests @@ -24,13 +24,13 @@ This client demonstrates and tests the `@x402/axios` package with EVM, SVM, and ```typescript import axios from "axios"; -import { wrapAxiosWithPayment } from "@x402/axios"; -import { x402Client } from "@x402/core/client"; -import { ExactEvmClient } from "@x402/evm"; -import { ExactEvmClientV1 } from "@x402/evm/v1"; -import { ExactSvmClient } from "@x402/svm"; -import { ExactSvmClientV1 } from "@x402/svm/v1"; -import { ExactStellarClient } from "@x402/stellar"; +import { wrapAxiosWithPayment } from "@bankofai/x402-axios"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactEvmClient } from "@bankofai/x402-evm"; +import { ExactEvmClientV1 } from "@bankofai/x402-evm/v1"; +import { ExactSvmClient } from "@bankofai/x402-svm"; +import { ExactSvmClientV1 } from "@bankofai/x402-svm/v1"; +import { ExactStellarClient } from "@bankofai/x402-stellar"; // Build x402 client with direct registration const client = new x402Client() @@ -117,12 +117,12 @@ pnpm start ## Package Dependencies -- `@x402/axios` - Axios wrapper with payment handling -- `@x402/core` - Core x402 client and types -- `@x402/evm` - EVM payment mechanisms (V2) -- `@x402/evm/v1` - EVM payment mechanisms (V1) -- `@x402/svm` - SVM payment mechanisms (V2) -- `@x402/svm/v1` - SVM payment mechanisms (V1) -- `@x402/stellar` - Stellar payment mechanisms (V2) +- `@bankofai/x402-axios` - Axios wrapper with payment handling +- `@bankofai/x402-core` - Core x402 client and types +- `@bankofai/x402-evm` - EVM payment mechanisms (V2) +- `@bankofai/x402-evm/v1` - EVM payment mechanisms (V1) +- `@bankofai/x402-svm` - SVM payment mechanisms (V2) +- `@bankofai/x402-svm/v1` - SVM payment mechanisms (V1) +- `@bankofai/x402-stellar` - Stellar payment mechanisms (V2) - `viem` - Ethereum library for account creation - `@solana/kit` - Solana keypair utilities diff --git a/e2e/clients/fetch/README.md b/e2e/clients/fetch/README.md index 33bcf7dd..97a8b364 100644 --- a/e2e/clients/fetch/README.md +++ b/e2e/clients/fetch/README.md @@ -1,6 +1,6 @@ # E2E Test Client: TypeScript Fetch -This client demonstrates and tests the `@x402/fetch` package with EVM, SVM, and Stellar payment support. +This client demonstrates and tests the `@bankofai/x402-fetch` package with EVM, SVM, and Stellar payment support. ## What It Tests @@ -23,13 +23,13 @@ This client demonstrates and tests the `@x402/fetch` package with EVM, SVM, and ### Usage Pattern ```typescript -import { wrapFetchWithPayment } from "@x402/fetch"; -import { x402Client } from "@x402/core/client"; -import { ExactEvmClient } from "@x402/evm"; -import { ExactEvmClientV1 } from "@x402/evm/v1"; -import { ExactSvmClient } from "@x402/svm"; -import { ExactSvmClientV1 } from "@x402/svm/v1"; -import { ExactStellarClient } from "@x402/stellar"; +import { wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactEvmClient } from "@bankofai/x402-evm"; +import { ExactEvmClientV1 } from "@bankofai/x402-evm/v1"; +import { ExactSvmClient } from "@bankofai/x402-svm"; +import { ExactSvmClientV1 } from "@bankofai/x402-svm/v1"; +import { ExactStellarClient } from "@bankofai/x402-stellar"; // Build x402 client with direct registration const client = new x402Client() @@ -116,12 +116,12 @@ pnpm start ## Package Dependencies -- `@x402/fetch` - HTTP wrapper with payment handling -- `@x402/core` - Core x402 client and types -- `@x402/evm` - EVM payment mechanisms (V2) -- `@x402/evm/v1` - EVM payment mechanisms (V1) -- `@x402/svm` - SVM payment mechanisms (V2) -- `@x402/svm/v1` - SVM payment mechanisms (V1) -- `@x402/stellar` - Stellar payment mechanisms (V2) +- `@bankofai/x402-fetch` - HTTP wrapper with payment handling +- `@bankofai/x402-core` - Core x402 client and types +- `@bankofai/x402-evm` - EVM payment mechanisms (V2) +- `@bankofai/x402-evm/v1` - EVM payment mechanisms (V1) +- `@bankofai/x402-svm` - SVM payment mechanisms (V2) +- `@bankofai/x402-svm/v1` - SVM payment mechanisms (V1) +- `@bankofai/x402-stellar` - Stellar payment mechanisms (V2) - `viem` - Ethereum library for account creation - `@solana/kit` - Solana keypair utilities diff --git a/e2e/coinbase/facilitators/typescript/README.md b/e2e/coinbase/facilitators/typescript/README.md index a87bbcad..4b25a759 100644 --- a/e2e/coinbase/facilitators/typescript/README.md +++ b/e2e/coinbase/facilitators/typescript/README.md @@ -71,12 +71,12 @@ const facilitator = new x402Facilitator() ### Facilitator Setup ```typescript -import { x402Facilitator } from "@x402/core/facilitator"; -import { ExactEvmFacilitator } from "@x402/evm"; -import { ExactEvmFacilitatorV1, NETWORKS as EVM_NETWORKS } from "@x402/evm/v1"; -import { ExactSvmFacilitator } from "@x402/svm"; -import { ExactSvmFacilitatorV1, NETWORKS as SVM_NETWORKS } from "@x402/svm/v1"; -import { ExactStellarFacilitator } from "@x402/stellar"; +import { x402Facilitator } from "@bankofai/x402-core/facilitator"; +import { ExactEvmFacilitator } from "@bankofai/x402-evm"; +import { ExactEvmFacilitatorV1, NETWORKS as EVM_NETWORKS } from "@bankofai/x402-evm/v1"; +import { ExactSvmFacilitator } from "@bankofai/x402-svm"; +import { ExactSvmFacilitatorV1, NETWORKS as SVM_NETWORKS } from "@bankofai/x402-svm/v1"; +import { ExactStellarFacilitator } from "@bankofai/x402-stellar"; // Create facilitator with bazaar extension const facilitator = new x402Facilitator() @@ -105,7 +105,7 @@ EVM_NETWORKS.forEach(network => { ```typescript import express from "express"; -import { createFacilitatorRouter } from "@x402/server/facilitator"; +import { createFacilitatorRouter } from "@bankofai/x402-server/facilitator"; const app = express(); app.use(express.json()); @@ -123,7 +123,7 @@ app.listen(port, () => { 1. **Extension Registration** - Bazaar discovery 2. **Comprehensive Network Support** - All EVM V1 networks, all SVM V1 networks 3. **Wildcard Schemes** - Efficient V2 registration with `eip155:*`, `solana:*`, and `stellar:*` -4. **HTTP Router Integration** - `@x402/server/facilitator` for Express +4. **HTTP Router Integration** - `@bankofai/x402-server/facilitator` for Express 5. **Real Signers** - Actual blockchain transaction submission 6. **Multi-Protocol** - V1 and V2 side-by-side @@ -177,13 +177,13 @@ pnpm start ## Package Dependencies -- `@x402/core` - Core facilitator -- `@x402/server` - Facilitator HTTP router -- `@x402/evm` - EVM facilitator (V2) -- `@x402/evm/v1` - EVM facilitator (V1) + NETWORKS -- `@x402/svm` - SVM facilitator (V2) -- `@x402/svm/v1` - SVM facilitator (V1) + NETWORKS -- `@x402/stellar` - Stellar facilitator (V2, SEP-41) +- `@bankofai/x402-core` - Core facilitator +- `@bankofai/x402-server` - Facilitator HTTP router +- `@bankofai/x402-evm` - EVM facilitator (V2) +- `@bankofai/x402-evm/v1` - EVM facilitator (V1) + NETWORKS +- `@bankofai/x402-svm` - SVM facilitator (V2) +- `@bankofai/x402-svm/v1` - SVM facilitator (V1) + NETWORKS +- `@bankofai/x402-stellar` - Stellar facilitator (V2, SEP-41) - `express` - HTTP server - `viem` - Ethereum transactions - `@solana/web3.js` - Solana transactions diff --git a/e2e/coinbase/servers/express/README.md b/e2e/coinbase/servers/express/README.md index 89623ce0..124431c6 100644 --- a/e2e/coinbase/servers/express/README.md +++ b/e2e/coinbase/servers/express/README.md @@ -23,10 +23,10 @@ This server demonstrates and tests the x402 Express.js middleware with EVM, SVM, ```typescript import express from "express"; -import { x402Middleware } from "@x402/server/express"; -import { ExactEvmServer } from "@x402/evm"; -import { ExactSvmServer } from "@x402/svm"; -import { ExactStellarServer } from "@x402/stellar"; +import { x402Middleware } from "@bankofai/x402-server/express"; +import { ExactEvmServer } from "@bankofai/x402-evm"; +import { ExactSvmServer } from "@bankofai/x402-svm"; +import { ExactStellarServer } from "@bankofai/x402-stellar"; const app = express(); @@ -170,11 +170,11 @@ PAYMENT-RESPONSE: ## Package Dependencies -- `@x402/server` - Express middleware -- `@x402/evm` - EVM server -- `@x402/svm` - SVM server -- `@x402/stellar` - Stellar server -- `@x402/extensions/bazaar` - Discovery extension +- `@bankofai/x402-server` - Express middleware +- `@bankofai/x402-evm` - EVM server +- `@bankofai/x402-svm` - SVM server +- `@bankofai/x402-stellar` - Stellar server +- `@bankofai/x402-extensions/bazaar` - Discovery extension - `express` - HTTP server framework ## Implementation Highlights diff --git a/e2e/facilitators/typescript/README.md b/e2e/facilitators/typescript/README.md index a87bbcad..4b25a759 100644 --- a/e2e/facilitators/typescript/README.md +++ b/e2e/facilitators/typescript/README.md @@ -71,12 +71,12 @@ const facilitator = new x402Facilitator() ### Facilitator Setup ```typescript -import { x402Facilitator } from "@x402/core/facilitator"; -import { ExactEvmFacilitator } from "@x402/evm"; -import { ExactEvmFacilitatorV1, NETWORKS as EVM_NETWORKS } from "@x402/evm/v1"; -import { ExactSvmFacilitator } from "@x402/svm"; -import { ExactSvmFacilitatorV1, NETWORKS as SVM_NETWORKS } from "@x402/svm/v1"; -import { ExactStellarFacilitator } from "@x402/stellar"; +import { x402Facilitator } from "@bankofai/x402-core/facilitator"; +import { ExactEvmFacilitator } from "@bankofai/x402-evm"; +import { ExactEvmFacilitatorV1, NETWORKS as EVM_NETWORKS } from "@bankofai/x402-evm/v1"; +import { ExactSvmFacilitator } from "@bankofai/x402-svm"; +import { ExactSvmFacilitatorV1, NETWORKS as SVM_NETWORKS } from "@bankofai/x402-svm/v1"; +import { ExactStellarFacilitator } from "@bankofai/x402-stellar"; // Create facilitator with bazaar extension const facilitator = new x402Facilitator() @@ -105,7 +105,7 @@ EVM_NETWORKS.forEach(network => { ```typescript import express from "express"; -import { createFacilitatorRouter } from "@x402/server/facilitator"; +import { createFacilitatorRouter } from "@bankofai/x402-server/facilitator"; const app = express(); app.use(express.json()); @@ -123,7 +123,7 @@ app.listen(port, () => { 1. **Extension Registration** - Bazaar discovery 2. **Comprehensive Network Support** - All EVM V1 networks, all SVM V1 networks 3. **Wildcard Schemes** - Efficient V2 registration with `eip155:*`, `solana:*`, and `stellar:*` -4. **HTTP Router Integration** - `@x402/server/facilitator` for Express +4. **HTTP Router Integration** - `@bankofai/x402-server/facilitator` for Express 5. **Real Signers** - Actual blockchain transaction submission 6. **Multi-Protocol** - V1 and V2 side-by-side @@ -177,13 +177,13 @@ pnpm start ## Package Dependencies -- `@x402/core` - Core facilitator -- `@x402/server` - Facilitator HTTP router -- `@x402/evm` - EVM facilitator (V2) -- `@x402/evm/v1` - EVM facilitator (V1) + NETWORKS -- `@x402/svm` - SVM facilitator (V2) -- `@x402/svm/v1` - SVM facilitator (V1) + NETWORKS -- `@x402/stellar` - Stellar facilitator (V2, SEP-41) +- `@bankofai/x402-core` - Core facilitator +- `@bankofai/x402-server` - Facilitator HTTP router +- `@bankofai/x402-evm` - EVM facilitator (V2) +- `@bankofai/x402-evm/v1` - EVM facilitator (V1) + NETWORKS +- `@bankofai/x402-svm` - SVM facilitator (V2) +- `@bankofai/x402-svm/v1` - SVM facilitator (V1) + NETWORKS +- `@bankofai/x402-stellar` - Stellar facilitator (V2, SEP-41) - `express` - HTTP server - `viem` - Ethereum transactions - `@solana/web3.js` - Solana transactions diff --git a/e2e/servers/express/README.md b/e2e/servers/express/README.md index 89623ce0..124431c6 100644 --- a/e2e/servers/express/README.md +++ b/e2e/servers/express/README.md @@ -23,10 +23,10 @@ This server demonstrates and tests the x402 Express.js middleware with EVM, SVM, ```typescript import express from "express"; -import { x402Middleware } from "@x402/server/express"; -import { ExactEvmServer } from "@x402/evm"; -import { ExactSvmServer } from "@x402/svm"; -import { ExactStellarServer } from "@x402/stellar"; +import { x402Middleware } from "@bankofai/x402-server/express"; +import { ExactEvmServer } from "@bankofai/x402-evm"; +import { ExactSvmServer } from "@bankofai/x402-svm"; +import { ExactStellarServer } from "@bankofai/x402-stellar"; const app = express(); @@ -170,11 +170,11 @@ PAYMENT-RESPONSE: ## Package Dependencies -- `@x402/server` - Express middleware -- `@x402/evm` - EVM server -- `@x402/svm` - SVM server -- `@x402/stellar` - Stellar server -- `@x402/extensions/bazaar` - Discovery extension +- `@bankofai/x402-server` - Express middleware +- `@bankofai/x402-evm` - EVM server +- `@bankofai/x402-svm` - SVM server +- `@bankofai/x402-stellar` - Stellar server +- `@bankofai/x402-extensions/bazaar` - Discovery extension - `express` - HTTP server framework ## Implementation Highlights diff --git a/e2e/servers/hono/README.md b/e2e/servers/hono/README.md index 9d0c51fd..22385c45 100644 --- a/e2e/servers/hono/README.md +++ b/e2e/servers/hono/README.md @@ -23,10 +23,10 @@ This server demonstrates and tests the x402 Hono middleware with EVM, SVM, and o ```typescript import express from "express"; -import { x402Middleware } from "@x402/server/express"; -import { ExactEvmServer } from "@x402/evm"; -import { ExactEvmServer } from "@x402/svm"; -import { ExactStellarServer } from "@x402/stellar"; +import { x402Middleware } from "@bankofai/x402-server/express"; +import { ExactEvmServer } from "@bankofai/x402-evm"; +import { ExactEvmServer } from "@bankofai/x402-svm"; +import { ExactStellarServer } from "@bankofai/x402-stellar"; const app = express(); @@ -170,11 +170,11 @@ PAYMENT-RESPONSE: ## Package Dependencies -- `@x402/server` - Express middleware -- `@x402/evm` - EVM service -- `@x402/svm` - SVM service -- `@x402/stellar` - Stellar server (optional) -- `@x402/extensions/bazaar` - Discovery extension +- `@bankofai/x402-server` - Express middleware +- `@bankofai/x402-evm` - EVM service +- `@bankofai/x402-svm` - SVM service +- `@bankofai/x402-stellar` - Stellar server (optional) +- `@bankofai/x402-extensions/bazaar` - Discovery extension - `hono` - HTTP server framework ## Implementation Highlights diff --git a/examples/python/README.md b/examples/python/README.md index 57494daa..71cce8cb 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -1,13 +1,13 @@ -# x402 Python Examples +# bankofai.x402 Python Examples -Examples for the x402 Python SDK. +Examples for the bankofai.x402 Python SDK. ## Quick Start ```bash cd clients/httpx cp .env-local .env -# Edit .env with your EVM_PRIVATE_KEY and/or SVM_PRIVATE_KEY +# Edit .env with your TRON_PRIVATE_KEY, EVM_PRIVATE_KEY and/or SVM_PRIVATE_KEY uv sync uv run python main.py ``` diff --git a/examples/python/clients/README.md b/examples/python/clients/README.md index 94477efa..68636de7 100644 --- a/examples/python/clients/README.md +++ b/examples/python/clients/README.md @@ -47,9 +47,9 @@ uv run python main.py Both examples follow the same pattern: ```python -from x402 import x402Client -from x402.mechanisms.evm.exact.register import register_exact_evm_client -from x402.mechanisms.evm.signers import EthAccountSigner +from bankofai.x402 import x402Client +from bankofai.x402.mechanisms.evm.exact.register import register_exact_evm_client +from bankofai.x402.mechanisms.evm.signers import EthAccountSigner # 1. Create account account = Account.from_key(private_key) diff --git a/examples/python/clients/custom/README.md b/examples/python/clients/custom/README.md index 8b3e9526..cbb9ad50 100644 --- a/examples/python/clients/custom/README.md +++ b/examples/python/clients/custom/README.md @@ -76,8 +76,8 @@ uv run python main.py ### 1. Client Setup ```python -from x402 import x402Client -from x402.mechanisms.evm.exact.register import register_exact_evm_client +from bankofai.x402 import x402Client +from bankofai.x402.mechanisms.evm.exact.register import register_exact_evm_client client = x402Client() register_exact_evm_client(client, EthAccountSigner(account)) diff --git a/examples/python/clients/httpx/README.md b/examples/python/clients/httpx/README.md index 654a24ab..9dd56386 100644 --- a/examples/python/clients/httpx/README.md +++ b/examples/python/clients/httpx/README.md @@ -42,13 +42,13 @@ The example demonstrates the complete x402 payment flow: ## Code Overview ```python -from x402 import x402Client -from x402.http import x402HTTPClient -from x402.http.clients import x402HttpxClient -from x402.mechanisms.evm import EthAccountSigner -from x402.mechanisms.evm.exact.register import register_exact_evm_client -from x402.mechanisms.svm import KeypairSigner -from x402.mechanisms.svm.exact.register import register_exact_svm_client +from bankofai.x402 import x402Client +from bankofai.x402.http import x402HTTPClient +from bankofai.x402.http.clients import x402HttpxClient +from bankofai.x402.mechanisms.evm import EthAccountSigner +from bankofai.x402.mechanisms.evm.exact.register import register_exact_evm_client +from bankofai.x402.mechanisms.svm import KeypairSigner +from bankofai.x402.mechanisms.svm.exact.register import register_exact_svm_client # Setup client = x402Client() diff --git a/examples/python/clients/payment-identifier/README.md b/examples/python/clients/payment-identifier/README.md index f8f1e4ab..e35f0b1a 100644 --- a/examples/python/clients/payment-identifier/README.md +++ b/examples/python/clients/payment-identifier/README.md @@ -10,12 +10,12 @@ Example client demonstrating how to use the `payment-identifier` extension to en 4. Retry requests with the same payment ID return cached responses without re-processing payment ```python -from x402 import x402Client -from x402.extensions.payment_identifier import ( +from bankofai.x402 import x402Client +from bankofai.x402.extensions.payment_identifier import ( append_payment_identifier_to_extensions, generate_payment_id, ) -from x402.http.clients import x402HttpxClient +from bankofai.x402.http.clients import x402HttpxClient client = x402Client() # ... register schemes ... diff --git a/examples/python/clients/requests/README.md b/examples/python/clients/requests/README.md index 36ce6ed6..30348453 100644 --- a/examples/python/clients/requests/README.md +++ b/examples/python/clients/requests/README.md @@ -42,13 +42,13 @@ The example demonstrates the complete x402 payment flow: ## Code Overview ```python -from x402 import x402ClientSync -from x402.http import x402HTTPClientSync -from x402.http.clients import x402_requests -from x402.mechanisms.evm import EthAccountSigner -from x402.mechanisms.evm.exact.register import register_exact_evm_client -from x402.mechanisms.svm import KeypairSigner -from x402.mechanisms.svm.exact.register import register_exact_svm_client +from bankofai.x402 import x402ClientSync +from bankofai.x402.http import x402HTTPClientSync +from bankofai.x402.http.clients import x402_requests +from bankofai.x402.mechanisms.evm import EthAccountSigner +from bankofai.x402.mechanisms.evm.exact.register import register_exact_evm_client +from bankofai.x402.mechanisms.svm import KeypairSigner +from bankofai.x402.mechanisms.svm.exact.register import register_exact_svm_client # Setup client = x402ClientSync() diff --git a/examples/python/facilitator/basic/README.md b/examples/python/facilitator/basic/README.md index a3095d4b..27815561 100644 --- a/examples/python/facilitator/basic/README.md +++ b/examples/python/facilitator/basic/README.md @@ -173,9 +173,9 @@ Response (failure): Register additional schemes for other networks: ```python -from x402 import x402Facilitator -from x402.mechanisms.evm.exact import register_exact_evm_facilitator -from x402.mechanisms.svm.exact import register_exact_svm_facilitator +from bankofai.x402 import x402Facilitator +from bankofai.x402.mechanisms.evm.exact import register_exact_evm_facilitator +from bankofai.x402.mechanisms.svm.exact import register_exact_svm_facilitator facilitator = x402Facilitator() @@ -197,8 +197,8 @@ register_exact_svm_facilitator( Add custom logic before/after verify and settle operations: ```python -from x402 import x402Facilitator -from x402.schemas import AbortResult +from bankofai.x402 import x402Facilitator +from bankofai.x402.schemas import AbortResult facilitator = ( x402Facilitator() @@ -219,8 +219,8 @@ facilitator = ( Create a custom signer for different providers: ```python -from x402.mechanisms.evm.signer import FacilitatorEvmSigner -from x402.mechanisms.evm.types import TransactionReceipt +from bankofai.x402.mechanisms.evm.signer import FacilitatorEvmSigner +from bankofai.x402.mechanisms.evm.types import TransactionReceipt class MyCustomSigner: """Implement FacilitatorEvmSigner protocol.""" diff --git a/examples/python/legacy/clients/httpx/README.md b/examples/python/legacy/clients/httpx/README.md index f7630329..f0e16c74 100644 --- a/examples/python/legacy/clients/httpx/README.md +++ b/examples/python/legacy/clients/httpx/README.md @@ -31,7 +31,7 @@ uv run python extensible.py The simple approach uses `x402HttpxClient`, a pre-configured client that handles payments automatically: ```python -from x402.clients import x402HttpxClient +from bankofai.x402.clients import x402HttpxClient async with x402HttpxClient(account=account, base_url=base_url) as client: response = await client.get(endpoint_path) @@ -42,7 +42,7 @@ async with x402HttpxClient(account=account, base_url=base_url) as client: The extensible approach uses `x402_payment_hooks` with your own httpx client: ```python -from x402.clients import x402_payment_hooks +from bankofai.x402.clients import x402_payment_hooks import httpx async with httpx.AsyncClient(base_url=base_url) as client: diff --git a/examples/python/legacy/clients/requests/README.md b/examples/python/legacy/clients/requests/README.md index 80fa16f9..2f46913d 100644 --- a/examples/python/legacy/clients/requests/README.md +++ b/examples/python/legacy/clients/requests/README.md @@ -31,7 +31,7 @@ python extensible.py The simple approach uses `x402_requests`, which returns a pre-configured session that handles payments automatically: ```python -from x402.clients import x402_requests +from bankofai.x402.clients import x402_requests session = x402_requests(account) response = session.get(url) @@ -42,7 +42,7 @@ response = session.get(url) The extensible approach uses `x402_http_adapter` with your own requests session: ```python -from x402.clients import x402_http_adapter +from bankofai.x402.clients import x402_http_adapter import requests session = requests.Session() diff --git a/examples/python/legacy/discovery/README.md b/examples/python/legacy/discovery/README.md index ec1192e9..0ae4f259 100644 --- a/examples/python/legacy/discovery/README.md +++ b/examples/python/legacy/discovery/README.md @@ -39,7 +39,7 @@ The example demonstrates how to: import json import asyncio from datetime import datetime -from x402.facilitator import FacilitatorClient +from bankofai.x402.facilitator import FacilitatorClient from cdp.x402 import create_facilitator_config # Initialize facilitator client (no API keys required for discovery) diff --git a/examples/python/servers/advanced/README.md b/examples/python/servers/advanced/README.md index 497694b7..04728633 100644 --- a/examples/python/servers/advanced/README.md +++ b/examples/python/servers/advanced/README.md @@ -4,12 +4,12 @@ FastAPI server demonstrating advanced x402 patterns including dynamic pricing, p ```python from fastapi import FastAPI -from x402.http.middleware.fastapi import PaymentMiddlewareASGI -from x402.http import HTTPFacilitatorClient, FacilitatorConfig, PaymentOption -from x402.http.types import RouteConfig -from x402.server import x402ResourceServer -from x402.mechanisms.evm.exact import ExactEvmServerScheme -from x402.mechanisms.svm.exact import ExactSvmServerScheme +from bankofai.x402.http.middleware.fastapi import PaymentMiddlewareASGI +from bankofai.x402.http import HTTPFacilitatorClient, FacilitatorConfig, PaymentOption +from bankofai.x402.http.types import RouteConfig +from bankofai.x402.server import x402ResourceServer +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402.mechanisms.svm.exact import ExactSvmServerScheme app = FastAPI() @@ -200,7 +200,7 @@ Network identifiers use [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/mai Add a browser-based payment interface for human users: ```python -from x402.http.paywall import create_paywall, evm_paywall, svm_paywall +from bankofai.x402.http.paywall import create_paywall, evm_paywall, svm_paywall paywall = ( create_paywall() @@ -225,7 +225,7 @@ app.add_middleware( Enable AI agent discovery with structured input/output schemas: ```python -from x402.extensions.bazaar import declare_discovery_extension, bazaar_resource_server_extension, OutputConfig +from bankofai.x402.extensions.bazaar import declare_discovery_extension, bazaar_resource_server_extension, OutputConfig server.register_extension(bazaar_resource_server_extension) @@ -308,7 +308,7 @@ RouteConfig( Add custom logic before/after payment verification and settlement: ```python -from x402 import VerifyContext, SettleResultContext, AbortResult +from bankofai.x402 import VerifyContext, SettleResultContext, AbortResult def before_verify_hook(context: VerifyContext) -> None | AbortResult: print(f"Verifying payment: {context}") @@ -332,7 +332,7 @@ server.on_settle_failure(on_settle_failure_hook) Define custom token conversions for specific networks: ```python -from x402.schemas import AssetAmount +from bankofai.x402.schemas import AssetAmount def custom_money_parser(amount: float, network: str) -> AssetAmount | None: if network == "eip155:100": # Gnosis Chain diff --git a/examples/python/servers/custom/README.md b/examples/python/servers/custom/README.md index 50f46e6c..4d56a7ee 100644 --- a/examples/python/servers/custom/README.md +++ b/examples/python/servers/custom/README.md @@ -3,9 +3,9 @@ Demonstrates how to implement x402 payment handling manually without using pre-built middleware packages like `x402-fastapi`. ```python -from x402.http import HTTPFacilitatorClient, FacilitatorConfig -from x402.mechanisms.evm.exact import ExactEvmServerScheme -from x402.server import x402ResourceServer +from bankofai.x402.http import HTTPFacilitatorClient, FacilitatorConfig +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402.server import x402ResourceServer resource_server = x402ResourceServer( HTTPFacilitatorClient(FacilitatorConfig(url=facilitator_url)) @@ -217,7 +217,7 @@ The custom implementation demonstrates each step of the x402 payment flow: ```python from dataclasses import dataclass -from x402.schemas import Network +from bankofai.x402.schemas import Network @dataclass class RoutePaymentConfig: diff --git a/examples/python/servers/fastapi/README.md b/examples/python/servers/fastapi/README.md index 2b70e2e2..f9709bc1 100644 --- a/examples/python/servers/fastapi/README.md +++ b/examples/python/servers/fastapi/README.md @@ -4,12 +4,12 @@ FastAPI server demonstrating how to protect API endpoints with a paywall using t ```python from fastapi import FastAPI -from x402.http.middleware.fastapi import PaymentMiddlewareASGI -from x402.http import HTTPFacilitatorClient, FacilitatorConfig, PaymentOption -from x402.http.types import RouteConfig -from x402.server import x402ResourceServer -from x402.mechanisms.evm.exact import ExactEvmServerScheme -from x402.mechanisms.svm.exact import ExactSvmServerScheme +from bankofai.x402.http.middleware.fastapi import PaymentMiddlewareASGI +from bankofai.x402.http import HTTPFacilitatorClient, FacilitatorConfig, PaymentOption +from bankofai.x402.http.types import RouteConfig +from bankofai.x402.server import x402ResourceServer +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402.mechanisms.svm.exact import ExactSvmServerScheme app = FastAPI() diff --git a/examples/python/servers/flask/README.md b/examples/python/servers/flask/README.md index 76a9d4e5..8d93f081 100644 --- a/examples/python/servers/flask/README.md +++ b/examples/python/servers/flask/README.md @@ -4,12 +4,12 @@ Flask server demonstrating how to protect API endpoints with a paywall using the ```python from flask import Flask, jsonify -from x402.http.middleware.flask import payment_middleware -from x402.http import HTTPFacilitatorClientSync, FacilitatorConfig, PaymentOption -from x402.http.types import RouteConfig -from x402.server import x402ResourceServerSync -from x402.mechanisms.evm.exact import ExactEvmServerScheme -from x402.mechanisms.svm.exact import ExactSvmServerScheme +from bankofai.x402.http.middleware.flask import payment_middleware +from bankofai.x402.http import HTTPFacilitatorClientSync, FacilitatorConfig, PaymentOption +from bankofai.x402.http.types import RouteConfig +from bankofai.x402.server import x402ResourceServerSync +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402.mechanisms.svm.exact import ExactSvmServerScheme app = Flask(__name__) diff --git a/examples/python/servers/payment-identifier/README.md b/examples/python/servers/payment-identifier/README.md index d736454b..70d347bb 100644 --- a/examples/python/servers/payment-identifier/README.md +++ b/examples/python/servers/payment-identifier/README.md @@ -10,12 +10,12 @@ Example server demonstrating how to implement the `payment-identifier` extension 4. Duplicate requests with the same payment ID return cached response without payment processing ```python -from x402.extensions.payment_identifier import ( +from bankofai.x402.extensions.payment_identifier import ( PAYMENT_IDENTIFIER, declare_payment_identifier_extension, extract_payment_identifier, ) -from x402.server import x402ResourceServer +from bankofai.x402.server import x402ResourceServer server = x402ResourceServer(facilitator) diff --git a/examples/typescript/README.md b/examples/typescript/README.md index f091b6a2..0f5bd157 100644 --- a/examples/typescript/README.md +++ b/examples/typescript/README.md @@ -20,24 +20,20 @@ The examples are organized into several categories: Examples of different client implementations for interacting with X402 services: -- `clients/axios/` - Axios client with x402 payment interceptor from `x402-axios`. -- `clients/fetch/` - Client using the `x402-fetch` wrapper around the native fetch API. -- `clients/cdp-sdk/` - Client that uses CDP Server Wallets as the signer with `x402-axios`. -- `clients/chainlink-vrf-nft/` - Example using [Chainlink](docs.chain.link) to mint a randomized NFT (see them on [Opensea](https://testnets.opensea.io/collection/vrfnft-1)). Demonstrates verify/settle flow with `x402-axios`. - -### Agents - -- `agent/` - Anthropic agent that pays via a Go proxy using `x402-fetch`. -- `dynamic_agent/` - Agent that discovers tools dynamically and pays per-request using x402. - -### Discovery - -- `discovery/` - Uses the facilitator to list available x402-protected resources (Bazaar). +- `clients/axios/` - Axios client with x402 payment interceptor from `@bankofai/x402-axios`. +- `clients/fetch/` - Client using the `@bankofai/x402-fetch` wrapper around the native fetch API. +- `clients/advanced/` - Advanced client patterns: hooks, preferred networks, and builder pattern. +- `clients/custom/` - Demonstration of a custom x402 client implementation. +- `clients/payment-identifier/` - Example using the Payment-Identifier extension for payment correlation. +- `clients/sign-in-with-x/` - Integration of Sign-In-With-X (SIWX) with x402 payments. ### MCP -- `mcp/` - MCP server that makes paid API requests via `x402-axios` (Claude Desktop compatible). -- `mcp-embedded-wallet/` - Electron-based MCP server with an embedded wallet that signs requests via IPC. +- `legacy/mcp/` - MCP server that makes paid API requests via `@bankofai/x402-axios` (Claude Desktop compatible). +- `legacy/mcp-embedded-wallet/` - Electron-based MCP server with an embedded wallet that signs requests via IPC. +- `clients/mcp/` - Client that uses MCP tools with x402 payment support. +- `clients/mcp-chatbot/` - OpenAI-powered chatbot using MCP tools and x402 payments. +- `servers/mcp/` - MCP server that provides paid tools via x402. ### Facilitator @@ -45,21 +41,20 @@ Examples of different client implementations for interacting with X402 services: ### Fullstack -- `fullstack/next/` - Next.js app demonstrating route protection with `x402-next` middleware. -- `fullstack/mainnet/` - Next.js app configured for Base mainnet using the Coinbase hosted facilitator. -- `fullstack/next-advanced/` - [WIP] Deep Next.js integration using a paywall + session cookie after verify/settle. -- `fullstack/browser-wallet-example/` - Browser wallet template: Hono server + React client with session and one-time payments. -- `fullstack/farcaster-miniapp/` - Farcaster Mini App template with x402-protected APIs using [MiniKit](https://www.base.org/build/mini-apps). -- `fullstack/auth_based_pricing/` - SIWE + JWT with conditional pricing ($0.01 with JWT vs $0.10 without) using x402. +- `fullstack/next/` - Next.js app demonstrating route protection with `@bankofai/x402-next` middleware. +- `fullstack/miniapp/` - Farcaster Mini App template with x402-protected APIs using MiniKit. ### Servers Examples of different server implementations: -- `servers/express/` - Express.js server using `x402-express` middleware. -- `servers/hono/` - Hono server using `x402-hono` middleware. -- `servers/advanced/` - Express server without middleware: delayed settlement, dynamic pricing, multiple requirements. -- `servers/mainnet/` - Server example for accepting real USDC on Base mainnet using the Coinbase hosted facilitator. +- `servers/express/` - Express.js server using `@bankofai/x402-express` middleware. +- `servers/hono/` - Hono server using `@bankofai/x402-hono` middleware. +- `servers/advanced/` - Advanced Express patterns: dynamic pricing, gas sponsoring, and custom money definitions. +- `servers/cloudfront-lambda-edge/` - x402 implementation for AWS CloudFront using Lambda@Edge. +- `servers/custom/` - Custom server implementation using `@bankofai/x402-core`. +- `servers/payment-identifier/` - Server-side support for Payment-Identifier correlation. +- `servers/sign-in-with-x/` - Server-side SIWX session management with paid endpoints. ## Running Examples diff --git a/examples/typescript/clients/README.md b/examples/typescript/clients/README.md index 62dd98a9..1ba214f1 100644 --- a/examples/typescript/clients/README.md +++ b/examples/typescript/clients/README.md @@ -6,10 +6,10 @@ This directory contains TypeScript client examples demonstrating how to make HTT | Directory | Description | | --- | --- | -| [`fetch/`](./fetch/) | Using `@x402/fetch` with the native Fetch API | -| [`axios/`](./axios/) | Using `@x402/axios` with Axios | +| [`fetch/`](./fetch/) | Using `@bankofai/x402-fetch` with the native Fetch API | +| [`axios/`](./axios/) | Using `@bankofai/x402-axios` with Axios | | [`advanced/`](./advanced/) | Advanced patterns: lifecycle hooks, network preferences | -| [`custom/`](./custom/) | Manual implementation using only `@x402/core` | +| [`custom/`](./custom/) | Manual implementation using only `@bankofai/x402-core` | ## Framework Examples @@ -33,7 +33,7 @@ These patterns are useful for production applications that need observability, c ## Custom Implementation -The **custom** directory shows how to implement x402 payment handling manually using only `@x402/core`, without any client interceptors. Use this approach when: +The **custom** directory shows how to implement x402 payment handling manually using only `@bankofai/x402-core`, without any client interceptors. Use this approach when: - You need complete control over the payment flow - You're integrating with an HTTP client we don't have a package for diff --git a/examples/typescript/clients/advanced/README.md b/examples/typescript/clients/advanced/README.md index 4c3470db..9c7bb71a 100644 --- a/examples/typescript/clients/advanced/README.md +++ b/examples/typescript/clients/advanced/README.md @@ -3,8 +3,8 @@ Advanced patterns for x402 TypeScript clients demonstrating builder pattern registration, payment lifecycle hooks, and network preferences. ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const client = new x402Client() @@ -98,10 +98,10 @@ pnpm dev:builder-pattern Use the builder pattern for fine-grained control over which networks are supported and with which signers: ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; -import { ExactSvmScheme } from "@x402/svm/exact/client"; -import { ExactStellarScheme } from "@x402/stellar/exact/client"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { ExactSvmScheme } from "@bankofai/x402-svm/exact/client"; +import { ExactStellarScheme } from "@bankofai/x402-stellar/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const evmSigner = privateKeyToAccount(evmPrivateKey); @@ -129,8 +129,8 @@ const response = await fetchWithPayment("http://localhost:4021/weather"); Register custom logic at different payment stages for observability and control: ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY); @@ -172,10 +172,10 @@ Available hooks: Configure client-side network preferences with automatic fallback: ```typescript -import { x402Client, wrapFetchWithPayment, type PaymentRequirements } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; -import { ExactSvmScheme } from "@x402/svm/exact/client"; -import { ExactStellarScheme } from "@x402/stellar/exact/client"; +import { x402Client, wrapFetchWithPayment, type PaymentRequirements } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { ExactSvmScheme } from "@bankofai/x402-svm/exact/client"; +import { ExactStellarScheme } from "@bankofai/x402-stellar/exact/client"; // Define network preference order (most preferred first) const networkPreferences = ["eip155:", "solana:", "stellar:"]; diff --git a/examples/typescript/clients/axios/README.md b/examples/typescript/clients/axios/README.md index 7495313b..53740c6f 100644 --- a/examples/typescript/clients/axios/README.md +++ b/examples/typescript/clients/axios/README.md @@ -1,10 +1,10 @@ -# @x402/axios Example Client +# @bankofai/x402-axios Example Client -Example client demonstrating how to use `@x402/axios` to make HTTP requests to endpoints protected by the x402 payment protocol. +Example client demonstrating how to use `@bankofai/x402-axios` to make HTTP requests to endpoints protected by the x402 payment protocol. ```typescript -import { x402Client, wrapAxiosWithPayment } from "@x402/axios"; -import { registerExactEvmScheme } from "@x402/evm/exact/client"; +import { x402Client, wrapAxiosWithPayment } from "@bankofai/x402-axios"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; import axios from "axios"; diff --git a/examples/typescript/clients/custom/README.md b/examples/typescript/clients/custom/README.md index 8e1897c2..1f5737b1 100644 --- a/examples/typescript/clients/custom/README.md +++ b/examples/typescript/clients/custom/README.md @@ -1,11 +1,11 @@ # Custom x402 Client Implementation -Demonstrates how to implement x402 payment handling manually using only the core packages, without convenience wrappers like `@x402/fetch` or `@x402/axios`. +Demonstrates how to implement x402 payment handling manually using only the core packages, without convenience wrappers like `@bankofai/x402-fetch` or `@bankofai/x402-axios`. ```typescript -import { x402Client } from "@x402/core/client"; -import { decodePaymentRequiredHeader, encodePaymentSignatureHeader } from "@x402/core/http"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; +import { x402Client } from "@bankofai/x402-core/client"; +import { decodePaymentRequiredHeader, encodePaymentSignatureHeader } from "@bankofai/x402-core/http"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const client = new x402Client().register( @@ -103,9 +103,9 @@ pnpm dev ### 1. Setting Up the Client ```typescript -import { x402Client } from "@x402/core/client"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; -import { ExactSvmScheme } from "@x402/svm/exact/client"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { ExactSvmScheme } from "@bankofai/x402-svm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const evmSigner = privateKeyToAccount(evmPrivateKey); @@ -124,7 +124,7 @@ const client = new x402Client(selectPayment) ### 2. Detecting Payment Required ```typescript -import { decodePaymentRequiredHeader } from "@x402/core/http"; +import { decodePaymentRequiredHeader } from "@bankofai/x402-core/http"; if (response.status === 402) { const paymentRequiredHeader = response.headers.get("PAYMENT-REQUIRED"); @@ -136,7 +136,7 @@ if (response.status === 402) { ### 3. Creating Payment Payload ```typescript -import { encodePaymentSignatureHeader } from "@x402/core/http"; +import { encodePaymentSignatureHeader } from "@bankofai/x402-core/http"; const paymentPayload = await client.createPaymentPayload(paymentRequired); const paymentHeader = encodePaymentSignatureHeader(paymentPayload); @@ -155,7 +155,7 @@ const response = await fetch(url, { ### 5. Extracting Settlement ```typescript -import { decodePaymentResponseHeader } from "@x402/core/http"; +import { decodePaymentResponseHeader } from "@bankofai/x402-core/http"; const settlementHeader = response.headers.get("PAYMENT-RESPONSE"); const settlement = decodePaymentResponseHeader(settlementHeader); @@ -164,7 +164,7 @@ const settlement = decodePaymentResponseHeader(settlementHeader); ## Wrapper vs Custom Comparison -| Aspect | With Wrapper (@x402/fetch) | Custom Implementation | +| Aspect | With Wrapper (@bankofai/x402-fetch) | Custom Implementation | | ----------------- | -------------------------- | --------------------- | | Code Complexity | ~10 lines | ~100 lines | | Automatic Retry | ✅ Yes | ❌ Manual | diff --git a/examples/typescript/clients/fetch/README.md b/examples/typescript/clients/fetch/README.md index ee64e966..602cc9ab 100644 --- a/examples/typescript/clients/fetch/README.md +++ b/examples/typescript/clients/fetch/README.md @@ -1,11 +1,11 @@ -# @x402/fetch Example Client +# @bankofai/x402-fetch Example Client -Example client demonstrating how to use `@x402/fetch` to make HTTP requests to endpoints protected by the x402 payment protocol. +Example client demonstrating how to use `@bankofai/x402-fetch` to make HTTP requests to endpoints protected by the x402 payment protocol. ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { registerExactEvmScheme } from "@x402/evm/exact/client"; -import { registerExactSvmScheme } from "@x402/svm/exact/client"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { registerExactSvmScheme } from "@bankofai/x402-svm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; import { createKeyPairSignerFromBytes } from "@solana/kit"; import { base58 } from "@scure/base"; diff --git a/examples/typescript/clients/payment-identifier/README.md b/examples/typescript/clients/payment-identifier/README.md index b0a88ff9..3192f3ac 100644 --- a/examples/typescript/clients/payment-identifier/README.md +++ b/examples/typescript/clients/payment-identifier/README.md @@ -10,8 +10,8 @@ Example client demonstrating how to use the `payment-identifier` extension to en 4. Retry requests with the same payment ID return cached responses without re-processing payment ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { appendPaymentIdentifierToExtensions, generatePaymentId } from "@x402/extensions/payment-identifier"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { appendPaymentIdentifierToExtensions, generatePaymentId } from "@bankofai/x402-extensions/payment-identifier"; const client = new x402Client(); // ... register schemes ... diff --git a/examples/typescript/clients/sign-in-with-x/README.md b/examples/typescript/clients/sign-in-with-x/README.md index e5dc2f0d..1fea6d5b 100644 --- a/examples/typescript/clients/sign-in-with-x/README.md +++ b/examples/typescript/clients/sign-in-with-x/README.md @@ -3,10 +3,10 @@ Client demonstrating how to use Sign-In-With-X authentication with x402, allowing wallet signatures to prove prior payment and skip re-payment on subsequent requests. ```typescript -import { x402Client, x402HTTPClient, wrapFetchWithPayment } from "@x402/fetch"; -import { registerExactEvmScheme } from "@x402/evm/exact/client"; -import { registerExactSvmScheme } from "@x402/svm/exact/client"; -import { createSIWxClientHook } from "@x402/extensions/sign-in-with-x"; +import { x402Client, x402HTTPClient, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { registerExactSvmScheme } from "@bankofai/x402-svm/exact/client"; +import { createSIWxClientHook } from "@bankofai/x402-extensions/sign-in-with-x"; import { privateKeyToAccount } from "viem/accounts"; import { createKeyPairSignerFromBytes } from "@solana/kit"; diff --git a/examples/typescript/facilitator/advanced/README.md b/examples/typescript/facilitator/advanced/README.md index a0ab8475..f2ab3ead 100644 --- a/examples/typescript/facilitator/advanced/README.md +++ b/examples/typescript/facilitator/advanced/README.md @@ -189,8 +189,8 @@ Response (failure): Register additional schemes for other networks: ```typescript -import { registerExactEvmScheme } from "@x402/evm/exact/facilitator"; -import { registerExactSvmScheme } from "@x402/svm/exact/facilitator"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/facilitator"; +import { registerExactSvmScheme } from "@bankofai/x402-svm/exact/facilitator"; const facilitator = new x402Facilitator(); diff --git a/examples/typescript/facilitator/basic/README.md b/examples/typescript/facilitator/basic/README.md index 6baf4845..4d7feebe 100644 --- a/examples/typescript/facilitator/basic/README.md +++ b/examples/typescript/facilitator/basic/README.md @@ -168,8 +168,8 @@ Response (failure): Register additional schemes for other networks: ```typescript -import { registerExactEvmScheme } from "@x402/evm/exact/facilitator"; -import { registerExactSvmScheme } from "@x402/svm/exact/facilitator"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/facilitator"; +import { registerExactSvmScheme } from "@bankofai/x402-svm/exact/facilitator"; const facilitator = new x402Facilitator(); diff --git a/examples/typescript/fullstack/miniapp/README.md b/examples/typescript/fullstack/miniapp/README.md index f4bc6437..e9cbfdca 100644 --- a/examples/typescript/fullstack/miniapp/README.md +++ b/examples/typescript/fullstack/miniapp/README.md @@ -1,6 +1,6 @@ # x402 Farcaster Mini App Example (v2 SDK) -This is a [Next.js](https://nextjs.org) project demonstrating how to build a [Farcaster Mini App](https://miniapps.farcaster.xyz/) with x402 payment-protected API endpoints using the `@x402/next`, `@x402/fetch` and `@x402/evm` packages. +This is a [Next.js](https://nextjs.org) project demonstrating how to build a [Farcaster Mini App](https://miniapps.farcaster.xyz/) with x402 payment-protected API endpoints using the `@bankofai/x402-next`, `@bankofai/x402-fetch` and `@bankofai/x402-evm` packages. ## Prerequisites @@ -71,9 +71,9 @@ The `/api/protected` endpoint uses the `withX402` wrapper for payment protection ```typescript // app/api/protected/route.ts -import { withX402 } from "@x402/next"; -import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server"; -import { registerExactEvmScheme } from "@x402/evm/exact/server"; +import { withX402 } from "@bankofai/x402-next"; +import { x402ResourceServer, HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const facilitatorClient = new HTTPFacilitatorClient({ url: process.env.FACILITATOR_URL, @@ -101,11 +101,11 @@ export const GET = withX402( ### Client-Side Payment Handling -The frontend uses `@x402/fetch` to handle payments: +The frontend uses `@bankofai/x402-fetch` to handle payments: ```typescript -import { x402Client, wrapFetchWithPayment } from "@x402/fetch"; -import { registerExactEvmScheme } from "@x402/evm/exact/client"; +import { x402Client, wrapFetchWithPayment } from "@bankofai/x402-fetch"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/client"; // Create client and register EVM scheme const client = new x402Client(); @@ -216,9 +216,9 @@ Create a new route file (e.g., `app/api/premium/route.ts`) and use the `withX402 ```typescript // app/api/premium/route.ts import { NextRequest, NextResponse } from "next/server"; -import { withX402 } from "@x402/next"; -import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server"; -import { registerExactEvmScheme } from "@x402/evm/exact/server"; +import { withX402 } from "@bankofai/x402-next"; +import { x402ResourceServer, HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const facilitatorClient = new HTTPFacilitatorClient({ url: process.env.FACILITATOR_URL, diff --git a/examples/typescript/fullstack/next/README.md b/examples/typescript/fullstack/next/README.md index 61431c2c..bcad513a 100644 --- a/examples/typescript/fullstack/next/README.md +++ b/examples/typescript/fullstack/next/README.md @@ -1,6 +1,6 @@ # x402-next Example App -Next.js application demonstrating how to protect routes with a paywall using the `@x402/next` middleware. +Next.js application demonstrating how to protect routes with a paywall using the `@bankofai/x402-next` middleware. ## Prerequisites @@ -45,13 +45,13 @@ The `/protected` route is protected using `paymentProxy`. Page routes are protec ```typescript // proxy.ts -import { paymentProxy } from "@x402/next"; -import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server"; -import { registerExactEvmScheme } from "@x402/evm/exact/server"; -import { registerExactSvmScheme } from "@x402/svm/exact/server"; -import { createPaywall } from "@x402/paywall"; -import { evmPaywall } from "@x402/paywall/evm"; -import { svmPaywall } from "@x402/paywall/svm"; +import { paymentProxy } from "@bankofai/x402-next"; +import { x402ResourceServer, HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { registerExactSvmScheme } from "@bankofai/x402-svm/exact/server"; +import { createPaywall } from "@bankofai/x402-paywall"; +import { evmPaywall } from "@bankofai/x402-paywall/evm"; +import { svmPaywall } from "@bankofai/x402-paywall/svm"; const facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl }); const server = new x402ResourceServer(facilitatorClient); @@ -109,7 +109,7 @@ The `/api/weather` route demonstrates the `withX402` wrapper for individual API ```typescript // app/api/weather/route.ts import { NextRequest, NextResponse } from "next/server"; -import { withX402 } from "@x402/next"; +import { withX402 } from "@bankofai/x402-next"; import { server, paywall, evmAddress, svmAddress } from "../../../proxy"; const handler = async (_: NextRequest) => { diff --git a/examples/typescript/servers/README.md b/examples/typescript/servers/README.md index 794371a6..63156083 100644 --- a/examples/typescript/servers/README.md +++ b/examples/typescript/servers/README.md @@ -6,10 +6,10 @@ This directory contains TypeScript server examples demonstrating how to protect | Directory | Description | | --- | --- | -| [`express/`](./express/) | Using `@x402/express` middleware | -| [`hono/`](./hono/) | Using `@x402/hono` middleware | +| [`express/`](./express/) | Using `@bankofai/x402-express` middleware | +| [`hono/`](./hono/) | Using `@bankofai/x402-hono` middleware | | [`advanced/`](./advanced/) | Advanced patterns: hooks, dynamic pricing, custom tokens | -| [`custom/`](./custom/) | Manual implementation using only `@x402/core` | +| [`custom/`](./custom/) | Manual implementation using only `@bankofai/x402-core` | ## Framework Examples @@ -36,7 +36,7 @@ These patterns are useful for production applications that need custom business ## Custom Implementation -The **custom** directory shows how to implement x402 payment handling manually using only `@x402/core`, without any middleware. Use this approach when: +The **custom** directory shows how to implement x402 payment handling manually using only `@bankofai/x402-core`, without any middleware. Use this approach when: - You need complete control over the payment flow - You're using a web framework we don't have a package for (Koa, Fastify, etc.) diff --git a/examples/typescript/servers/advanced/README.md b/examples/typescript/servers/advanced/README.md index 17d98b23..cfce418d 100644 --- a/examples/typescript/servers/advanced/README.md +++ b/examples/typescript/servers/advanced/README.md @@ -1,12 +1,12 @@ -# @x402/express Advanced Examples +# @bankofai/x402-express Advanced Examples Express.js server demonstrating advanced x402 patterns including dynamic pricing, payment routing, lifecycle hooks and API discoverability. ```typescript -import { paymentMiddleware, x402ResourceServer } from "@x402/express"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { ExactStellarScheme } from "@x402/stellar/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-express"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { ExactStellarScheme } from "@bankofai/x402-stellar/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; const resourceServer = new x402ResourceServer(new HTTPFacilitatorClient({ url: facilitatorUrl })) .register("eip155:84532", new ExactEvmScheme()) @@ -122,7 +122,7 @@ pnpm dev Adding the discovery extension to make your API discoverable: ```typescript -import { declareDiscoveryExtension } from "@x402/extensions/bazaar"; +import { declareDiscoveryExtension } from "@bankofai/x402-extensions/bazaar"; app.use( paymentMiddleware( @@ -257,7 +257,7 @@ Available hooks: Accept payments in custom tokens. Register a money parser on the scheme to support alternative tokens for specific networks. ```typescript -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const resourceServer = new x402ResourceServer(facilitatorClient).register( "eip155:84532", diff --git a/examples/typescript/servers/cloudfront-lambda-edge/README.md b/examples/typescript/servers/cloudfront-lambda-edge/README.md index 72d4f02c..fd4f5862 100644 --- a/examples/typescript/servers/cloudfront-lambda-edge/README.md +++ b/examples/typescript/servers/cloudfront-lambda-edge/README.md @@ -72,8 +72,8 @@ Copy `lambda/src/` into your project and adapt the build to your tooling. > **Note**: Replace `workspace:*` dependencies with specific versions: > ```json -> "@x402/core": "^2.2.0", -> "@x402/evm": "^2.2.0" +> "@bankofai/x402-core": "^2.2.0", +> "@bankofai/x402-evm": "^2.2.0" > ``` ### 2. Configure Payment Settings @@ -187,7 +187,7 @@ cloudfront-lambda-edge/ ## Middleware Pattern -The `lib/` folder follows the same pattern as `@x402/express`, `@x402/hono`, etc.: +The `lib/` folder follows the same pattern as `@bankofai/x402-express`, `@bankofai/x402-hono`, etc.: ```typescript import { createX402Middleware, MiddlewareResultType } from './lib'; diff --git a/examples/typescript/servers/custom/README.md b/examples/typescript/servers/custom/README.md index d94311af..98c79381 100644 --- a/examples/typescript/servers/custom/README.md +++ b/examples/typescript/servers/custom/README.md @@ -1,10 +1,10 @@ -# @x402/core Custom Server +# @bankofai/x402-core Custom Server -Demonstrates how to implement x402 payment handling manually without using pre-built middleware packages like `@x402/express` or `@x402/hono`. +Demonstrates how to implement x402 payment handling manually without using pre-built middleware packages like `@bankofai/x402-express` or `@bankofai/x402-hono`. ```typescript -import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { x402ResourceServer, HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const resourceServer = new x402ResourceServer( new HTTPFacilitatorClient({ url: facilitatorUrl }), @@ -273,7 +273,7 @@ res.set("PAYMENT-RESPONSE", settlementHeader); ## Middleware vs Custom Comparison -| Aspect | With Middleware (@x402/express) | Custom Implementation | +| Aspect | With Middleware (@bankofai/x402-express) | Custom Implementation | | ---------------------- | ------------------------------- | --------------------- | | Code Complexity | ~10 lines | ~150 lines | | Automatic Verification | ✅ Yes | ❌ Manual | @@ -285,7 +285,7 @@ res.set("PAYMENT-RESPONSE", settlementHeader); ## When to Use Each Approach -**Use Middleware (@x402/express, @x402/hono) when:** +**Use Middleware (@bankofai/x402-express, @bankofai/x402-hono) when:** - Building standard applications - Want quick integration diff --git a/examples/typescript/servers/express/README.md b/examples/typescript/servers/express/README.md index 2891fbcb..d3ccea54 100644 --- a/examples/typescript/servers/express/README.md +++ b/examples/typescript/servers/express/README.md @@ -1,12 +1,12 @@ -# @x402/express Example Server +# @bankofai/x402-express Example Server -Express.js server demonstrating how to protect API endpoints with a paywall using the `@x402/express` middleware. +Express.js server demonstrating how to protect API endpoints with a paywall using the `@bankofai/x402-express` middleware. ```typescript import express from "express"; -import { paymentMiddleware, x402ResourceServer } from "@x402/express"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-express"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; const app = express(); @@ -14,13 +14,13 @@ app.use( paymentMiddleware( { "GET /weather": { - accepts: { scheme: "exact", price: "$0.001", network: "eip155:84532", payTo: evmAddress }, + accepts: { scheme: "exact", price: "$0.001", network: "eip155:97", payTo: evmAddress }, description: "Weather data", mimeType: "application/json", }, }, new x402ResourceServer(new HTTPFacilitatorClient({ url: facilitatorUrl })) - .register("eip155:84532", new ExactEvmScheme()), + .register("eip155:97", new ExactEvmScheme()), ), ); @@ -85,7 +85,7 @@ These clients will demonstrate how to: ## Example Endpoint -The server includes a single example endpoint at `/weather` that requires a payment of 0.001 USDC on Base Sepolia or Solana Devnet to access. The endpoint returns a simple weather report. +The server includes a single example endpoint at `/weather` that requires a payment of 0.001 USDC on BSC Testnet or Solana Devnet to access. The endpoint returns a simple weather report. ## Response Format @@ -114,10 +114,10 @@ Note: `amount` is in atomic units (e.g., 1000 = 0.001 USDC, since USDC has 6 dec "accepts": [ { "scheme": "exact", - "network": "eip155:84532", + "network": "eip155:97", "amount": "1000", - "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", - "payTo": "0x1c47E9C085c2B7458F5b6C16cCBD65A65255a9f6", + "asset": "0x...", + "payTo": "0x...", "maxTimeoutSeconds": 300, "extra": { "name": "USDC", @@ -157,13 +157,13 @@ The `PAYMENT-RESPONSE` header contains base64-encoded JSON with the settlement d { "success": true, "transaction": "0x...", - "network": "eip155:84532", + "network": "eip155:97", "payer": "0x...", "requirements": { "scheme": "exact", - "network": "eip155:84532", + "network": "eip155:97", "amount": "1000", - "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", + "asset": "0x...", "payTo": "0x...", "maxTimeoutSeconds": 300, "extra": { @@ -188,7 +188,7 @@ app.use( accepts: { scheme: "exact", price: "$0.10", - network: "eip155:84532", + network: "eip155:97", payTo: evmAddress, }, description: "Your endpoint description", @@ -208,10 +208,10 @@ app.get("/your-endpoint", (req, res) => { ``` **Network identifiers** use [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) format, for example: +- `eip155:97` — BSC Testnet +- `eip155:56` — BSC Mainnet - `eip155:84532` — Base Sepolia - `eip155:8453` — Base Mainnet -- `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` — Solana Devnet -- `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` — Solana Mainnet ## x402ResourceServer Config @@ -219,8 +219,7 @@ The `x402ResourceServer` uses a builder pattern to register payment schemes that ```typescript const resourceServer = new x402ResourceServer(facilitatorClient) - .register("eip155:*", new ExactEvmScheme()) // All EVM chains - .register("solana:*", new ExactSvmScheme()) // All SVM chains + .register("eip155:*", new ExactEvmScheme()) // All EVM chains (BSC, Base, etc.) ``` ## Facilitator Config diff --git a/examples/typescript/servers/express/index.ts b/examples/typescript/servers/express/index.ts index 3fffe8fd..69a2728a 100644 --- a/examples/typescript/servers/express/index.ts +++ b/examples/typescript/servers/express/index.ts @@ -30,7 +30,7 @@ app.use( { scheme: "exact", price: "$0.001", - network: "eip155:84532", + network: "eip155:97", payTo: evmAddress, }, { @@ -45,7 +45,7 @@ app.use( }, }, new x402ResourceServer(facilitatorClient) - .register("eip155:84532", new ExactEvmScheme()) + .register("eip155:97", new ExactEvmScheme()) .register("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", new ExactSvmScheme()), ), ); diff --git a/examples/typescript/servers/hono/README.md b/examples/typescript/servers/hono/README.md index 68091443..e0976906 100644 --- a/examples/typescript/servers/hono/README.md +++ b/examples/typescript/servers/hono/README.md @@ -1,12 +1,12 @@ -# @x402/hono Example Server +# @bankofai/x402-hono Example Server -Hono server demonstrating how to protect API endpoints with a paywall using the `@x402/hono` middleware. +Hono server demonstrating how to protect API endpoints with a paywall using the `@bankofai/x402-hono` middleware. ```typescript import { Hono } from "hono"; -import { paymentMiddleware, x402ResourceServer } from "@x402/hono"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-hono"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; const app = new Hono(); diff --git a/examples/typescript/servers/payment-identifier/README.md b/examples/typescript/servers/payment-identifier/README.md index 0c0fecc4..0ccd6f4e 100644 --- a/examples/typescript/servers/payment-identifier/README.md +++ b/examples/typescript/servers/payment-identifier/README.md @@ -14,12 +14,12 @@ import { paymentMiddlewareFromHTTPServer, x402ResourceServer, x402HTTPResourceServer, -} from "@x402/express"; +} from "@bankofai/x402-express"; import { declarePaymentIdentifierExtension, extractPaymentIdentifier, PAYMENT_IDENTIFIER, -} from "@x402/extensions/payment-identifier"; +} from "@bankofai/x402-extensions/payment-identifier"; // In-memory cache (use Redis in production) const idempotencyCache = new Map(); diff --git a/examples/typescript/servers/sign-in-with-x/README.md b/examples/typescript/servers/sign-in-with-x/README.md index 61cf8787..1ef0330b 100644 --- a/examples/typescript/servers/sign-in-with-x/README.md +++ b/examples/typescript/servers/sign-in-with-x/README.md @@ -4,16 +4,16 @@ Express.js server demonstrating how to implement Sign-In-With-X authentication, ```typescript import express from "express"; -import { paymentMiddlewareFromHTTPServer, x402ResourceServer, x402HTTPResourceServer } from "@x402/express"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddlewareFromHTTPServer, x402ResourceServer, x402HTTPResourceServer } from "@bankofai/x402-express"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; import { declareSIWxExtension, siwxResourceServerExtension, createSIWxSettleHook, createSIWxRequestHook, InMemorySIWxStorage, -} from "@x402/extensions/sign-in-with-x"; +} from "@bankofai/x402-extensions/sign-in-with-x"; const storage = new InMemorySIWxStorage(); @@ -132,7 +132,7 @@ const httpServer = new x402HTTPResourceServer(resourceServer, routes) This example uses in-memory storage (`InMemorySIWxStorage`). For production, implement persistent storage: ```typescript -import { SIWxStorage } from "@x402/extensions/sign-in-with-x"; +import { SIWxStorage } from "@bankofai/x402-extensions/sign-in-with-x"; class RedisSIWxStorage implements SIWxStorage { async recordPayment(address: string, resource: string): Promise { diff --git a/python/legacy/README.md b/python/legacy/README.md index 7901d150..bb734482 100644 --- a/python/legacy/README.md +++ b/python/legacy/README.md @@ -5,7 +5,7 @@ Python package for the x402 payments protocol. ## Installation ```bash -pip install x402 +pip install bankofai.x402 ``` ## Overview @@ -23,7 +23,7 @@ The simplest way to add x402 payment protection to your FastAPI application: ```py from fastapi import FastAPI -from x402.fastapi.middleware import require_payment +from bankofai.x402.fastapi.middleware import require_payment app = FastAPI() app.middleware("http")( @@ -51,7 +51,7 @@ The simplest way to add x402 payment protection to your Flask application: ```py from flask import Flask -from x402.flask.middleware import PaymentMiddleware +from bankofai.x402.flask.middleware import PaymentMiddleware app = Flask(__name__) @@ -87,7 +87,7 @@ payment_middleware.add( #### Httpx Client ```py from eth_account import Account -from x402.clients.httpx import x402HttpxClient +from bankofai.x402.clients.httpx import x402HttpxClient # Initialize account account = Account.from_key("your_private_key") @@ -101,7 +101,7 @@ async with x402HttpxClient(account=account, base_url="https://api.example.com") #### Requests Session Client ```py from eth_account import Account -from x402.clients.requests import x402_requests +from bankofai.x402.clients.requests import x402_requests # Initialize account account = Account.from_key("your_private_key") @@ -118,7 +118,7 @@ print(response.content) ```py import httpx from eth_account import Account -from x402.clients.httpx import x402_payment_hooks +from bankofai.x402.clients.httpx import x402_payment_hooks # Initialize account account = Account.from_key("your_private_key") @@ -137,7 +137,7 @@ async with httpx.AsyncClient(base_url="https://api.example.com") as client: ```py import requests from eth_account import Account -from x402.clients.requests import x402_http_adapter +from bankofai.x402.clients.requests import x402_http_adapter # Initialize account account = Account.from_key("your_private_key") @@ -171,9 +171,9 @@ import base64 import json from typing import Annotated from fastapi import FastAPI, Request, Response, JSONResponse -from x402.types import PaymentRequiredResponse, PaymentRequirements, PaymentPayload -from x402.encoding import safe_base64_decode -from x402.facilitator import FacilitatorClient +from bankofai.x402.types import PaymentRequiredResponse, PaymentRequirements, PaymentPayload +from bankofai.x402.encoding import safe_base64_decode +from bankofai.x402.facilitator import FacilitatorClient payment_requirements = PaymentRequirements(...) facilitator = FacilitatorClient(facilitator_url) diff --git a/python/x402/README.md b/python/x402/README.md index acf7bbf5..a6f8395f 100644 --- a/python/x402/README.md +++ b/python/x402/README.md @@ -1,29 +1,30 @@ -# x402 Python SDK +# bankofai.x402 Python SDK Core implementation of the x402 payment protocol. Provides transport-agnostic client, server, and facilitator components with both async and sync variants. ## Installation -Install the core package with your preferred framework/client: +Install the package with your preferred framework/client: ```bash # HTTP clients (pick one) -uv add x402[httpx] # httpx client -uv add x402[requests] # requests client +uv add bankofai.x402[httpx] # httpx client +uv add bankofai.x402[requests] # requests client # Server frameworks (pick one) -uv add x402[fastapi] # FastAPI middleware -uv add x402[flask] # Flask middleware +uv add bankofai.x402[fastapi] # FastAPI middleware +uv add bankofai.x402[flask] # Flask middleware -# Blockchain mechanisms (pick one or both) -uv add x402[evm] # EVM/Ethereum -uv add x402[svm] # Solana +# Blockchain mechanisms (pick one or all) +uv add bankofai.x402[tron] # TRON +uv add bankofai.x402[evm] # EVM/Ethereum/BSC +uv add bankofai.x402[svm] # Solana # Multiple extras -uv add x402[fastapi,httpx,evm] +uv add "bankofai.x402[fastapi,httpx,tron,evm]" # Everything -uv add x402[all] +uv add "bankofai.x402[all]" ``` ## Quick Start @@ -31,11 +32,14 @@ uv add x402[all] ### Client (Async) ```python -from x402 import x402Client -from x402.mechanisms.evm.exact import ExactEvmScheme +from bankofai.x402 import x402Client +from bankofai.x402.mechanisms.tron.exact import ExactTronScheme +from bankofai.x402.mechanisms.evm.exact import ExactEvmScheme client = x402Client() -client.register("eip155:*", ExactEvmScheme(signer=my_signer)) +# Register TRON and EVM handlers +client.register("tron:*", ExactTronScheme(signer=my_tron_signer)) +client.register("eip155:*", ExactEvmScheme(signer=my_evm_signer)) # Create payment from 402 response payload = await client.create_payment_payload(payment_required) @@ -44,11 +48,11 @@ payload = await client.create_payment_payload(payment_required) ### Client (Sync) ```python -from x402 import x402ClientSync -from x402.mechanisms.evm.exact import ExactEvmScheme +from bankofai.x402 import x402ClientSync +from bankofai.x402.mechanisms.tron.exact import ExactTronScheme client = x402ClientSync() -client.register("eip155:*", ExactEvmScheme(signer=my_signer)) +client.register("tron:*", ExactTronScheme(signer=my_tron_signer)) payload = client.create_payment_payload(payment_required) ``` @@ -56,20 +60,20 @@ payload = client.create_payment_payload(payment_required) ### Server (Async) ```python -from x402 import x402ResourceServer, ResourceConfig -from x402.http import HTTPFacilitatorClient -from x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402 import x402ResourceServer, ResourceConfig +from bankofai.x402.http import HTTPFacilitatorClient +from bankofai.x402.mechanisms.tron.exact import ExactTronServerScheme facilitator = HTTPFacilitatorClient(url="https://x402.org/facilitator") server = x402ResourceServer(facilitator) -server.register("eip155:*", ExactEvmServerScheme()) +server.register("tron:*", ExactTronServerScheme()) server.initialize() # Build requirements config = ResourceConfig( scheme="exact", - network="eip155:8453", - pay_to="0x...", + network="tron:mainnet", # TRON Mainnet + pay_to="T...", price="$0.01", ) requirements = server.build_payment_requirements(config) @@ -81,13 +85,13 @@ result = await server.verify_payment(payload, requirements[0]) ### Server (Sync) ```python -from x402 import x402ResourceServerSync, ResourceConfig -from x402.http import HTTPFacilitatorClientSync -from x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402 import x402ResourceServerSync, ResourceConfig +from bankofai.x402.http import HTTPFacilitatorClientSync +from bankofai.x402.mechanisms.tron.exact import ExactTronServerScheme facilitator = HTTPFacilitatorClientSync(url="https://x402.org/facilitator") server = x402ResourceServerSync(facilitator) -server.register("eip155:*", ExactEvmServerScheme()) +server.register("tron:*", ExactTronServerScheme()) server.initialize() result = server.verify_payment(payload, requirements[0]) @@ -96,13 +100,13 @@ result = server.verify_payment(payload, requirements[0]) ### Facilitator (Async) ```python -from x402 import x402Facilitator -from x402.mechanisms.evm.exact import ExactEvmFacilitatorScheme +from bankofai.x402 import x402Facilitator +from bankofai.x402.mechanisms.tron.exact import ExactTronFacilitatorScheme facilitator = x402Facilitator() facilitator.register( - ["eip155:8453", "eip155:84532"], - ExactEvmFacilitatorScheme(wallet=wallet), + ["tron:mainnet", "tron:nile"], # Mainnet and Nile + ExactTronFacilitatorScheme(wallet=wallet), ) result = await facilitator.verify(payload, requirements) @@ -113,13 +117,13 @@ if result.is_valid: ### Facilitator (Sync) ```python -from x402 import x402FacilitatorSync -from x402.mechanisms.evm.exact import ExactEvmFacilitatorScheme +from bankofai.x402 import x402FacilitatorSync +from bankofai.x402.mechanisms.tron.exact import ExactTronFacilitatorScheme facilitator = x402FacilitatorSync() facilitator.register( - ["eip155:8453", "eip155:84532"], - ExactEvmFacilitatorScheme(wallet=wallet), + ["tron:mainnet"], + ExactTronFacilitatorScheme(wallet=wallet), ) result = facilitator.verify(payload, requirements) @@ -152,14 +156,16 @@ Mismatched variants raise `TypeError` at runtime. Use `from_config()` for declarative setup: ```python -from x402 import x402Client, x402ClientConfig, SchemeRegistration +from bankofai.x402 import x402Client, x402ClientConfig, SchemeRegistration +from bankofai.x402.mechanisms.tron.exact import ExactTronScheme +from bankofai.x402.mechanisms.evm.exact import ExactEvmScheme config = x402ClientConfig( schemes=[ - SchemeRegistration(network="eip155:*", client=ExactEvmScheme(signer)), - SchemeRegistration(network="solana:*", client=ExactSvmScheme(signer)), + SchemeRegistration(network="tron:*", client=ExactTronScheme(tron_signer)), + SchemeRegistration(network="eip155:*", client=ExactEvmScheme(evm_signer)), ], - policies=[prefer_network("eip155:8453")], + policies=[prefer_network("tron:mainnet")], ) client = x402Client.from_config(config) ``` @@ -169,11 +175,11 @@ client = x402Client.from_config(config) Filter or prioritize payment requirements: ```python -from x402 import prefer_network, prefer_scheme, max_amount +from bankofai.x402 import prefer_network, prefer_scheme, max_amount -client.register_policy(prefer_network("eip155:8453")) +client.register_policy(prefer_network("tron:mainnet")) client.register_policy(prefer_scheme("exact")) -client.register_policy(max_amount(1_000_000)) # 1 USDC max +client.register_policy(max_amount(1_000_000)) # 1 USDC (6 decimals) max ``` ## Lifecycle Hooks @@ -181,7 +187,7 @@ client.register_policy(max_amount(1_000_000)) # 1 USDC max ### Client Hooks ```python -from x402 import AbortResult, RecoveredPayloadResult +from bankofai.x402 import AbortResult, RecoveredPayloadResult def before_payment(ctx): print(f"Creating payment for: {ctx.selected_requirements.network}") diff --git a/python/x402/src/bankofai/x402/extensions/README.md b/python/x402/src/bankofai/x402/extensions/README.md index efa53f38..33889552 100644 --- a/python/x402/src/bankofai/x402/extensions/README.md +++ b/python/x402/src/bankofai/x402/extensions/README.md @@ -5,7 +5,7 @@ Optional extensions that enhance the x402 payment protocol with additional funct ## Installation ```bash -uv add x402[extensions] +uv add bankofai.x402[extensions] ``` ## Bazaar Discovery Extension @@ -17,7 +17,7 @@ Enables facilitators to automatically catalog and index x402-enabled resources b Declare endpoint discovery metadata in route configuration: ```python -from x402.extensions.bazaar import declare_discovery_extension +from bankofai.x402.extensions.bazaar import declare_discovery_extension routes = { "GET /api/weather": { @@ -70,7 +70,7 @@ routes = { Extract discovery information from payment requests: ```python -from x402.extensions.bazaar import extract_discovery_info +from bankofai.x402.extensions.bazaar import extract_discovery_info discovered = extract_discovery_info(payment_payload, payment_requirements) @@ -83,7 +83,7 @@ if discovered: #### Validation ```python -from x402.extensions.bazaar import validate_discovery_extension +from bankofai.x402.extensions.bazaar import validate_discovery_extension result = validate_discovery_extension(extension) if not result.valid: @@ -95,7 +95,7 @@ if not result.valid: Auto-enrich extensions with HTTP method from route: ```python -from x402.extensions.bazaar import bazaar_resource_server_extension +from bankofai.x402.extensions.bazaar import bazaar_resource_server_extension server = x402ResourceServer(facilitator) server.register_extension(bazaar_resource_server_extension) diff --git a/python/x402/src/bankofai/x402/http/README.md b/python/x402/src/bankofai/x402/http/README.md index edcfd7e3..17435b53 100644 --- a/python/x402/src/bankofai/x402/http/README.md +++ b/python/x402/src/bankofai/x402/http/README.md @@ -20,7 +20,7 @@ Communicates with remote x402 facilitator services. ### Async ```python -from x402.http import HTTPFacilitatorClient, FacilitatorConfig +from bankofai.x402.http import HTTPFacilitatorClient, FacilitatorConfig facilitator = HTTPFacilitatorClient( FacilitatorConfig(url="https://x402.org/facilitator") @@ -39,7 +39,7 @@ settle = await facilitator.settle(payload, requirements) ### Sync ```python -from x402.http import HTTPFacilitatorClientSync +from bankofai.x402.http import HTTPFacilitatorClientSync facilitator = HTTPFacilitatorClientSync(url="https://x402.org/facilitator") @@ -50,7 +50,7 @@ result = facilitator.verify(payload, requirements) ### Authentication ```python -from x402.http import FacilitatorConfig, AuthHeaders +from bankofai.x402.http import FacilitatorConfig, AuthHeaders class MyAuth: async def get_auth_headers(self) -> AuthHeaders: @@ -71,7 +71,7 @@ config = FacilitatorConfig( Encoding/decoding utilities: ```python -from x402.http import ( +from bankofai.x402.http import ( encode_payment_signature_header, decode_payment_signature_header, encode_payment_required_header, @@ -90,7 +90,7 @@ payload = decode_payment_signature_header(header_value) ## Constants ```python -from x402.http import ( +from bankofai.x402.http import ( PAYMENT_SIGNATURE_HEADER, # "PAYMENT-SIGNATURE" PAYMENT_REQUIRED_HEADER, # "PAYMENT-REQUIRED" PAYMENT_RESPONSE_HEADER, # "PAYMENT-RESPONSE" @@ -109,7 +109,7 @@ from x402.http import ( ## Route Configuration ```python -from x402.http import RouteConfig, PaymentOption, RoutesConfig +from bankofai.x402.http import RouteConfig, PaymentOption, RoutesConfig routes: RoutesConfig = { "GET /api/weather/*": RouteConfig( diff --git a/python/x402/src/bankofai/x402/http/clients/README.md b/python/x402/src/bankofai/x402/http/clients/README.md index 9fe2a041..0e68884a 100644 --- a/python/x402/src/bankofai/x402/http/clients/README.md +++ b/python/x402/src/bankofai/x402/http/clients/README.md @@ -5,15 +5,15 @@ HTTP client wrappers with automatic 402 payment handling. ## httpx (Async) ```bash -uv add x402[httpx] +uv add bankofai.x402[httpx] ``` ### Transport Wrapper ```python -from x402 import x402Client -from x402.http.clients import x402_httpx_transport -from x402.mechanisms.evm.exact import ExactEvmScheme +from bankofai.x402 import x402Client +from bankofai.x402.http.clients import x402_httpx_transport +from bankofai.x402.mechanisms.evm.exact import ExactEvmScheme import httpx client = x402Client() @@ -28,7 +28,7 @@ async with httpx.AsyncClient( ### Convenience Wrapper ```python -from x402.http.clients import wrapHttpxWithPayment +from bankofai.x402.http.clients import wrapHttpxWithPayment async with wrapHttpxWithPayment(client) as http: response = await http.get("https://api.example.com/paid") @@ -37,8 +37,8 @@ async with wrapHttpxWithPayment(client) as http: ### From Config ```python -from x402 import x402ClientConfig, SchemeRegistration -from x402.http.clients import wrapHttpxWithPaymentFromConfig +from bankofai.x402 import x402ClientConfig, SchemeRegistration +from bankofai.x402.http.clients import wrapHttpxWithPaymentFromConfig config = x402ClientConfig( schemes=[ @@ -56,7 +56,7 @@ async with wrapHttpxWithPaymentFromConfig(config) as http: ### Client Class ```python -from x402.http.clients import x402HttpxClient +from bankofai.x402.http.clients import x402HttpxClient async with x402HttpxClient(client) as http: response = await http.get("https://api.example.com/paid") @@ -65,15 +65,15 @@ async with x402HttpxClient(client) as http: ## requests (Sync) ```bash -uv add x402[requests] +uv add bankofai.x402[requests] ``` ### Session Wrapper ```python -from x402 import x402ClientSync -from x402.http.clients import wrapRequestsWithPayment -from x402.mechanisms.evm.exact import ExactEvmScheme +from bankofai.x402 import x402ClientSync +from bankofai.x402.http.clients import wrapRequestsWithPayment +from bankofai.x402.mechanisms.evm.exact import ExactEvmScheme import requests client = x402ClientSync() @@ -86,7 +86,7 @@ response = session.get("https://api.example.com/paid") ### HTTP Adapter ```python -from x402.http.clients import x402_http_adapter +from bankofai.x402.http.clients import x402_http_adapter import requests session = requests.Session() @@ -100,7 +100,7 @@ response = session.get("https://api.example.com/paid") ### Convenience Function ```python -from x402.http.clients import x402_requests +from bankofai.x402.http.clients import x402_requests session = x402_requests(client) response = session.get("https://api.example.com/paid") @@ -109,7 +109,7 @@ response = session.get("https://api.example.com/paid") ### From Config ```python -from x402.http.clients import wrapRequestsWithPaymentFromConfig +from bankofai.x402.http.clients import wrapRequestsWithPaymentFromConfig session = wrapRequestsWithPaymentFromConfig(requests.Session(), config) ``` diff --git a/python/x402/src/bankofai/x402/http/middleware/README.md b/python/x402/src/bankofai/x402/http/middleware/README.md index b7050859..e61ef11a 100644 --- a/python/x402/src/bankofai/x402/http/middleware/README.md +++ b/python/x402/src/bankofai/x402/http/middleware/README.md @@ -5,17 +5,17 @@ Server-side middleware for protecting routes with x402 payments. ## FastAPI (Async) ```bash -uv add x402[fastapi] +uv add bankofai.x402[fastapi] ``` ### Basic Usage ```python from fastapi import FastAPI -from x402 import x402ResourceServer -from x402.http import HTTPFacilitatorClient -from x402.http.middleware import payment_middleware -from x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402 import x402ResourceServer +from bankofai.x402.http import HTTPFacilitatorClient +from bankofai.x402.http.middleware import payment_middleware +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme app = FastAPI() @@ -46,7 +46,7 @@ async def x402_middleware(request, call_next): ### ASGI Middleware Class ```python -from x402.http.middleware import PaymentMiddlewareASGI +from bankofai.x402.http.middleware import PaymentMiddlewareASGI app.add_middleware( PaymentMiddlewareASGI, @@ -69,17 +69,17 @@ async def weather(request: Request): ## Flask (Sync) ```bash -uv add x402[flask] +uv add bankofai.x402[flask] ``` ### Basic Usage ```python from flask import Flask, g -from x402 import x402ResourceServerSync -from x402.http import HTTPFacilitatorClientSync -from x402.http.middleware import PaymentMiddleware -from x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402 import x402ResourceServerSync +from bankofai.x402.http import HTTPFacilitatorClientSync +from bankofai.x402.http.middleware import PaymentMiddleware +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme app = Flask(__name__) @@ -112,7 +112,7 @@ def weather(): ### Convenience Function ```python -from x402.http.middleware import payment_middleware +from bankofai.x402.http.middleware import payment_middleware payment_middleware(app, routes, server, paywall_config={"appName": "My API"}) ``` @@ -152,7 +152,7 @@ Browser requests to protected routes show an HTML paywall. API requests receive ## Custom Paywall ```python -from x402.http import PaywallProvider +from bankofai.x402.http import PaywallProvider class MyPaywall(PaywallProvider): def generate_html(self, payment_required, config): diff --git a/python/x402/src/bankofai/x402/mcp/README.md b/python/x402/src/bankofai/x402/mcp/README.md index 8c870db7..f095aaeb 100644 --- a/python/x402/src/bankofai/x402/mcp/README.md +++ b/python/x402/src/bankofai/x402/mcp/README.md @@ -5,7 +5,7 @@ MCP (Model Context Protocol) integration for the x402 payment protocol. This pac ## Installation ```bash -pip install x402 +pip install bankofai.x402 ``` ## Quick Start @@ -13,8 +13,8 @@ pip install x402 ### Server - Using Payment Wrapper ```python -from x402 import x402ResourceServerSync -from x402.mcp import create_payment_wrapper, PaymentWrapperConfig +from bankofai.x402 import x402ResourceServerSync +from bankofai.x402.mcp import create_payment_wrapper, PaymentWrapperConfig # Create x402 resource server facilitator_client = # ... create facilitator client @@ -46,8 +46,8 @@ def handler(args, context): ### Client - Using Factory Function ```python -from x402.mcp import create_x402_mcp_client_from_config -from x402.mechanisms.evm.exact import ExactEvmClientScheme +from bankofai.x402.mcp import create_x402_mcp_client_from_config +from bankofai.x402.mechanisms.evm.exact import ExactEvmClientScheme # Create MCP client (from MCP SDK) mcp_client = # ... create MCP client @@ -96,7 +96,7 @@ x402_mcp = create_x402_mcp_client_from_config( Wraps an existing MCP client with x402 payment handling. ```python -from x402 import x402ClientSync +from bankofai.x402 import x402ClientSync payment_client = x402ClientSync() payment_client.register("eip155:84532", evm_client_scheme) @@ -129,7 +129,7 @@ x402_mcp = wrap_mcp_client_with_payment_from_config( Creates a payment wrapper for MCP tool handlers. ```python -from x402.mcp import PaymentWrapperHooks +from bankofai.x402.mcp import PaymentWrapperHooks paid = create_payment_wrapper( resource_server, @@ -149,7 +149,7 @@ paid = create_payment_wrapper( #### Error Handling ```python -from x402.mcp import ( +from bankofai.x402.mcp import ( create_payment_required_error, is_payment_required_error, extract_payment_required_from_error, @@ -171,7 +171,7 @@ pr = extract_payment_required_from_error(json_rpc_error) #### Type Guards ```python -from x402.mcp import is_object +from bankofai.x402.mcp import is_object # Check if value is an object if is_object(value): diff --git a/python/x402/src/bankofai/x402/mechanisms/evm/README.md b/python/x402/src/bankofai/x402/mechanisms/evm/README.md index c51fc93e..4a6b513b 100644 --- a/python/x402/src/bankofai/x402/mechanisms/evm/README.md +++ b/python/x402/src/bankofai/x402/mechanisms/evm/README.md @@ -5,7 +5,7 @@ EVM implementation of the x402 payment protocol using the **Exact** payment sche ## Installation ```bash -uv add x402[evm] +uv add bankofai.x402[evm] ``` ## Overview @@ -21,9 +21,9 @@ Three components for handling x402 payments on EVM-compatible blockchains: ### Client ```python -from x402 import x402Client -from x402.mechanisms.evm.exact import ExactEvmScheme -from x402.mechanisms.evm import EthAccountSigner +from bankofai.x402 import x402Client +from bankofai.x402.mechanisms.evm.exact import ExactEvmScheme +from bankofai.x402.mechanisms.evm import EthAccountSigner from eth_account import Account account = Account.from_key("0x...") @@ -38,8 +38,8 @@ payload = await client.create_payment_payload(payment_required) ### Server ```python -from x402 import x402ResourceServer -from x402.mechanisms.evm.exact import ExactEvmServerScheme +from bankofai.x402 import x402ResourceServer +from bankofai.x402.mechanisms.evm.exact import ExactEvmServerScheme server = x402ResourceServer(facilitator_client) server.register("eip155:*", ExactEvmServerScheme()) @@ -48,9 +48,9 @@ server.register("eip155:*", ExactEvmServerScheme()) ### Facilitator ```python -from x402 import x402Facilitator -from x402.mechanisms.evm.exact import ExactEvmFacilitatorScheme -from x402.mechanisms.evm import FacilitatorWeb3Signer +from bankofai.x402 import x402Facilitator +from bankofai.x402.mechanisms.evm.exact import ExactEvmFacilitatorScheme +from bankofai.x402.mechanisms.evm import FacilitatorWeb3Signer signer = FacilitatorWeb3Signer(web3_instance, account) diff --git a/python/x402/src/bankofai/x402/mechanisms/svm/README.md b/python/x402/src/bankofai/x402/mechanisms/svm/README.md index ab826140..acaf471c 100644 --- a/python/x402/src/bankofai/x402/mechanisms/svm/README.md +++ b/python/x402/src/bankofai/x402/mechanisms/svm/README.md @@ -5,7 +5,7 @@ Solana implementation of the x402 payment protocol using the **Exact** payment s ## Installation ```bash -uv add x402[svm] +uv add bankofai.x402[svm] ``` ## Overview @@ -21,9 +21,9 @@ Three components for handling x402 payments on Solana: ### Client ```python -from x402 import x402Client -from x402.mechanisms.svm.exact import ExactSvmScheme -from x402.mechanisms.svm import KeypairSigner +from bankofai.x402 import x402Client +from bankofai.x402.mechanisms.svm.exact import ExactSvmScheme +from bankofai.x402.mechanisms.svm import KeypairSigner from solders.keypair import Keypair keypair = Keypair.from_base58_string("...") @@ -38,8 +38,8 @@ payload = await client.create_payment_payload(payment_required) ### Server ```python -from x402 import x402ResourceServer -from x402.mechanisms.svm.exact import ExactSvmServerScheme +from bankofai.x402 import x402ResourceServer +from bankofai.x402.mechanisms.svm.exact import ExactSvmServerScheme server = x402ResourceServer(facilitator_client) server.register("solana:*", ExactSvmServerScheme()) @@ -48,9 +48,9 @@ server.register("solana:*", ExactSvmServerScheme()) ### Facilitator ```python -from x402 import x402Facilitator -from x402.mechanisms.svm.exact import ExactSvmFacilitatorScheme -from x402.mechanisms.svm import FacilitatorKeypairSigner +from bankofai.x402 import x402Facilitator +from bankofai.x402.mechanisms.svm.exact import ExactSvmFacilitatorScheme +from bankofai.x402.mechanisms.svm import FacilitatorKeypairSigner signer = FacilitatorKeypairSigner(keypair, rpc_client) diff --git a/typescript/packages/core/CHANGELOG.md b/typescript/packages/core/CHANGELOG.md index fe72eea1..17765090 100644 --- a/typescript/packages/core/CHANGELOG.md +++ b/typescript/packages/core/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/core Changelog +# @bankofai/x402-core Changelog ## 2.6.0 @@ -14,7 +14,7 @@ ### Minor Changes -- Bumped to align version with dependent packages (@x402/evm, @x402/extensions) +- Bumped to align version with dependent packages (@bankofai/x402-evm, @bankofai/x402-extensions) ### Patch Changes @@ -27,7 +27,7 @@ - 57a5488: Add Aptos blockchain support to x402 payment protocol - - Introduces new `@x402/aptos` package with full client, server, and facilitator scheme implementations + - Introduces new `@bankofai/x402-aptos` package with full client, server, and facilitator scheme implementations - Supports exact payment mechanism for Aptos using native APT and fungible assets - Includes sponsored transaction support where facilitator pays gas fees - Provides `registerExactAptosScheme` helpers for easy client and server integration diff --git a/typescript/packages/core/README.md b/typescript/packages/core/README.md index c2c92188..57e85150 100644 --- a/typescript/packages/core/README.md +++ b/typescript/packages/core/README.md @@ -1,11 +1,11 @@ -# @x402/core +# @bankofai/x402-core Core implementation of the x402 payment protocol for TypeScript/JavaScript applications. Provides transport-agnostic client, server and facilitator components. ## Installation ```bash -pnpm install @x402/core +pnpm install @bankofai/x402-core ``` ## Quick Start @@ -13,12 +13,14 @@ pnpm install @x402/core ### Client Usage ```typescript -import { x402Client } from '@x402/core/client'; -import { x402HTTPClient } from '@x402/core/http'; -import { ExactEvmScheme } from '@x402/evm/exact/client'; +import { x402Client } from '@bankofai/x402-core/client'; +import { x402HTTPClient } from '@bankofai/x402-core/http'; +import { ExactTronScheme } from '@bankofai/x402-tron/exact/client'; +import { ExactEvmScheme } from '@bankofai/x402-evm/exact/client'; // Create core client and register payment schemes const coreClient = new x402Client() + .register('tron:*', new ExactTronScheme(tronSigner)) .register('eip155:*', new ExactEvmScheme(evmSigner)); // Wrap with HTTP client for header encoding/decoding @@ -52,9 +54,9 @@ if (response.status === 402) { ### Server Usage ```typescript -import { x402ResourceServer, HTTPFacilitatorClient } from '@x402/core/server'; -import { x402HTTPResourceServer } from '@x402/core/http'; -import { ExactEvmScheme } from '@x402/evm/exact/server'; +import { x402ResourceServer, HTTPFacilitatorClient } from '@bankofai/x402-core/server'; +import { x402HTTPResourceServer } from '@bankofai/x402-core/http'; +import { ExactTronScheme } from '@bankofai/x402-tron/exact/server'; // Connect to facilitator const facilitatorClient = new HTTPFacilitatorClient({ @@ -63,7 +65,7 @@ const facilitatorClient = new HTTPFacilitatorClient({ // Create resource server with payment schemes const resourceServer = new x402ResourceServer(facilitatorClient) - .register('eip155:*', new ExactEvmScheme()); + .register('tron:*', new ExactTronScheme()); // Initialize (fetches supported kinds from facilitator) await resourceServer.initialize(); @@ -73,8 +75,8 @@ const routes = { 'GET /api/data': { accepts: { scheme: 'exact', - network: 'eip155:8453', - payTo: '0xYourAddress', + network: 'tron:mainnet', + payTo: 'TYourTronAddress', price: '$0.01', }, description: 'Premium data access', @@ -89,15 +91,15 @@ const httpServer = new x402HTTPResourceServer(resourceServer, routes); ### Facilitator Usage ```typescript -import { x402Facilitator } from '@x402/core/facilitator'; -import { registerExactEvmScheme } from '@x402/evm/exact/facilitator'; +import { x402Facilitator } from '@bankofai/x402-core/facilitator'; +import { registerExactTronScheme } from '@bankofai/x402-tron/exact/facilitator'; const facilitator = new x402Facilitator(); // Register scheme implementations using helper -registerExactEvmScheme(facilitator, { - signer: evmSigner, - networks: 'eip155:84532', +registerExactTronScheme(facilitator, { + signer: tronSigner, + networks: 'tron:mainnet', }); // Verify payment @@ -155,8 +157,8 @@ Use `fromConfig()` for declarative setup: ```typescript const client = x402Client.fromConfig({ schemes: [ + { network: 'tron:mainnet', client: new ExactTronScheme(tronSigner) }, { network: 'eip155:8453', client: new ExactEvmScheme(evmSigner) }, - { network: 'solana:mainnet', client: new ExactSvmScheme(svmSigner) }, ], policies: [ // Filter by max price @@ -271,18 +273,21 @@ type PaymentRequired = { For framework-specific middleware, use: -- `@x402/express` - Express.js middleware -- `@x402/hono` - Hono middleware -- `@x402/next` - Next.js integration -- `@x402/axios` - Axios interceptor -- `@x402/fetch` - Fetch wrapper +- `@bankofai/x402-express` - Express.js middleware +- `@bankofai/x402-hono` - Hono middleware +- `@bankofai/x402-next` - Next.js integration +- `@bankofai/x402-axios` - Axios interceptor +- `@bankofai/x402-fetch` - Fetch wrapper ## Implementation Packages For blockchain-specific implementations: -- `@x402/evm` - Ethereum and EVM-compatible chains -- `@x402/svm` - Solana blockchain +- `@bankofai/x402-tron` - TRON blockchain +- `@bankofai/x402-evm` - Ethereum and EVM-compatible chains +- `@bankofai/x402-svm` - Solana blockchain +- `@bankofai/x402-aptos` - Aptos blockchain +- `@bankofai/x402-stellar` - Stellar blockchain ## Examples diff --git a/typescript/packages/extensions/CHANGELOG.md b/typescript/packages/extensions/CHANGELOG.md index 899ed31e..ad06a5be 100644 --- a/typescript/packages/extensions/CHANGELOG.md +++ b/typescript/packages/extensions/CHANGELOG.md @@ -1,11 +1,11 @@ -# @x402/extensions Changelog +# @bankofai/x402-extensions Changelog ## 2.6.0 ### Minor Changes - Updated dependencies - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -19,7 +19,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -37,7 +37,7 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.1 @@ -45,7 +45,7 @@ - f93fc09: Added solanakit support for siwx - Updated dependencies [9ec9f15] - - @x402/core@2.3.1 + - @bankofai/x402-core@2.3.1 ## 2.3.0 @@ -58,7 +58,7 @@ - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/extensions/README.md b/typescript/packages/extensions/README.md index 91d4c560..7346de32 100644 --- a/typescript/packages/extensions/README.md +++ b/typescript/packages/extensions/README.md @@ -1,11 +1,11 @@ -# @x402/extensions +# @bankofai/x402-extensions x402 Payment Protocol Extensions. This package provides optional extensions that enhance the x402 payment protocol with additional functionality. ## Installation ```bash -pnpm install @x402/extensions +pnpm install @bankofai/x402-extensions ``` ## Overview @@ -36,15 +36,15 @@ Declare endpoint discovery metadata in your payment middleware configuration. Th #### Basic Example: GET Endpoint with Query Parameters ```typescript -import { declareDiscoveryExtension } from "@x402/extensions/bazaar"; +import { declareDiscoveryExtension } from "@bankofai/x402-extensions/bazaar"; const resources = { "GET /weather": { accepts: { scheme: "exact", price: "$0.001", - network: "eip155:84532", - payTo: "0xYourAddress" + network: "tron:mainnet", + payTo: "TYourTronAddress" }, extensions: { ...declareDiscoveryExtension({ @@ -75,7 +75,7 @@ const resources = { For POST, PUT, and PATCH endpoints, specify `bodyType` to indicate the request body format: ```typescript -import { declareDiscoveryExtension } from "@x402/extensions/bazaar"; +import { declareDiscoveryExtension } from "@bankofai/x402-extensions/bazaar"; const resources = { "POST /api/translate": { @@ -189,7 +189,7 @@ const resources = { For MCP (Model Context Protocol) tools, use the `toolName` field instead of `bodyType`/`input`. The HTTP method is not relevant -- MCP tools are invoked by name. ```typescript -import { declareDiscoveryExtension } from "@x402/extensions/bazaar"; +import { declareDiscoveryExtension } from "@bankofai/x402-extensions/bazaar"; const resources = { "POST /mcp": { @@ -233,10 +233,10 @@ You can optionally specify `transport` to indicate the MCP transport type (`"str #### Using with Next.js Middleware ```typescript -import { paymentProxy, x402ResourceServer } from "@x402/next"; -import { HTTPFacilitatorClient } from "@x402/core/http"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { declareDiscoveryExtension } from "@x402/extensions/bazaar"; +import { paymentProxy, x402ResourceServer } from "@bankofai/x402-next"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/http"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { declareDiscoveryExtension } from "@bankofai/x402-extensions/bazaar"; const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.org" }); const resourceServer = new x402ResourceServer(facilitatorClient) @@ -276,8 +276,8 @@ Extract discovery information from incoming payment requests to catalog resource #### Basic Usage ```typescript -import { extractDiscoveryInfo } from "@x402/extensions/bazaar"; -import type { PaymentPayload, PaymentRequirements } from "@x402/core/types"; +import { extractDiscoveryInfo } from "@bankofai/x402-extensions/bazaar"; +import type { PaymentPayload, PaymentRequirements } from "@bankofai/x402-core/types"; async function handlePayment( paymentPayload: PaymentPayload, @@ -312,7 +312,7 @@ async function handlePayment( #### Validating Discovery Extensions ```typescript -import { validateDiscoveryExtension, extractDiscoveryInfo } from "@x402/extensions/bazaar"; +import { validateDiscoveryExtension, extractDiscoveryInfo } from "@bankofai/x402-extensions/bazaar"; function processPayment(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements) { const discovered = extractDiscoveryInfo(paymentPayload, paymentRequirements); @@ -338,8 +338,8 @@ function processPayment(paymentPayload: PaymentPayload, paymentRequirements: Pay The `bazaarResourceServerExtension` automatically enriches discovery extensions with HTTP method information from the request context: ```typescript -import { bazaarResourceServerExtension } from "@x402/extensions/bazaar"; -import { x402ResourceServer } from "@x402/core/server"; +import { bazaarResourceServerExtension } from "@bankofai/x402-extensions/bazaar"; +import { x402ResourceServer } from "@bankofai/x402-core/server"; // The extension helper automatically extracts discovery info const resourceServer = new x402ResourceServer(facilitatorClient) @@ -452,7 +452,7 @@ A server extension that automatically enriches HTTP discovery extensions with me **Usage:** ```typescript -import { bazaarResourceServerExtension } from "@x402/extensions/bazaar"; +import { bazaarResourceServerExtension } from "@bankofai/x402-extensions/bazaar"; const resourceServer = new x402ResourceServer(facilitatorClient) .registerExtension(bazaarResourceServerExtension); @@ -484,21 +484,21 @@ import { createSIWxSettleHook, createSIWxRequestHook, InMemorySIWxStorage, -} from '@x402/extensions/sign-in-with-x'; +} from '@bankofai/x402-extensions/sign-in-with-x'; // Storage for tracking paid addresses const storage = new InMemorySIWxStorage(); // 1. Register extension for time-based field refreshment const resourceServer = new x402ResourceServer(facilitatorClient) - .register(NETWORK, new ExactEvmScheme()) + .register(NETWORK, new ExactTronScheme()) .registerExtension(siwxResourceServerExtension) // Refreshes nonce/timestamps per request .onAfterSettle(createSIWxSettleHook({ storage })); // Records payments // 2. Declare SIWX support in routes (network/domain/uri derived automatically) const routes = { "GET /data": { - accepts: [{scheme: "exact", price: "$0.01", network: "eip155:8453", payTo}], + accepts: [{scheme: "exact", price: "$0.01", network: "tron:mainnet", payTo}], extensions: declareSIWxExtension({ statement: 'Sign in to access your purchased content', }), @@ -535,7 +535,7 @@ import { validateSIWxMessage, verifySIWxSignature, SIGN_IN_WITH_X, -} from '@x402/extensions/sign-in-with-x'; +} from '@bankofai/x402-extensions/sign-in-with-x'; // 1. Declare in PaymentRequired response const extensions = { @@ -584,8 +584,8 @@ async function handleRequest(request: Request) { #### Recommended: Client Hook (Automatic) ```typescript -import { createSIWxClientHook } from '@x402/extensions/sign-in-with-x'; -import { x402HTTPClient } from '@x402/fetch'; +import { createSIWxClientHook } from '@bankofai/x402-extensions/sign-in-with-x'; +import { x402HTTPClient } from '@bankofai/x402-fetch'; // Configure client with SIWX hook - automatically tries SIWX auth before payment const httpClient = new x402HTTPClient(client) @@ -607,7 +607,7 @@ The client hook automatically: import { createSIWxPayload, encodeSIWxHeader, -} from '@x402/extensions/sign-in-with-x'; +} from '@bankofai/x402-extensions/sign-in-with-x'; // 1. Get extension and network from 402 response const paymentRequired = await response.json(); diff --git a/typescript/packages/http/axios/CHANGELOG.md b/typescript/packages/http/axios/CHANGELOG.md index 1de2ded1..ec41c164 100644 --- a/typescript/packages/http/axios/CHANGELOG.md +++ b/typescript/packages/http/axios/CHANGELOG.md @@ -1,11 +1,11 @@ -# @x402/axios Changelog +# @bankofai/x402-axios Changelog ## 2.6.0 ### Minor Changes - Updated dependencies - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -14,7 +14,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -23,19 +23,19 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/axios/README.md b/typescript/packages/http/axios/README.md index 6cd3b424..562675cc 100644 --- a/typescript/packages/http/axios/README.md +++ b/typescript/packages/http/axios/README.md @@ -5,26 +5,22 @@ A utility package that extends Axios to automatically handle 402 Payment Require ## Installation ```bash -pnpm install @x402/axios +pnpm install @bankofai/x402-axios ``` ## Quick Start ```typescript import axios from "axios"; -import { wrapAxiosWithPaymentFromConfig } from "@x402/axios"; -import { ExactEvmScheme } from "@x402/evm"; -import { privateKeyToAccount } from "viem/accounts"; - -// Create an account -const account = privateKeyToAccount("0xYourPrivateKey"); +import { wrapAxiosWithPaymentFromConfig } from "@bankofai/x402-axios"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/client"; // Wrap the axios instance with payment handling const api = wrapAxiosWithPaymentFromConfig(axios.create(), { schemes: [ { - network: "eip155:8453", // Base Mainnet - client: new ExactEvmScheme(account), + network: "tron:mainnet", // TRON Mainnet + client: new ExactTronScheme(tronSigner), }, ], }); @@ -75,9 +71,9 @@ A wrapped Axios instance that automatically handles 402 responses by: ```typescript import { config } from "dotenv"; import axios from "axios"; -import { wrapAxiosWithPaymentFromConfig, decodePaymentResponseHeader } from "@x402/axios"; +import { wrapAxiosWithPaymentFromConfig, decodePaymentResponseHeader } from "@bankofai/x402-axios"; import { privateKeyToAccount } from "viem/accounts"; -import { ExactEvmScheme } from "@x402/evm"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; config(); @@ -119,9 +115,9 @@ For more control, you can use the builder pattern to register multiple schemes: ```typescript import axios from "axios"; -import { wrapAxiosWithPayment, x402Client } from "@x402/axios"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; -import { ExactSvmScheme } from "@x402/svm/exact/client"; +import { wrapAxiosWithPayment, x402Client } from "@bankofai/x402-axios"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { ExactSvmScheme } from "@bankofai/x402-svm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; import { createKeyPairSignerFromBytes } from "@solana/kit"; import { base58 } from "@scure/base"; @@ -143,22 +139,22 @@ const api = wrapAxiosWithPayment(axios.create(), client); ```typescript import axios from "axios"; -import { wrapAxiosWithPaymentFromConfig } from "@x402/axios"; -import { ExactEvmScheme } from "@x402/evm"; -import { ExactSvmScheme } from "@x402/svm"; +import { wrapAxiosWithPaymentFromConfig } from "@bankofai/x402-axios"; +import { ExactTronScheme } from "@bankofai/x402-tron"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; const api = wrapAxiosWithPaymentFromConfig(axios.create(), { schemes: [ + // TRON chains + { + network: "tron:mainnet", // TRON Mainnet + client: new ExactTronScheme(tronSigner), + }, // EVM chains { network: "eip155:8453", // Base Mainnet client: new ExactEvmScheme(evmAccount), }, - // SVM chains - { - network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", // Solana devnet - client: new ExactSvmScheme(svmSigner), - }, ], }); ``` @@ -167,8 +163,8 @@ const api = wrapAxiosWithPaymentFromConfig(axios.create(), { ```typescript import axios from "axios"; -import { wrapAxiosWithPaymentFromConfig, type SelectPaymentRequirements } from "@x402/axios"; -import { ExactEvmScheme } from "@x402/evm"; +import { wrapAxiosWithPaymentFromConfig, type SelectPaymentRequirements } from "@bankofai/x402-axios"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; // Custom selector that prefers the cheapest option const selectCheapestOption: SelectPaymentRequirements = (version, accepts) => { diff --git a/typescript/packages/http/express/CHANGELOG.md b/typescript/packages/http/express/CHANGELOG.md index 155288ac..276b16e0 100644 --- a/typescript/packages/http/express/CHANGELOG.md +++ b/typescript/packages/http/express/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/express Changelog +# @bankofai/x402-express Changelog ## 2.6.0 @@ -12,8 +12,8 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 - - @x402/paywall@2.6.0 + - @bankofai/x402-core@2.6.0 + - @bankofai/x402-paywall@2.6.0 ## 2.5.0 @@ -24,9 +24,9 @@ - Updated dependencies [1ab1c86] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 - - @x402/extensions@2.5.0 - - @x402/paywall@2.4.1 + - @bankofai/x402-core@2.5.0 + - @bankofai/x402-extensions@2.5.0 + - @bankofai/x402-paywall@2.4.1 ## 2.4.0 @@ -35,15 +35,15 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 - - @x402/extensions@2.4.0 - - @x402/paywall@2.4.0 + - @bankofai/x402-core@2.4.0 + - @bankofai/x402-extensions@2.4.0 + - @bankofai/x402-paywall@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes @@ -52,9 +52,9 @@ - Updated dependencies [51b8445] - Updated dependencies [fe42994] - Updated dependencies [51b8445] - - @x402/core@2.3.0 - - @x402/paywall@2.3.0 - - @x402/extensions@2.3.0 + - @bankofai/x402-core@2.3.0 + - @bankofai/x402-paywall@2.3.0 + - @bankofai/x402-extensions@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/express/README.md b/typescript/packages/http/express/README.md index d9cba682..cef590b5 100644 --- a/typescript/packages/http/express/README.md +++ b/typescript/packages/http/express/README.md @@ -1,20 +1,54 @@ -# @x402/express +# @bankofai/x402-express Express middleware integration for the x402 Payment Protocol. This package provides a simple middleware function for adding x402 payment requirements to your Express.js applications. ## Installation ```bash -pnpm install @x402/express +pnpm install @bankofai/x402-express ``` ## Quick Start ```typescript import express from "express"; -import { paymentMiddleware, x402ResourceServer } from "@x402/express"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-express"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; + +const app = express(); + +const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.org" }); +const resourceServer = new x402ResourceServer(facilitatorClient) + .register("tron:mainnet", new ExactTronScheme()); + +// Apply the payment middleware with your configuration +app.use( + paymentMiddleware( + { + "GET /protected-route": { + accepts: { + scheme: "exact", + price: "$0.10", + network: "tron:mainnet", + payTo: "TYourTronAddress", + }, + description: "Access to premium content", + }, + }, + resourceServer, + ), +); +``` + + +## Quick Start + +```typescript +import express from "express"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-express"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; const app = express(); @@ -76,7 +110,7 @@ See the sections below for detailed configuration options. ### ExpressAdapter -The `ExpressAdapter` class implements the `HTTPAdapter` interface from `@x402/core`, providing Express-specific request handling: +The `ExpressAdapter` class implements the `HTTPAdapter` interface from `@bankofai/x402-core`, providing Express-specific request handling: ```typescript class ExpressAdapter implements HTTPAdapter { @@ -137,10 +171,10 @@ The middleware automatically displays a paywall UI when browsers request protect **Option 1: Full Paywall UI (Recommended)** -Install the optional `@x402/paywall` package for a complete wallet connection and payment UI: +Install the optional `@bankofai/x402-paywall` package for a complete wallet connection and payment UI: ```bash -pnpm add @x402/paywall +pnpm add @bankofai/x402-paywall ``` Then configure it: @@ -165,7 +199,7 @@ The paywall includes: **Option 2: Basic Paywall (No Installation)** -Without `@x402/paywall` installed, the middleware returns a basic HTML page with payment instructions. This works but doesn't include wallet connections. +Without `@bankofai/x402-paywall` installed, the middleware returns a basic HTML page with payment instructions. This works but doesn't include wallet connections. **Option 3: Custom Paywall Provider** @@ -177,7 +211,7 @@ app.use(paymentMiddleware(routes, resourceServer, paywallConfig, customPaywallPr This allows full customization of the paywall UI. -**For advanced configuration** (builder pattern, network-specific bundles, custom handlers), see the [@x402/paywall README](../paywall/README.md). +**For advanced configuration** (builder pattern, network-specific bundles, custom handlers), see the [@bankofai/x402-paywall README](../paywall/README.md). ## Advanced Usage @@ -217,9 +251,9 @@ app.use( If you need to use a custom facilitator server, configure it when creating the x402ResourceServer: ```typescript -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { x402ResourceServer } from "@x402/express"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { x402ResourceServer } from "@bankofai/x402-express"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const customFacilitator = new HTTPFacilitatorClient({ url: "https://your-facilitator.com", @@ -239,7 +273,7 @@ app.use(paymentMiddleware(routes, resourceServer, paywallConfig)); If you're migrating from the legacy `x402-express` package: -1. **Update imports**: Change from `x402-express` to `@x402/express` +1. **Update imports**: Change from `x402-express` to `@bankofai/x402-express` 2. **New API**: Create an x402ResourceServer and register payment schemes 3. **Parameter order**: Routes first, then resource server, then optional paywall config @@ -258,12 +292,12 @@ app.use( ); ``` -### After (@x402/express): +### After (@bankofai/x402-express): ```typescript -import { paymentMiddleware, x402ResourceServer } from "@x402/express"; -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-express"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const facilitator = new HTTPFacilitatorClient({ url: facilitatorUrl }); const resourceServer = new x402ResourceServer(facilitator) diff --git a/typescript/packages/http/fetch/CHANGELOG.md b/typescript/packages/http/fetch/CHANGELOG.md index 4e530af0..0dfde8b8 100644 --- a/typescript/packages/http/fetch/CHANGELOG.md +++ b/typescript/packages/http/fetch/CHANGELOG.md @@ -1,11 +1,11 @@ -# @x402/fetch Changelog +# @bankofai/x402-fetch Changelog ## 2.6.0 ### Minor Changes - Updated dependencies - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -14,7 +14,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -23,19 +23,19 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/fetch/README.md b/typescript/packages/http/fetch/README.md index d78819a2..2d31492d 100644 --- a/typescript/packages/http/fetch/README.md +++ b/typescript/packages/http/fetch/README.md @@ -5,25 +5,21 @@ A utility package that extends the native `fetch` API to automatically handle 40 ## Installation ```bash -pnpm install @x402/fetch +pnpm install @bankofai/x402-fetch ``` ## Quick Start ```typescript -import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm"; -import { privateKeyToAccount } from "viem/accounts"; - -// Create an account -const account = privateKeyToAccount("0xYourPrivateKey"); +import { wrapFetchWithPaymentFromConfig } from "@bankofai/x402-fetch"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/client"; // Wrap the fetch function with payment handling const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, { schemes: [ { - network: "eip155:8453", // Base Mainnet - client: new ExactEvmScheme(account), + network: "tron:mainnet", // TRON Mainnet + client: new ExactTronScheme(tronSigner), }, ], }); @@ -75,9 +71,9 @@ A wrapped fetch function that automatically handles 402 responses by: ```typescript import { config } from "dotenv"; -import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from "@x402/fetch"; +import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from "@bankofai/x402-fetch"; import { privateKeyToAccount } from "viem/accounts"; -import { ExactEvmScheme } from "@x402/evm"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; config(); @@ -120,9 +116,9 @@ fetchWithPayment(API_URL, { For more control, you can use the builder pattern to register multiple schemes: ```typescript -import { wrapFetchWithPayment, x402Client } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm/exact/client"; -import { ExactSvmScheme } from "@x402/svm/exact/client"; +import { wrapFetchWithPayment, x402Client } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; +import { ExactSvmScheme } from "@bankofai/x402-svm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; import { createKeyPairSignerFromBytes } from "@solana/kit"; import { base58 } from "@scure/base"; @@ -143,22 +139,22 @@ const fetchWithPayment = wrapFetchWithPayment(fetch, client); ### Multi-Chain Support ```typescript -import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm"; -import { ExactSvmScheme } from "@x402/svm"; +import { wrapFetchWithPaymentFromConfig } from "@bankofai/x402-fetch"; +import { ExactTronScheme } from "@bankofai/x402-tron"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, { schemes: [ + // TRON chains + { + network: "tron:mainnet", // TRON Mainnet + client: new ExactTronScheme(tronSigner), + }, // EVM chains { network: "eip155:8453", // Base Sepolia client: new ExactEvmScheme(evmAccount), }, - // SVM chains - { - network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", // Solana devnet - client: new ExactSvmScheme(svmSigner), - }, ], }); ``` @@ -166,8 +162,8 @@ const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, { ### Custom Payment Requirements Selector ```typescript -import { wrapFetchWithPaymentFromConfig, type SelectPaymentRequirements } from "@x402/fetch"; -import { ExactEvmScheme } from "@x402/evm"; +import { wrapFetchWithPaymentFromConfig, type SelectPaymentRequirements } from "@bankofai/x402-fetch"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; // Custom selector that prefers the cheapest option const selectCheapestOption: SelectPaymentRequirements = (version, accepts) => { diff --git a/typescript/packages/http/hono/CHANGELOG.md b/typescript/packages/http/hono/CHANGELOG.md index cb438329..f68071b6 100644 --- a/typescript/packages/http/hono/CHANGELOG.md +++ b/typescript/packages/http/hono/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/hono Changelog +# @bankofai/x402-hono Changelog ## 2.6.0 @@ -11,8 +11,8 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 - - @x402/paywall@2.6.0 + - @bankofai/x402-core@2.6.0 + - @bankofai/x402-paywall@2.6.0 ## 2.5.0 @@ -23,9 +23,9 @@ - Updated dependencies [1ab1c86] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 - - @x402/extensions@2.5.0 - - @x402/paywall@2.4.1 + - @bankofai/x402-core@2.5.0 + - @bankofai/x402-extensions@2.5.0 + - @bankofai/x402-paywall@2.4.1 ## 2.4.0 @@ -34,15 +34,15 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 - - @x402/extensions@2.4.0 - - @x402/paywall@2.4.0 + - @bankofai/x402-core@2.4.0 + - @bankofai/x402-extensions@2.4.0 + - @bankofai/x402-paywall@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes @@ -51,9 +51,9 @@ - Updated dependencies [51b8445] - Updated dependencies [fe42994] - Updated dependencies [51b8445] - - @x402/core@2.3.0 - - @x402/paywall@2.3.0 - - @x402/extensions@2.3.0 + - @bankofai/x402-core@2.3.0 + - @bankofai/x402-paywall@2.3.0 + - @bankofai/x402-extensions@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/hono/README.md b/typescript/packages/http/hono/README.md index b9776b42..cfb7c5d7 100644 --- a/typescript/packages/http/hono/README.md +++ b/typescript/packages/http/hono/README.md @@ -1,11 +1,11 @@ -# @x402/hono +# @bankofai/x402-hono Hono middleware integration for the x402 Payment Protocol. This package provides a simple middleware function for adding x402 payment requirements to your Hono applications. ## Installation ```bash -pnpm install @x402/hono +pnpm install @bankofai/x402-hono ``` ## Quick Start @@ -13,15 +13,15 @@ pnpm install @x402/hono ```typescript import { Hono } from "hono"; import { serve } from "@hono/node-server"; -import { paymentMiddleware, x402ResourceServer } from "@x402/hono"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; -import { HTTPFacilitatorClient } from "@x402/core/server"; +import { paymentMiddleware, x402ResourceServer } from "@bankofai/x402-hono"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; const app = new Hono(); const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.org" }); const resourceServer = new x402ResourceServer(facilitatorClient) - .register("eip155:84532", new ExactEvmScheme()); + .register("tron:mainnet", new ExactTronScheme()); // Apply the payment middleware with your configuration app.use( @@ -31,8 +31,8 @@ app.use( accepts: { scheme: "exact", price: "$0.10", - network: "eip155:84532", - payTo: "0xYourAddress", + network: "tron:mainnet", + payTo: "TYourTronAddress", }, description: "Access to premium content", }, @@ -75,7 +75,7 @@ paymentMiddleware( ### HonoAdapter -The `HonoAdapter` class implements the `HTTPAdapter` interface from `@x402/core`, providing Hono-specific request handling: +The `HonoAdapter` class implements the `HTTPAdapter` interface from `@bankofai/x402-core`, providing Hono-specific request handling: ```typescript class HonoAdapter implements HTTPAdapter { @@ -136,10 +136,10 @@ The middleware automatically displays a paywall UI when browsers request protect **Option 1: Full Paywall UI (Recommended)** -Install the optional `@x402/paywall` package for a complete wallet connection and payment UI: +Install the optional `@bankofai/x402-paywall` package for a complete wallet connection and payment UI: ```bash -pnpm add @x402/paywall +pnpm add @bankofai/x402-paywall ``` Then configure it: @@ -156,7 +156,7 @@ app.use(paymentMiddleware(routes, resourceServer, paywallConfig)); **Option 2: Basic Paywall (No Installation)** -Without `@x402/paywall` installed, the middleware returns a basic HTML page with payment instructions. +Without `@bankofai/x402-paywall` installed, the middleware returns a basic HTML page with payment instructions. **Option 3: Custom Paywall Provider** @@ -236,9 +236,9 @@ app.use( If you need to use a custom facilitator server, configure it when creating the x402ResourceServer: ```typescript -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { x402ResourceServer } from "@x402/hono"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { x402ResourceServer } from "@bankofai/x402-hono"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const customFacilitator = new HTTPFacilitatorClient({ url: "https://your-facilitator.com", diff --git a/typescript/packages/http/next/CHANGELOG.md b/typescript/packages/http/next/CHANGELOG.md index 6738d218..74d835b6 100644 --- a/typescript/packages/http/next/CHANGELOG.md +++ b/typescript/packages/http/next/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/next Changelog +# @bankofai/x402-next Changelog ## 2.6.0 @@ -12,8 +12,8 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 - - @x402/paywall@2.6.0 + - @bankofai/x402-core@2.6.0 + - @bankofai/x402-paywall@2.6.0 ## 2.5.0 @@ -24,9 +24,9 @@ - Updated dependencies [1ab1c86] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 - - @x402/extensions@2.5.0 - - @x402/paywall@2.4.1 + - @bankofai/x402-core@2.5.0 + - @bankofai/x402-extensions@2.5.0 + - @bankofai/x402-paywall@2.4.1 ## 2.4.0 @@ -35,15 +35,15 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 - - @x402/extensions@2.4.0 - - @x402/paywall@2.4.0 + - @bankofai/x402-core@2.4.0 + - @bankofai/x402-extensions@2.4.0 + - @bankofai/x402-paywall@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes @@ -52,9 +52,9 @@ - Updated dependencies [51b8445] - Updated dependencies [fe42994] - Updated dependencies [51b8445] - - @x402/core@2.3.0 - - @x402/paywall@2.3.0 - - @x402/extensions@2.3.0 + - @bankofai/x402-core@2.3.0 + - @bankofai/x402-paywall@2.3.0 + - @bankofai/x402-extensions@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/next/README.md b/typescript/packages/http/next/README.md index db135277..ccfa0af6 100644 --- a/typescript/packages/http/next/README.md +++ b/typescript/packages/http/next/README.md @@ -1,11 +1,11 @@ -# @x402/next +# @bankofai/x402-next Next.js integration for the x402 Payment Protocol. This package allows you to easily add paywall functionality to your Next.js applications using the x402 protocol. ## Installation ```bash -pnpm install @x402/next +pnpm install @bankofai/x402-next ``` ## Quick Start @@ -15,13 +15,13 @@ pnpm install @x402/next Page routes are protected using the `paymentProxy`. Create a proxy (middleware) file in your Next.js project (`proxy.ts`): ```typescript -import { paymentProxy, x402ResourceServer } from "@x402/next"; -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { paymentProxy, x402ResourceServer } from "@bankofai/x402-next"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/server"; const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.org" }); const resourceServer = new x402ResourceServer(facilitatorClient) - .register("eip155:84532", new ExactEvmScheme()); + .register("tron:mainnet", new ExactTronScheme()); export const proxy = paymentProxy( { @@ -29,8 +29,8 @@ export const proxy = paymentProxy( accepts: { scheme: "exact", price: "$0.01", - network: "eip155:84532", - payTo: "0xYourAddress", + network: "tron:mainnet", + payTo: "TYourTronAddress", }, description: "Access to protected content", }, @@ -51,7 +51,7 @@ API routes are protected using the `withX402` route wrapper. This is the recomme ```typescript // app/api/your-endpoint/route.ts import { NextRequest, NextResponse } from "next/server"; -import { withX402 } from "@x402/next"; +import { withX402 } from "@bankofai/x402-next"; const handler = async (_: NextRequest) => { return NextResponse.json({ data: "your response" }); @@ -124,7 +124,7 @@ withX402( ### NextAdapter -The `NextAdapter` class implements the `HTTPAdapter` interface from `@x402/core`, providing Next.js-specific request handling: +The `NextAdapter` class implements the `HTTPAdapter` interface from `@bankofai/x402-core`, providing Next.js-specific request handling: ```typescript class NextAdapter implements HTTPAdapter { @@ -159,16 +159,16 @@ const routes: RoutesConfig = { ### Multiple Payment Networks ```typescript -import { paymentProxy, x402ResourceServer } from "@x402/next"; -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { registerExactEvmScheme } from "@x402/evm/exact/server"; -import { registerExactSvmScheme } from "@x402/svm/exact/server"; +import { paymentProxy, x402ResourceServer } from "@bankofai/x402-next"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { registerExactTronScheme } from "@bankofai/x402-tron/exact/server"; +import { registerExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl }); const server = new x402ResourceServer(facilitatorClient); +registerExactTronScheme(server); registerExactEvmScheme(server); -registerExactSvmScheme(server); export const middleware = paymentProxy( { @@ -177,14 +177,14 @@ export const middleware = paymentProxy( { scheme: "exact", price: "$0.001", - network: "eip155:84532", - payTo: evmAddress, + network: "tron:mainnet", + payTo: tronAddress, }, { scheme: "exact", price: "$0.001", - network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", - payTo: svmAddress, + network: "eip155:84532", + payTo: evmAddress, }, ], description: "Premium content", @@ -198,9 +198,9 @@ export const middleware = paymentProxy( ### Custom Paywall ```typescript -import { createPaywall } from "@x402/paywall"; -import { evmPaywall } from "@x402/paywall/evm"; -import { svmPaywall } from "@x402/paywall/svm"; +import { createPaywall } from "@bankofai/x402-paywall"; +import { evmPaywall } from "@bankofai/x402-paywall/evm"; +import { svmPaywall } from "@bankofai/x402-paywall/svm"; const paywall = createPaywall() .withNetwork(evmPaywall) @@ -223,7 +223,7 @@ export const middleware = paymentProxy( If you're migrating from the legacy `x402-next` package: -1. **Update imports**: Change from `x402-next` to `@x402/next` +1. **Update imports**: Change from `x402-next` to `@bankofai/x402-next` 2. **New API**: Create an x402ResourceServer and register payment schemes 3. **Function rename**: `paymentMiddleware` is now `paymentProxy` 4. **Parameter order**: Routes first, then resource server @@ -247,12 +247,12 @@ export const middleware = paymentMiddleware( ); ``` -### After (@x402/next): +### After (@bankofai/x402-next): ```typescript -import { paymentProxy, x402ResourceServer } from "@x402/next"; -import { HTTPFacilitatorClient } from "@x402/core/server"; -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { paymentProxy, x402ResourceServer } from "@bankofai/x402-next"; +import { HTTPFacilitatorClient } from "@bankofai/x402-core/server"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const facilitator = new HTTPFacilitatorClient({ url: facilitatorUrl }); const resourceServer = new x402ResourceServer(facilitator) diff --git a/typescript/packages/http/paywall/CHANGELOG.md b/typescript/packages/http/paywall/CHANGELOG.md index 6d73bf3e..d8593bb5 100644 --- a/typescript/packages/http/paywall/CHANGELOG.md +++ b/typescript/packages/http/paywall/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/paywall Changelog +# @bankofai/x402-paywall Changelog ## 2.6.0 @@ -10,7 +10,7 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -19,7 +19,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -28,19 +28,19 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 ### Patch Changes - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/http/paywall/README.md b/typescript/packages/http/paywall/README.md index caafbcc8..0ae40b2b 100644 --- a/typescript/packages/http/paywall/README.md +++ b/typescript/packages/http/paywall/README.md @@ -1,4 +1,4 @@ -# @x402/paywall +# @bankofai/x402-paywall Modular paywall UI for the x402 payment protocol with support for EVM and Solana networks. @@ -14,7 +14,7 @@ Modular paywall UI for the x402 payment protocol with support for EVM and Solana ## Installation ```bash -pnpm add @x402/paywall +pnpm add @bankofai/x402-paywall ``` ## Bundle Sizes @@ -23,17 +23,17 @@ Choose the import that matches your needs: | Import | Size | Networks | Use Case | |--------|------|----------|----------| -| `@x402/paywall` | 3.5MB | EVM + Solana | Multi-network apps | -| `@x402/paywall/evm` | 3.4MB | EVM only | Base, Ethereum, Polygon, etc. | -| `@x402/paywall/svm` | 1.0MB | Solana only | Solana apps | +| `@bankofai/x402-paywall` | 3.5MB | EVM + Solana | Multi-network apps | +| `@bankofai/x402-paywall/evm` | 3.4MB | EVM only | Base, Ethereum, Polygon, etc. | +| `@bankofai/x402-paywall/svm` | 1.0MB | Solana only | Solana apps | ## Usage ### Option 1: EVM Only ```typescript -import { createPaywall } from '@x402/paywall'; -import { evmPaywall } from '@x402/paywall/evm'; +import { createPaywall } from '@bankofai/x402-paywall'; +import { evmPaywall } from '@bankofai/x402-paywall/evm'; const paywall = createPaywall() .withNetwork(evmPaywall) @@ -50,8 +50,8 @@ app.use(paymentMiddleware(routes, facilitators, schemes, undefined, paywall)); ### Option 2: Solana Only ```typescript -import { createPaywall } from '@x402/paywall'; -import { svmPaywall } from '@x402/paywall/svm'; +import { createPaywall } from '@bankofai/x402-paywall'; +import { svmPaywall } from '@bankofai/x402-paywall/svm'; const paywall = createPaywall() .withNetwork(svmPaywall) @@ -65,9 +65,9 @@ const paywall = createPaywall() ### Option 3: Multi-Network ```typescript -import { createPaywall } from '@x402/paywall'; -import { evmPaywall } from '@x402/paywall/evm'; -import { svmPaywall } from '@x402/paywall/svm'; +import { createPaywall } from '@bankofai/x402-paywall'; +import { evmPaywall } from '@bankofai/x402-paywall/evm'; +import { svmPaywall } from '@bankofai/x402-paywall/svm'; const paywall = createPaywall() .withNetwork(evmPaywall) // First-match priority @@ -133,9 +133,9 @@ const paywall = createPaywall() ```typescript import express from 'express'; -import { paymentMiddleware } from '@x402/express'; -import { createPaywall } from '@x402/paywall'; -import { evmPaywall } from '@x402/paywall/evm'; +import { paymentMiddleware } from '@bankofai/x402-express'; +import { createPaywall } from '@bankofai/x402-paywall'; +import { evmPaywall } from '@bankofai/x402-paywall/evm'; const app = express(); @@ -155,12 +155,12 @@ app.use(paymentMiddleware( ### Automatic Detection -If you provide `paywallConfig` without a custom paywall, `@x402/core` automatically: -1. Tries to load `@x402/paywall` if installed +If you provide `paywallConfig` without a custom paywall, `@bankofai/x402-core` automatically: +1. Tries to load `@bankofai/x402-paywall` if installed 2. Falls back to basic HTML if not installed ```typescript -// Simple usage - auto-detects @x402/paywall +// Simple usage - auto-detects @bankofai/x402-paywall app.use(paymentMiddleware(routes, facilitators, schemes, { appName: 'My App', testnet: true @@ -172,7 +172,7 @@ app.use(paymentMiddleware(routes, facilitators, schemes, { You can create custom handlers for new networks: ```typescript -import { createPaywall, type PaywallNetworkHandler } from '@x402/paywall'; +import { createPaywall, type PaywallNetworkHandler } from '@bankofai/x402-paywall'; const suiPaywall: PaywallNetworkHandler = { supports: (req) => req.network.startsWith('sui:'), diff --git a/typescript/packages/mcp/CHANGELOG.md b/typescript/packages/mcp/CHANGELOG.md index b09aeabd..b6249e97 100644 --- a/typescript/packages/mcp/CHANGELOG.md +++ b/typescript/packages/mcp/CHANGELOG.md @@ -5,7 +5,7 @@ ### Minor Changes - Updated dependencies - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -14,7 +14,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -23,7 +23,7 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.0 @@ -31,7 +31,7 @@ - 9ec9f15: Fixed select payment requirements - Updated dependencies [9ec9f15] - - @x402/core@2.3.1 + - @bankofai/x402-core@2.3.1 ## 2.3.0-alpha diff --git a/typescript/packages/mcp/README.md b/typescript/packages/mcp/README.md index 32c286ee..f6de5943 100644 --- a/typescript/packages/mcp/README.md +++ b/typescript/packages/mcp/README.md @@ -109,14 +109,14 @@ const mcpServer = new McpServer({ name: "premium-api", version: "1.0.0" }); // Set up x402 for payment handling const facilitatorClient = new HTTPFacilitatorClient({ url: "https://x402.org/facilitator" }); const resourceServer = new x402ResourceServer(facilitatorClient); -resourceServer.register("eip155:84532", new ExactEvmScheme()); +resourceServer.register("tron:mainnet", new ExactTronScheme()); await resourceServer.initialize(); // Build payment requirements const accepts = await resourceServer.buildPaymentRequirements({ scheme: "exact", - network: "eip155:84532", - payTo: "0x...", + network: "tron:mainnet", + payTo: "TYourTronAddress", price: "$0.10", }); @@ -148,6 +148,7 @@ await mcpServer.connect(transport); ```typescript import { createx402MCPClient } from "@bankofai/x402-mcp"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/client"; import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; @@ -155,26 +156,19 @@ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; const client = createx402MCPClient({ name: "my-agent", version: "1.0.0", - schemes: [{ network: "eip155:84532", client: new ExactEvmScheme(walletAccount) }], + schemes: [ + { network: "tron:mainnet", client: new ExactTronScheme(tronSigner) }, + { network: "eip155:84532", client: new ExactEvmScheme(evmAccount) } + ], autoPayment: true, onPaymentRequested: async ({ paymentRequired }) => { console.log(`Tool requires payment: ${paymentRequired.accepts[0].amount}`); return true; // Return false to deny payment }, }); - -// Connect and use -const transport = new SSEClientTransport(new URL("http://localhost:4022/sse")); -await client.connect(transport); - -const result = await client.callTool("financial_analysis", { ticker: "AAPL" }); -console.log(result.content); - -if (result.paymentMade) { - console.log("Payment settled:", result.paymentResponse?.transaction); -} ``` + ## Advanced Features ### Production Hooks @@ -277,7 +271,8 @@ import { ExactEvmScheme } from "@bankofai/x402-evm/exact/client"; // Option 1: Wrap existing client with existing payment client const mcpClient = new Client({ name: "my-agent", version: "1.0.0" }); const paymentClient = new x402Client() - .register("eip155:84532", new ExactEvmScheme(walletAccount)); + .register("tron:mainnet", new ExactTronScheme(tronSigner)) + .register("eip155:84532", new ExactEvmScheme(evmAccount)); const x402Mcp = wrapMCPClientWithPayment(mcpClient, paymentClient, { autoPayment: true, @@ -285,7 +280,10 @@ const x402Mcp = wrapMCPClientWithPayment(mcpClient, paymentClient, { // Option 2: Wrap existing client with config const x402Mcp2 = wrapMCPClientWithPaymentFromConfig(mcpClient, { - schemes: [{ network: "eip155:84532", client: new ExactEvmScheme(walletAccount) }], + schemes: [ + { network: "tron:mainnet", client: new ExactTronScheme(tronSigner) }, + { network: "eip155:84532", client: new ExactEvmScheme(evmAccount) } + ], }); ``` diff --git a/typescript/packages/mechanisms/aptos/CHANGELOG.md b/typescript/packages/mechanisms/aptos/CHANGELOG.md index 19521f2f..fc7965bf 100644 --- a/typescript/packages/mechanisms/aptos/CHANGELOG.md +++ b/typescript/packages/mechanisms/aptos/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/aptos +# @bankofai/x402-aptos ## 2.6.0 @@ -9,7 +9,7 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -18,7 +18,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -26,7 +26,7 @@ - 57a5488: Add Aptos blockchain support to x402 payment protocol - - Introduces new `@x402/aptos` package with full client, server, and facilitator scheme implementations + - Introduces new `@bankofai/x402-aptos` package with full client, server, and facilitator scheme implementations - Supports exact payment mechanism for Aptos using native APT and fungible assets - Includes sponsored transaction support where facilitator pays gas fees - Provides `registerExactAptosScheme` helpers for easy client and server integration @@ -38,4 +38,4 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 diff --git a/typescript/packages/mechanisms/aptos/README.md b/typescript/packages/mechanisms/aptos/README.md index c8ed6269..e7163848 100644 --- a/typescript/packages/mechanisms/aptos/README.md +++ b/typescript/packages/mechanisms/aptos/README.md @@ -1,13 +1,13 @@ -# @x402/aptos +# @bankofai/x402-aptos Aptos implementation of the x402 payment protocol. ## Installation ```bash -npm install @x402/aptos +npm install @bankofai/x402-aptos # or -pnpm add @x402/aptos +pnpm add @bankofai/x402-aptos ``` ## Usage @@ -16,7 +16,7 @@ pnpm add @x402/aptos ```typescript import { Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk"; -import { ExactAptosScheme } from "@x402/aptos/exact/client"; +import { ExactAptosScheme } from "@bankofai/x402-aptos/exact/client"; // Create signer from private key const privateKey = new Ed25519PrivateKey("0x..."); @@ -30,8 +30,8 @@ client.register("aptos:*", new ExactAptosScheme(account)); ```typescript import { Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk"; -import { ExactAptosScheme } from "@x402/aptos/exact/facilitator"; -import { toFacilitatorAptosSigner } from "@x402/aptos"; +import { ExactAptosScheme } from "@bankofai/x402-aptos/exact/facilitator"; +import { toFacilitatorAptosSigner } from "@bankofai/x402-aptos"; // Create facilitator signer const privateKey = new Ed25519PrivateKey("0x..."); @@ -45,8 +45,8 @@ facilitator.register("aptos:2", new ExactAptosScheme(signer)); ### Server ```typescript -import { x402ResourceServer } from "@x402/core/server"; -import { ExactAptosScheme } from "@x402/aptos/exact/server"; +import { x402ResourceServer } from "@bankofai/x402-core/server"; +import { ExactAptosScheme } from "@bankofai/x402-aptos/exact/server"; // Create and configure server const server = new x402ResourceServer({ facilitatorUrl: "https://..." }); diff --git a/typescript/packages/mechanisms/evm/CHANGELOG.md b/typescript/packages/mechanisms/evm/CHANGELOG.md index 310ccccd..75292afd 100644 --- a/typescript/packages/mechanisms/evm/CHANGELOG.md +++ b/typescript/packages/mechanisms/evm/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/evm Changelog +# @bankofai/x402-evm Changelog ## 2.6.0 @@ -10,7 +10,7 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -27,8 +27,8 @@ - Updated dependencies [1ab1c86] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 - - @x402/extensions@2.5.0 + - @bankofai/x402-core@2.5.0 + - @bankofai/x402-extensions@2.5.0 ## 2.4.0 @@ -43,8 +43,8 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 - - @x402/extensions@2.4.0 + - @bankofai/x402-core@2.4.0 + - @bankofai/x402-extensions@2.4.0 ## 2.3.1 @@ -52,13 +52,13 @@ - 0c6064d: Add MegaETH mainnet (chain ID 4326) support with USDM as the default stablecoin - Updated dependencies [9ec9f15] - - @x402/core@2.3.1 + - @bankofai/x402-core@2.3.1 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 - 51b8445: Upgraded exact evm to support permit2 payments ### Patch Changes @@ -66,7 +66,7 @@ - adb1b55: Improved error messages for insufficient funds. The `invalidMessage` field now includes the required amount, available balance, asset denomination, and actionable guidance when payment fails due to insufficient funds. - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/mechanisms/evm/README.md b/typescript/packages/mechanisms/evm/README.md index 9eb90f73..97274da5 100644 --- a/typescript/packages/mechanisms/evm/README.md +++ b/typescript/packages/mechanisms/evm/README.md @@ -1,11 +1,11 @@ -# @x402/evm +# @bankofai/x402-evm EVM (Ethereum Virtual Machine) implementation of the x402 payment protocol using the **Exact** payment scheme with EIP-3009 TransferWithAuthorization. ## Installation ```bash -npm install @x402/evm +npm install @bankofai/x402-evm ``` ## Overview @@ -18,30 +18,30 @@ This package provides three main components for handling x402 payments on EVM-co ## Package Exports -### Main Package (`@x402/evm`) +### Main Package (`@bankofai/x402-evm`) **V2 Protocol Support** - Modern x402 protocol with CAIP-2 network identifiers **Client:** -- `ExactEvmClient` - V2 client implementation using EIP-3009 +- `ExactEvmScheme` - V2 client implementation using EIP-3009 and Permit2 - `toClientEvmSigner(account)` - Converts viem accounts to x402 signers - `ClientEvmSigner` - TypeScript type for client signers **Facilitator:** -- `ExactEvmFacilitator` - V2 facilitator for payment verification and settlement +- `ExactEvmFacilitatorScheme` - V2 facilitator for payment verification and settlement - `toFacilitatorEvmSigner(wallet)` - Converts viem wallets to facilitator signers - `FacilitatorEvmSigner` - TypeScript type for facilitator signers **Service:** -- `ExactEvmServer` - V2 service for building payment requirements +- `ExactEvmServerScheme` - V2 service for building payment requirements -### V1 Package (`@x402/evm/v1`) +### V1 Package (`@bankofai/x402-evm/v1`) **V1 Protocol Support** - Legacy x402 protocol with simple network names **Exports:** -- `ExactEvmClientV1` - V1 client implementation -- `ExactEvmFacilitatorV1` - V1 facilitator implementation +- `ExactEvmSchemeV1` - V1 client implementation +- `ExactEvmSchemeV1Facilitator` - V1 facilitator implementation - `NETWORKS` - Array of all supported V1 network names **Supported V1 Networks:** @@ -57,7 +57,7 @@ This package provides three main components for handling x402 payments on EVM-co ] ``` -### Client Builder (`@x402/evm/client`) +### Client Builder (`@bankofai/x402-evm/client`) **Convenience builder** for creating fully-configured EVM clients @@ -73,8 +73,8 @@ This package provides three main components for handling x402 payments on EVM-co **Example:** ```typescript -import { createEvmClient } from "@x402/evm/client"; -import { toClientEvmSigner } from "@x402/evm"; +import { createEvmClient } from "@bankofai/x402-evm/client"; +import { toClientEvmSigner } from "@bankofai/x402-evm"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0x..."); @@ -105,8 +105,8 @@ const client = createEvmClient({ signer }); ### 1. Using Pre-built Builder (Recommended) ```typescript -import { createEvmClient } from "@x402/evm/client"; -import { wrapFetchWithPayment } from "@x402/fetch"; +import { createEvmClient } from "@bankofai/x402-evm/client"; +import { wrapFetchWithPayment } from "@bankofai/x402-fetch"; const client = createEvmClient({ signer: myEvmSigner }); const paidFetch = wrapFetchWithPayment(fetch, client); @@ -115,26 +115,27 @@ const paidFetch = wrapFetchWithPayment(fetch, client); ### 2. Direct Registration (Full Control) ```typescript -import { x402Client } from "@x402/core/client"; -import { ExactEvmClient } from "@x402/evm"; -import { ExactEvmClientV1 } from "@x402/evm/v1"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; +import { ExactEvmSchemeV1 } from "@bankofai/x402-evm/v1"; const client = new x402Client() - .register("eip155:*", new ExactEvmClient(signer)) - .registerSchemeV1("base-sepolia", new ExactEvmClientV1(signer)) - .registerSchemeV1("base", new ExactEvmClientV1(signer)); + .register("eip155:*", new ExactEvmScheme(signer)) + .registerSchemeV1("base-sepolia", new ExactEvmSchemeV1(signer)) + .registerSchemeV1("base", new ExactEvmSchemeV1(signer)); ``` ### 3. Using Config (Flexible) ```typescript -import { x402Client } from "@x402/core/client"; -import { ExactEvmClient } from "@x402/evm"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactEvmScheme } from "@bankofai/x402-evm"; +import { ExactEvmSchemeV1 } from "@bankofai/x402-evm/v1"; const client = x402Client.fromConfig({ schemes: [ - { network: "eip155:*", client: new ExactEvmClient(signer) }, - { network: "base-sepolia", client: new ExactEvmClientV1(signer), x402Version: 1 } + { network: "eip155:*", client: new ExactEvmScheme(signer) }, + { network: "base-sepolia", client: new ExactEvmSchemeV1(signer), x402Version: 1 } ], policies: [myCustomPolicy] }); @@ -150,7 +151,7 @@ const client = x402Client.fromConfig({ - Any `eip155:` network **V1 Networks** (simple names): -See `NETWORKS` constant in `@x402/evm/v1` +See `NETWORKS` constant in `@bankofai/x402-evm/v1` ## Asset Support @@ -178,7 +179,7 @@ npm run format ## Related Packages -- `@x402/core` - Core protocol types and client -- `@x402/fetch` - HTTP wrapper with automatic payment handling -- `@x402/svm` - Solana/SVM implementation -- `@x402/stellar` - Stellar implementation +- `@bankofai/x402-core` - Core protocol types and client +- `@bankofai/x402-fetch` - HTTP wrapper with automatic payment handling +- `@bankofai/x402-svm` - Solana/SVM implementation +- `@bankofai/x402-stellar` - Stellar implementation diff --git a/typescript/packages/mechanisms/evm/TODO.md b/typescript/packages/mechanisms/evm/TODO.md index 3f7b0867..533f15a4 100644 --- a/typescript/packages/mechanisms/evm/TODO.md +++ b/typescript/packages/mechanisms/evm/TODO.md @@ -1,8 +1,8 @@ -# @x402/evm +# @bankofai/x402-evm ## Overview -The `@x402/evm` package provides EVM blockchain implementations for x402 payment schemes. It serves as the **reference implementation** for how mechanism packages should be structured, providing scheme clients, facilitators, and resource servers for EVM-compatible chains. +The `@bankofai/x402-evm` package provides EVM blockchain implementations for x402 payment schemes. It serves as the **reference implementation** for how mechanism packages should be structured, providing scheme clients, facilitators, and resource servers for EVM-compatible chains. ## Current Implementation Status @@ -60,15 +60,15 @@ Before implementing these expansions: 2. **Follow the Reference Pattern** - Review how the exact scheme is implemented - Maintain consistency with the three-class export pattern - - Ensure compatibility with `@x402/core` abstractions + - Ensure compatibility with `@bankofai/x402-core` abstractions 3. **Testing Requirements** - Unit tests for all new functionality - - Integration tests with `@x402/core` + - Integration tests with `@bankofai/x402-core` - E2E test implementation in `/e2e` ## Technical Notes - This package serves as the reference for other mechanism implementations (Solana, etc.) -- All exports should extend the base classes from `@x402/core/types` +- All exports should extend the base classes from `@bankofai/x402-core/types` - Maintain support for both x402 v1 and v2 protocols where applicable \ No newline at end of file diff --git a/typescript/packages/mechanisms/evm/src/exact/server/DEFAULT_ASSET.md b/typescript/packages/mechanisms/evm/src/exact/server/DEFAULT_ASSET.md index e85fff8f..ab794337 100644 --- a/typescript/packages/mechanisms/evm/src/exact/server/DEFAULT_ASSET.md +++ b/typescript/packages/mechanisms/evm/src/exact/server/DEFAULT_ASSET.md @@ -58,7 +58,7 @@ If no `assetTransferMethod` is specified, the client defaults to **EIP-3009**. T For tokens that don't support EIP-3009 and aren't in the default config, use the `registerMoneyParser` method to specify Permit2: ```typescript -import { ExactEvmScheme } from "@x402/evm/exact/server"; +import { ExactEvmScheme } from "@bankofai/x402-evm/exact/server"; const server = new ExactEvmScheme(); @@ -107,8 +107,8 @@ When a server specifies `assetTransferMethod: "permit2"`, clients must: 1. **One-time approval**: Approve the Permit2 contract to spend their tokens ```typescript - // Using @x402/evm helpers - import { createPermit2ApprovalTx, PERMIT2_ADDRESS } from "@x402/evm"; + // Using @bankofai/x402-evm helpers + import { createPermit2ApprovalTx, PERMIT2_ADDRESS } from "@bankofai/x402-evm"; const tx = createPermit2ApprovalTx(tokenAddress); await walletClient.sendTransaction(tx); diff --git a/typescript/packages/mechanisms/stellar/CHANGELOG.md b/typescript/packages/mechanisms/stellar/CHANGELOG.md index e6ac6740..b93bfe05 100644 --- a/typescript/packages/mechanisms/stellar/CHANGELOG.md +++ b/typescript/packages/mechanisms/stellar/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/stellar Changelog +# @bankofai/x402-stellar Changelog ## 2.6.0 diff --git a/typescript/packages/mechanisms/stellar/README.md b/typescript/packages/mechanisms/stellar/README.md index efffd237..2b5bb1a2 100644 --- a/typescript/packages/mechanisms/stellar/README.md +++ b/typescript/packages/mechanisms/stellar/README.md @@ -1,11 +1,11 @@ -# @x402/stellar +# @bankofai/x402-stellar Stellar implementation of the x402 payment protocol using the **Exact** payment scheme with [Soroban token](https://stellar.org/protocol/sep-41) transfers. ## Installation ```bash -npm install @x402/stellar +npm install @bankofai/x402-stellar ``` ## Overview @@ -24,7 +24,7 @@ This package provides three main components for handling x402 payments on Stella ## Package Exports -### Main Package (`@x402/stellar`) +### Main Package (`@bankofai/x402-stellar`) **V2 Protocol Support** - x402 v2 protocol with CAIP-2 network identifiers @@ -66,9 +66,9 @@ This package provides three main components for handling x402 payments on Stella ### Subpath Exports -- `@x402/stellar/exact/client` - `ExactStellarScheme` (client) -- `@x402/stellar/exact/server` - `ExactStellarScheme` (server) -- `@x402/stellar/exact/facilitator` - `ExactStellarScheme` (facilitator) +- `@bankofai/x402-stellar/exact/client` - `ExactStellarScheme` (client) +- `@bankofai/x402-stellar/exact/server` - `ExactStellarScheme` (server) +- `@bankofai/x402-stellar/exact/facilitator` - `ExactStellarScheme` (facilitator) ## Supported Networks @@ -92,9 +92,9 @@ Supports Soroban tokens implementing [SEP-41](https://github.com/stellar/stellar ### 1. Direct Registration (Recommended) ```typescript -import { x402Client } from "@x402/core/client"; -import { createEd25519Signer } from "@x402/stellar"; -import { ExactStellarScheme } from "@x402/stellar/exact/client"; +import { x402Client } from "@bankofai/x402-core/client"; +import { createEd25519Signer } from "@bankofai/x402-stellar"; +import { ExactStellarScheme } from "@bankofai/x402-stellar/exact/client"; const signer = createEd25519Signer(privateKey, "stellar:testnet"); const client = new x402Client().register("stellar:*", new ExactStellarScheme(signer)); @@ -162,7 +162,7 @@ RESOURCE_SERVER_ADDRESS=G... # Resource server's public address ## Related Packages -- `@x402/core` - Core protocol types and client -- `@x402/fetch` - HTTP wrapper with automatic payment handling -- `@x402/evm` - EVM/Ethereum implementation -- `@x402/svm` - Solana/SVM implementation +- `@bankofai/x402-core` - Core protocol types and client +- `@bankofai/x402-fetch` - HTTP wrapper with automatic payment handling +- `@bankofai/x402-evm` - EVM/Ethereum implementation +- `@bankofai/x402-svm` - Solana/SVM implementation diff --git a/typescript/packages/mechanisms/svm/CHANGELOG.md b/typescript/packages/mechanisms/svm/CHANGELOG.md index 525d6ebd..39684c44 100644 --- a/typescript/packages/mechanisms/svm/CHANGELOG.md +++ b/typescript/packages/mechanisms/svm/CHANGELOG.md @@ -1,4 +1,4 @@ -# @x402/svm Changelog +# @bankofai/x402-svm Changelog ## 2.6.0 @@ -10,7 +10,7 @@ - Updated dependencies [2564781] - Updated dependencies [b341973] - Updated dependencies [29fe09a] - - @x402/core@2.6.0 + - @bankofai/x402-core@2.6.0 ## 2.5.0 @@ -19,7 +19,7 @@ - Updated dependencies [96a9db0] - Updated dependencies [d0a2b11] - Updated dependencies - - @x402/core@2.5.0 + - @bankofai/x402-core@2.5.0 ## 2.4.0 @@ -28,20 +28,20 @@ - Updated dependencies [57a5488] - Updated dependencies [018181b] - Updated dependencies [3fb55d7] - - @x402/core@2.4.0 + - @bankofai/x402-core@2.4.0 ## 2.3.0 ### Minor Changes -- 51b8445: Bumped @x402/core dependency to 2.3.0 +- 51b8445: Bumped @bankofai/x402-core dependency to 2.3.0 - bd01572: Added memo instruction with random nonce to SVM transactions to ensure uniqueness and prevent duplicate transaction attacks when multiple payments occur within the same Solana slot ### Patch Changes - Updated dependencies [51b8445] - Updated dependencies [51b8445] - - @x402/core@2.3.0 + - @bankofai/x402-core@2.3.0 ## 2.0.0 diff --git a/typescript/packages/mechanisms/svm/README.md b/typescript/packages/mechanisms/svm/README.md index 01601da1..70decef9 100644 --- a/typescript/packages/mechanisms/svm/README.md +++ b/typescript/packages/mechanisms/svm/README.md @@ -1,11 +1,11 @@ -# @x402/svm +# @bankofai/x402-svm SVM (Solana Virtual Machine) implementation of the x402 payment protocol using the **Exact** payment scheme with SPL Token transfers. ## Installation ```bash -npm install @x402/svm +npm install @bankofai/x402-svm ``` ## Overview @@ -18,7 +18,7 @@ This package provides three main components for handling x402 payments on Solana ## Package Exports -### Main Package (`@x402/svm`) +### Main Package (`@bankofai/x402-svm`) **V2 Protocol Support** - Modern x402 protocol with CAIP-2 network identifiers @@ -40,7 +40,7 @@ This package provides three main components for handling x402 payments on Solana **Utilities:** - Network validation, asset info lookup, amount formatting, transaction encoding -### V1 Package (`@x402/svm/v1`) +### V1 Package (`@bankofai/x402-svm/v1`) **V1 Protocol Support** - Legacy x402 protocol with simple network names @@ -58,7 +58,7 @@ This package provides three main components for handling x402 payments on Solana ] ``` -### Client Builder (`@x402/svm/client`) +### Client Builder (`@bankofai/x402-svm/client`) **Convenience builder** for creating fully-configured SVM clients @@ -74,8 +74,8 @@ This package provides three main components for handling x402 payments on Solana **Example:** ```typescript -import { createSvmClient } from "@x402/svm/client"; -import { toClientSvmSigner } from "@x402/svm"; +import { createSvmClient } from "@bankofai/x402-svm/client"; +import { toClientSvmSigner } from "@bankofai/x402-svm"; import { createKeyPairSignerFromBytes } from "@solana/kit"; import { base58 } from "@scure/base"; @@ -109,8 +109,8 @@ const client = createSvmClient({ signer }); ### 1. Using Pre-built Builder (Recommended) ```typescript -import { createSvmClient } from "@x402/svm/client"; -import { wrapFetchWithPayment } from "@x402/fetch"; +import { createSvmClient } from "@bankofai/x402-svm/client"; +import { wrapFetchWithPayment } from "@bankofai/x402-fetch"; const client = createSvmClient({ signer: mySvmSigner }); const paidFetch = wrapFetchWithPayment(fetch, client); @@ -119,9 +119,9 @@ const paidFetch = wrapFetchWithPayment(fetch, client); ### 2. Direct Registration (Full Control) ```typescript -import { x402Client } from "@x402/core/client"; -import { ExactSvmClient } from "@x402/svm"; -import { ExactSvmClientV1 } from "@x402/svm/v1"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactSvmClient } from "@bankofai/x402-svm"; +import { ExactSvmClientV1 } from "@bankofai/x402-svm/v1"; const client = new x402Client() .register("solana:*", new ExactSvmClient(signer)) @@ -132,8 +132,8 @@ const client = new x402Client() ### 3. Using Config (Flexible) ```typescript -import { x402Client } from "@x402/core/client"; -import { ExactSvmClient } from "@x402/svm"; +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactSvmClient } from "@bankofai/x402-svm"; const client = x402Client.fromConfig({ schemes: [ @@ -203,8 +203,8 @@ pnpm format ## Related Packages -- `@x402/core` - Core protocol types and client -- `@x402/fetch` - HTTP wrapper with automatic payment handling -- `@x402/evm` - EVM/Ethereum implementation -- `@x402/stellar` - Stellar implementation +- `@bankofai/x402-core` - Core protocol types and client +- `@bankofai/x402-fetch` - HTTP wrapper with automatic payment handling +- `@bankofai/x402-evm` - EVM/Ethereum implementation +- `@bankofai/x402-stellar` - Stellar implementation - `@solana/web3.js` - Solana JavaScript SDK (peer dependency) diff --git a/typescript/packages/mechanisms/tron/README.md b/typescript/packages/mechanisms/tron/README.md new file mode 100644 index 00000000..1fad5581 --- /dev/null +++ b/typescript/packages/mechanisms/tron/README.md @@ -0,0 +1,63 @@ +# @bankofai/x402-tron + +TRON implementation of the x402 payment protocol using the **Exact** payment scheme. Supports both EIP-3009 style TransferWithAuthorization and Permit2 flows for TRC-20 tokens. + +## Installation + +```bash +pnpm install @bankofai/x402-tron @bankofai/x402-core +``` + +## Overview + +This package provides components for handling x402 payments on the TRON blockchain: + +- **Client** - For applications that need to make payments (using `ExactTronScheme`) +- **Facilitator** - For payment processors that verify and execute on-chain transactions (using `ExactTronFacilitatorScheme`) +- **Server** - For resource servers that accept payments and build payment requirements (using `ExactTronServerScheme`) + +## Usage + +### Client Setup + +```typescript +import { x402Client } from "@bankofai/x402-core/client"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/client"; + +const client = new x402Client() + .register("tron:*", new ExactTronScheme(tronSigner)); +``` + +### Server Setup + +```typescript +import { x402ResourceServer } from "@bankofai/x402-core/server"; +import { ExactTronScheme } from "@bankofai/x402-tron/exact/server"; + +const server = new x402ResourceServer(facilitatorClient) + .register("tron:*", new ExactTronScheme()); +``` + +### Facilitator Setup + +```typescript +import { x402Facilitator } from "@bankofai/x402-core/facilitator"; +import { registerExactTronScheme } from "@bankofai/x402-tron/exact/facilitator"; + +const facilitator = new x402Facilitator(); +registerExactTronScheme(facilitator, { + signer: tronSigner, + networks: ["tron:mainnet", "tron:nile"], +}); +``` + +## Supported Networks + +Uses [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) identifiers: +- `tron:mainnet` - TRON Mainnet +- `tron:nile` - TRON Nile Testnet +- `tron:shasta` - TRON Shasta Testnet + +## License + +Apache-2.0