Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
9c172bb
feat(ts): add typescript_new monorepo
Jun 15, 2026
f035eeb
Merge pull request #72 from matrix-agent116/release-v1.0.0
roger-gan Jun 17, 2026
387ac47
align bankofai's x402
roger-gan Jun 17, 2026
d391619
support upto & batch-settlement
roger-gan Jun 17, 2026
a6c71ca
chore(typescript): rename typescript_new packages to @bankofai scope …
roger-gan Jun 18, 2026
71a0e9d
fix(typescript): pin typescript_new lockfile to upstream dependency r…
roger-gan Jun 18, 2026
ce50bc2
fix(typescript): add missing site -> @bankofai/x402-hedera link to lo…
roger-gan Jun 18, 2026
0b18527
fix(typescript): restore site/lib/animations.tsx swallowed by Python …
roger-gan Jun 18, 2026
63754b4
chore(typescript): drop non-EVM/TRON mechanisms, paywall, and demo site
roger-gan Jun 18, 2026
6432057
docs(tron): correct signer examples to pass AgentWallet, not private …
roger-gan Jun 18, 2026
e904c13
chore(typescript): add .prettierrc and .prettierignore for typescript…
roger-gan Jun 18, 2026
acd6a7e
feat(evm): add createFacilitatorEvmSigner wallet-bridge factory
roger-gan Jun 18, 2026
c764a38
feat(evm): add createClientEvmSigner client wallet-bridge
roger-gan Jun 18, 2026
a7f20af
docs(examples): add EVM+TRON main-line TypeScript examples
roger-gan Jun 18, 2026
4947d49
feat(tron): auto-approve Permit2 allowance in client signer
roger-gan Jun 19, 2026
558f5c2
docs(examples): wire signTransaction for TRON client auto-approve
roger-gan Jun 19, 2026
42f3e1a
test(tron): wire signTransaction in integration client wallet adapter
roger-gan Jun 19, 2026
9eeab4a
perf(tron): confirm client Permit2 approve at packed speed
roger-gan Jun 19, 2026
73392c4
feat(evm): wallet-bridge support for ERC-20 approval gas-sponsoring
roger-gan Jun 19, 2026
316dfae
feat(examples): TRON balance guard on the fetch client
roger-gan Jun 19, 2026
758357b
feat(examples): BSC support + TRON USDD via per-network token tables
roger-gan Jun 19, 2026
ad6eff9
refactor(examples): single shared gitignored .env-local
roger-gan Jun 19, 2026
cb264f1
fix(examples): make the three apps typecheck
roger-gan Jun 19, 2026
f43f247
revert(examples): drop the TRON balance-guard hook
roger-gan Jun 19, 2026
bf50995
perf(tron): confirm facilitator settle at packed speed
roger-gan Jun 19, 2026
f0245c6
fix(tron): confirm packed tx with a delay + two stable reads
roger-gan Jun 19, 2026
e260ca7
fix(evm): bind agent-wallet signTransaction in the client signer
roger-gan Jun 19, 2026
c349d3b
fix(examples): resolve agent-wallet with CAIP-2 network ids
roger-gan Jun 19, 2026
69de309
fix(gasfree): clamp+warn TRON gasfree deadline to align with python c…
roger-gan Jun 22, 2026
9b585c3
fix(tron): harden signer allowance read + broadcast txid check
roger-gan Jun 22, 2026
441b3c5
refactor(tron): align client scheme/config interfaces (options + naming)
roger-gan Jun 22, 2026
0b1ee6d
fix(tron): normalize signTypedData in client signer factory
roger-gan Jun 22, 2026
5c44337
fix(tron): use core parseMoneyString for server price parsing
roger-gan Jun 22, 2026
0dbb795
docs(tron): clarify fee advisory-vs-enforced and signer setAddress si…
roger-gan Jun 22, 2026
b09ee2d
chore(tron): prettier-format gasfree-flow test
roger-gan Jun 22, 2026
d8e1c95
fix(tron): sync mainnet contract addresses with x402-contracts registry
roger-gan Jun 22, 2026
171091c
fix(tron): default GasFree relayer to BankofAI proxy for out-of-box use
roger-gan Jun 22, 2026
df5c813
feat(gasfree): add TRON exact_gasfree example apps in examples_new
roger-gan Jun 22, 2026
7df6047
feat(evm): add BSC to batch-settlement default-asset registry
roger-gan Jun 23, 2026
0c458b8
feat(typescript): add batch-settlement example (BSC + TRON), split en…
roger-gan Jun 23, 2026
e9d77fe
fix(tron): auto-approve Permit2 in upto client (ensureAllowance)
roger-gan Jun 23, 2026
f961122
fix(evm): make upto verify simulate as the witness facilitator; use p…
roger-gan Jun 23, 2026
0f39d5b
feat(typescript): add upto usage-based-billing example (EVM + TRON)
roger-gan Jun 23, 2026
9fd8d62
refactor(evm): keep agent-wallet overlay minimal; move upto fix out o…
roger-gan Jun 23, 2026
0641447
feat(core): add chain-agnostic wallet contracts (./wallets)
roger-gan Jun 23, 2026
acd7351
refactor(evm): network-driven adapter factories + authorizer signer
roger-gan Jun 23, 2026
4394044
refactor(tron): network-driven signer factories + authorizer signer
roger-gan Jun 23, 2026
1d6752d
chore(examples): adopt network-driven signer API (EVM + TRON)
roger-gan Jun 23, 2026
5d8459f
docs(typescript): add typescript_new CLAUDE.md
roger-gan Jun 23, 2026
aabf9fc
refactor(examples): use SDK helpers, drop RequestHandler casts
roger-gan Jun 24, 2026
8866544
style(evm): prettier formatting (defaultAssets comment, facilitator t…
roger-gan Jun 24, 2026
7931913
style(evm): wrap createAuthorizerEvmSigner signature
roger-gan Jun 24, 2026
519c39d
refactor(tron)!: align batch-settlement scheme surface with EVM
roger-gan Jun 24, 2026
d2a2bbf
refactor(tron)!: rename ExactGasFreeScheme -> ExactGasFreeTronScheme
roger-gan Jun 24, 2026
d9d3ffd
docs(typescript): document scheme API surface (naming, subpaths, regi…
roger-gan Jun 24, 2026
687f3e1
refactor(examples): price gasfree accepts in "$" form, matching upto/…
roger-gan Jun 24, 2026
8a893b8
fix(typescript): add nile/shasta fallback RPC when TRON_GRID_API_KEY …
roger-gan Jun 24, 2026
ed1e6ef
fix(gasfree): return [] from getProviders on 404 (network unsupported)
roger-gan Jun 24, 2026
a4c2a73
feat(typescript): add injectable global Logger, route console through it
roger-gan Jun 24, 2026
307a103
feat(typescript): instrument payment path with structured logs
roger-gan Jun 24, 2026
483a193
docs(examples): document Logger usage and add runnable logging example
roger-gan Jun 24, 2026
fc6e3b7
fix(tron): add nile/shasta fallback RPC when TRON_GRID_API_KEY unset
roger-gan Jun 24, 2026
90c30b8
fix(gasfree): return [] from getProviders on 404 (network unsupported)
roger-gan Jun 24, 2026
dfd139e
refactor(typescript): move facilitator verify/settle logging to hook …
roger-gan Jun 24, 2026
34acd0c
fix(tron): surface settle broadcast error via errorMessage
roger-gan Jun 24, 2026
4166caf
fix(tron): guard toSignedTransaction JSON.parse with a clear contract…
roger-gan Jun 24, 2026
e3b1caa
feat(examples): add MCP example and env-driven multi-chain PAY_TARGET…
roger-gan Jun 25, 2026
14b91fa
test(tron): remove obsolete nile integration test suite
roger-gan Jun 25, 2026
ea661ee
refactor(tron): trim internal-only exports from public barrel, expose…
roger-gan Jun 25, 2026
c9c39ac
refactor(typescript): make attachFacilitatorLogging internal, trim co…
roger-gan Jun 25, 2026
3a7f1a5
chore: gitignore turbo build cache
roger-gan Jun 25, 2026
4e378cb
feat(examples): opt-in resource.url stripping for hosted facilitators
roger-gan Jun 26, 2026
50c20b1
refactor(evm): stop auto-registering legacy v1 schemes in registerExa…
roger-gan Jun 26, 2026
67b4c5d
feat(examples): opt-in FACILITATOR_API_KEY for resource servers
roger-gan Jun 29, 2026
877f3e1
feat(client): opt-in EVM_RPC_URL override for fetch client
roger-gan Jun 29, 2026
f9f9472
feat(server): log verify/settle lifecycle on express example
roger-gan Jun 29, 2026
19e4cbc
feat(typescript): unify verify/settle logging across facilitator and …
roger-gan Jun 29, 2026
fe7e514
refactor(server): use createResourceServer in express example
roger-gan Jun 29, 2026
c4472cc
fix(gasfree): stop advertising facilitator address as GasFree feeTo
roger-gan Jun 29, 2026
9d882b4
refactor(server): use createResourceServer in upto/gasfree/batch/mcp …
roger-gan Jun 29, 2026
cc49af3
feat(client): wire EVM_RPC_URL override into upto and batch clients
roger-gan Jun 29, 2026
d667b9e
fix(batch): select own VM family's accept in refund probe
roger-gan Jun 29, 2026
b68ad41
docs(examples): group .env examples by client/server/facilitator role
roger-gan Jun 30, 2026
0711791
chore(repo): reorganize into legacy/, drop _new suffix, realign tooling
roger-gan Jun 30, 2026
ef38f97
chore(design): drop legacy create-scenario command
roger-gan Jun 30, 2026
1b45b33
chore(design): remove scheme-author agent
roger-gan Jun 30, 2026
956187b
docs(readme): align README with the new TypeScript-only SDK
roger-gan Jun 30, 2026
16625db
docs(contributing): align with the new TypeScript-only SDK
roger-gan Jun 30, 2026
96154ad
docs(readme): lead the client example with TRON, BSC as the variant
roger-gan Jun 30, 2026
aa2e22c
docs(readme): drop x402-demo references
roger-gan Jun 30, 2026
6c691e7
change tron mainnet contract address
roger-gan Jul 1, 2026
133a537
feat(examples): add BSC testnet USDT to express exact server
roger-gan Jul 1, 2026
7328647
fix(examples): resolve token symbol per-chain-family in fetch client
roger-gan Jul 1, 2026
0acf34f
fix(examples): use correct BSC testnet USDT contract address
roger-gan Jul 1, 2026
4c18b93
fix(examples): use BSC testnet USDT contract with available test balance
roger-gan Jul 1, 2026
bdd783a
style(examples): normalize BSC testnet USDT address to EIP-55 checksum
roger-gan Jul 2, 2026
adfb73b
fix(tron): use fullNode gettransactioninfobyid for accurate settle re…
roger-gan Jul 2, 2026
3277ed8
feat: support reliable exact mainnet payments
roger-gan Jul 2, 2026
0d7274a
Merge origin/main into release-v1.0.0
roger-gan Jul 2, 2026
d8cd2f9
docs: add v1.0.0 changelog and release notes
roger-gan Jul 2, 2026
7c2b7c1
chore: bump all packages to 1.0.0
roger-gan Jul 2, 2026
fbaba35
fix(tron): use core convertToTokenAmount for strict amount validation
roger-gan Jul 2, 2026
1c39c1e
chore: gitignore audit/ and untrack audit reports
roger-gan Jul 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 0 additions & 51 deletions .claude/agents/scheme-author.md

This file was deleted.

88 changes: 0 additions & 88 deletions .claude/commands/x402/create-scenario.md

This file was deleted.

57 changes: 28 additions & 29 deletions .claude/rules/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

This is the rules knowledge base. Every file here is a **self-contained rule sheet** Claude loads on demand when the touched code matches its scope. Rules override defaults; CLAUDE.md at the repo root sets the floor.

The SDK is a **TypeScript-only** pnpm/turbo monorepo under [typescript/](../../typescript/CLAUDE.md). `core` and `mechanisms/evm` are **upstream forks** (keep byte-identical, additions go in overlays); `mechanisms/tron` is in-house. There is no Python in the current SDK. (The previous-generation Python + old TypeScript code lives under `legacy/` and is slated for removal — these rules do **not** cover it.)

## When Claude reads what

| Scope of the change | Always read | Also read |
|---|---|---|
| Any file in the repo | [common/conventions.md](common/conventions.md) | — |
| Python code under `python/x402/` | common/ | [python/conventions.md](python/conventions.md) |
| TypeScript under `typescript/packages/` | common/ | [typescript/conventions.md](typescript/conventions.md) |
| Scheme `exact` (ERC-3009) code or spec | common/ | [schemes/exact.md](schemes/exact.md) |
| Scheme `exact_permit` (EIP-2612) code or spec | common/ | [schemes/exact-permit.md](schemes/exact-permit.md) |
| Scheme `exact_gasfree` (TRON GasFree) code or spec | common/ | [schemes/exact-gasfree.md](schemes/exact-gasfree.md) + [networks/tron.md](networks/tron.md) |
| TRON mechanisms / config | common/ | [networks/tron.md](networks/tron.md) |
| EVM mechanisms / config | common/ | [networks/evm.md](networks/evm.md) |
| e2e scenarios (`e2e/scenarios/`, `integration/`) | common/ | [testing/scenarios.md](testing/scenarios.md) |
| Scheme `exact` (ERC-3009 / Permit2) | common/ | [schemes/exact.md](schemes/exact.md) |
| Scheme `upto` (usage-based) | common/ | [schemes/upto.md](schemes/upto.md) |
| Scheme `batch-settlement` (payment channels) | common/ | [schemes/batch-settlement.md](schemes/batch-settlement.md) |
| Scheme `auth-capture` (EVM authorize+capture) | common/ | [schemes/auth-capture.md](schemes/auth-capture.md) |
| Scheme `exact_gasfree` (TRON GasFree) | common/ | [schemes/exact-gasfree.md](schemes/exact-gasfree.md) + [networks/tron.md](networks/tron.md) |
| TRON mechanisms (`mechanisms/tron`) | common/ | [networks/tron.md](networks/tron.md) |
| EVM mechanisms (`mechanisms/evm`) | common/ | [networks/evm.md](networks/evm.md) |
| Tests (`packages/*/test/**`) | common/ | [testing/conventions.md](testing/conventions.md) |

When multiple rule files apply, read all of them before editing. Rules are layered, not exclusive.

Expand All @@ -25,18 +28,18 @@ When multiple rule files apply, read all of them before editing. Rules are layer
├── common/
│ └── conventions.md # repo-wide: addressing, amounts, headers, pipeline, commit style
├── schemes/
│ ├── exact.md # ERC-3009 transferWithAuthorization
│ ├── exact-permit.md # EIP-2612 / TIP-2612 permit + transferFrom
│ ├── exact.md # ERC-3009 / Permit2 (extra.assetTransferMethod)
│ ├── upto.md # usage-based: sign up-to-max, settle actual
│ ├── batch-settlement.md # payment channels: deposit + off-chain vouchers + refund
│ ├── auth-capture.md # EVM authorize then capture
│ └── exact-gasfree.md # TRON GasFree custodial + TIP-712 relayer
├── networks/
│ ├── evm.md # eip155:<chainId>, contracts, signing, smoke tests
│ ├── evm.md # eip155:<chainId>, contracts, signing
│ └── tron.md # tron:<name>, TIP-712 hex-address rule, GasFree link
├── python/
│ └── conventions.md # Python 3.11+, uv, pytest, pydantic v2, async-first
├── typescript/
│ └── conventions.md # Node 20+, pnpm, ESM, viem, BigInt, named exports
│ └── conventions.md # pnpm/turbo, ESM, viem/tronweb, fork+overlay, signer factories
└── testing/
└── scenarios.md # e2e/scenarios/ JSON scenario authoring + ports + tiers
└── conventions.md # vitest unit + integration layout, self-skip, mocking
```

## Authoring a new rule
Expand All @@ -45,35 +48,31 @@ Add a rule **only when the knowledge is non-obvious and would otherwise be relea

Structure every rule file:

1. **Header** — one line: what scope this covers + pointer to the canonical spec under `specs/`.
1. **Header** — one line: what scope this covers + pointer to the authoritative source (the package source, or [typescript/CLAUDE.md](../../typescript/CLAUDE.md)).
2. **When to use** — the decision the rule answers.
3. **Key invariants** — the short list that must hold.
4. **Common gotchas** — cite commits or `docs/solutions.md` entries. Every bullet should map to a real incident.
4. **Common gotchas** — cite commits. Every bullet should map to a real incident.
5. **Testing** — where the tests live and what template to reuse.

### New scheme

1. New spec at `specs/<scheme>.md`.
2. New rule at `.claude/rules/schemes/<scheme>.md` — link back to the spec.
3. Register the scheme in the mechanism and the `config.md` registry.
4. Scenario skeleton: `/x402:create-scenario` (see [../commands/x402/create-scenario.md](../commands/x402/create-scenario.md)).
1. New scheme classes per role under `mechanisms/<chain>/src/<scheme>/{client,facilitator,server}` — `<Scheme><Chain>Scheme`, same class name across roles, role = import subpath (see [typescript/CLAUDE.md](../../typescript/CLAUDE.md)).
2. New rule at `.claude/rules/schemes/<scheme>.md`.
3. Register the scheme on the client/facilitator with `new + register` (thin pass-through register helpers are not added).

### New network

1. Add to `specs/config.md` registry.
2. New rule at `.claude/rules/networks/<name>.md` — chain ids, signing rules, RPC defaults, contract table.
3. If it introduces a new signing flavor (e.g. TIP-712 analogue), document the conversion helpers.
1. New rule at `.claude/rules/networks/<name>.md` — chain ids, signing rules, RPC defaults, contract table.
2. If it introduces a new signing flavor (e.g. a TIP-712 analogue), document the conversion helpers.

## Relation to other surfaces

- **specs/** — authoritative protocol definitions. Rules cite specs; specs do not cite rules.
- **docs/solutions.md** — incident log. Rules point here when a gotcha came from a real bug; new solutions are added via `/x402:compound`.
- **.claude/agents/** — specialized reviewers (`code-reviewer`, `security-reviewer`, `scheme-author`) that load the rules relevant to their domain. Payment-path / signing changes route through `security-reviewer`.
- **.claude/commands/x402/** — slash-command wizards that scaffold code + scenarios conforming to these rules.
- **[typescript/CLAUDE.md](../../typescript/CLAUDE.md)** — the SDK's own build/test/layout guide and the fork/overlay + signer-factory + scheme-API rules. Rules here cite it; it is the authoritative source for structure.
- **.claude/agents/** — specialized reviewers (`code-reviewer`, `security-reviewer`) that load the rules relevant to their domain. Payment-path / signing changes route through `security-reviewer`.
- **.claude/commands/x402/** — slash-command wizards that scaffold code conforming to these rules.

## Don'ts

- **No code examples longer than 10 lines** in a rule. If it needs more, it belongs in `specs/` or an example.
- **No duplicating specs.** Rules are *behavioral guidance*; specs are *definitions*. Link, don't copy.
- **No code examples longer than 10 lines** in a rule.
- **No rule without a scope.** If you can't say which file touches trigger it, it belongs in `CLAUDE.md` instead.
- **No rules that rot.** Anything citing a specific line number or commit that isn't a historical anchor will drift — prefer filenames and invariants.
16 changes: 8 additions & 8 deletions .claude/rules/common/conventions.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# x402 Conventions

Repository-wide conventions that apply to every component, every language, every scheme. Break these silently and you will produce bugs that take days to diagnose.
Repository-wide conventions that apply to every component, every scheme. Break these silently and you will produce bugs that take days to diagnose.

## Addressing

- **Lowercase everything**: addresses, selectors, event topics.
- **TRON + EIP/TIP-712**: convert TRON Base58 addresses (`T...`) to **0x-prefixed EVM hex** before passing to any EIP-712 / TIP-712 signer. This applies to `verifyingContract`, `token`, `serviceProvider`, `user`, `receiver`, and any other `address`-typed field, **both in the domain and in the message**. See [docs/solutions.md entry #1](../../../docs/solutions.md).
- **Network identifiers**: CAIP-2 `eip155:<chainId>` for EVM, `tron:<name>` for TRON. Detection rule: `tron:` prefix → TRON, `eip155:` prefix → EVM. See [specs/config.md](../../../specs/config.md).
- **TRON + EIP/TIP-712**: convert TRON Base58 addresses (`T...`) to **0x-prefixed EVM hex** before passing to any EIP-712 / TIP-712 signer. This applies to `verifyingContract`, `token`, `serviceProvider`, `user`, `receiver`, and any other `address`-typed field, **both in the domain and in the message**. Use `tronAddressToEvm` / `normalizeAddressForSigning` from `mechanisms/tron/src/utils.ts` — do not reimplement. See [docs/solutions.md entry #1](../../../docs/solutions.md).
- **Network identifiers**: CAIP-2 `eip155:<chainId>` for EVM, `tron:<name>` for TRON. Detection rule: `tron:` prefix → TRON, `eip155:` prefix → EVM.

## Amounts & fees

- **Fees in millionths** (e.g. `3000` = 0.3%).
- **Token amounts in smallest unit** (wei / sun). Never use floating point. Use `BigInt` in TS, `int` in Python.
- **Token amounts in smallest unit** (wei / sun). Never use floating point. Use `BigInt` in TS; serialize with `.toString()`, never through `Number`.

## Payment identifiers

Expand All @@ -20,7 +20,7 @@ Repository-wide conventions that apply to every component, every language, every
## HTTP wire format

- **Header encoding**: `Base64(UTF-8(JSON.stringify(object)))`.
- **Headers** (see [specs/protocol.md](../../../specs/protocol.md)):
- **Headers**:
- `PAYMENT-REQUIRED` — server → client (402 response)
- `PAYMENT-SIGNATURE` — client → server (retry request)
- `PAYMENT-RESPONSE` — server → client (success response, with settlement info)
Expand All @@ -37,11 +37,11 @@ Repository-wide conventions that apply to every component, every language, every
## Mechanism registration

- **Exact match** (e.g. `"tron:nile"`) outranks **wildcard** (e.g. `"tron:*"`). Register more specific first, or accept that exact-match mechanisms win the lookup regardless of insertion order.
- Each mechanism is associated with a scheme (`exact`, `exact_permit`, `exact_gasfree`, ...). Do not conflate schemes across mechanisms; register each scheme-network pair explicitly.
- Each scheme class is registered per `(network, scheme)` with `new + register` (no thin wrapper). Do not conflate schemes across mechanisms; register each scheme-network pair explicitly. See [typescript/CLAUDE.md](../../../typescript/CLAUDE.md) "Scheme API surface".

## Policy pipeline

Client payment selection is a five-step pipeline (see [specs/roles.md](../../../specs/roles.md)):
Client payment selection is a five-step pipeline:

```
[1] Filter by scheme → [2] Filter by network → [3] Filter by max amount
Expand All @@ -56,4 +56,4 @@ Format: `<type>(<scope>): <description>`.

Types: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `perf`, `ci`.

Scopes (choose the narrowest one that fits): `python`, `typescript`, `tron`, `evm`, `gasfree`, `facilitator`, `client`, `server`, `specs`, `docs`, `ci`, `design`.
Scopes (choose the narrowest one that fits): `typescript`, `tron`, `evm`, `gasfree`, `facilitator`, `client`, `server`, `core`, `http`, `mcp`, `docs`, `ci`, `design`.
Loading
Loading