Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/agents/code-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ General code review for x402 changes. Treat like a normal `code-reviewer`, but b
1. **Wire format**: any touch to `PaymentRequired`, `PaymentPayload`, or `PaymentResponse` serialization must match [specs/protocol.md](../../specs/protocol.md) and not break [specs/001-exact-v2-compat/spec.md](../../specs/001-exact-v2-compat/spec.md).
2. **Scheme payload**: check that `payload.authorization` is used (not legacy `extensions.transferAuthorization`) for `exact`.
3. **Pipeline step ordering**: client payment selection is 5 steps in [specs/roles.md](../../specs/roles.md). Policies go at step 5.
4. **Mechanism registration**: exact-match network keys (`tron:nile`) win over wildcards (`tron:*`). Flag changes to registration logic.
4. **Mechanism registration**: exact-match network keys (`tron:0xcd8690dc`) win over wildcards (`tron:*`). Flag changes to registration logic.
5. **Lowercase addresses**: all address/selector/topic strings lowercase. Flag any uppercase leak.
6. **Header encoding**: `Base64(UTF-8(JSON.stringify(...)))`, never raw JSON in the header value.

Expand Down
2 changes: 1 addition & 1 deletion .claude/rules/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ When multiple rule files apply, read all of them before editing. Rules are layer
│ └── exact-gasfree.md # TRON GasFree custodial + TIP-712 relayer
├── networks/
│ ├── evm.md # eip155:<chainId>, contracts, signing
│ └── tron.md # tron:<name>, TIP-712 hex-address rule, GasFree link
│ └── tron.md # tron:<hexChainId>, TIP-712 hex-address rule, GasFree link
├── typescript/
│ └── conventions.md # pnpm/turbo, ESM, viem/tronweb, fork+overlay, signer factories
└── testing/
Expand Down
4 changes: 2 additions & 2 deletions .claude/rules/common/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Repository-wide conventions that apply to every component, every scheme. Break t

- **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**. 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.
- **Network identifiers**: CAIP-2 `eip155:<chainId>` for EVM, `tron:<hexChainId>` for TRON (e.g. `tron:0xcd8690dc` for Nile). Detection rule: `tron:` prefix → TRON, `eip155:` prefix → EVM. Prefer the exported constants `TRON_MAINNET` / `TRON_NILE` / `TRON_SHASTA` from `@bankofai/x402-tron` over copying the hex strings.

## Amounts & fees

Expand Down Expand Up @@ -36,7 +36,7 @@ Repository-wide conventions that apply to every component, every scheme. Break t

## 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.
- **Exact match** (e.g. `"tron:0xcd8690dc"`) outranks **wildcard** (e.g. `"tron:*"`). Register more specific first, or accept that exact-match mechanisms win the lookup regardless of insertion order.
- 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
Expand Down
14 changes: 7 additions & 7 deletions .claude/rules/networks/tron.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Mechanisms: `typescript/packages/mechanisms/tron` (`@bankofai/x402-tron`). **In-house, no upstream** — edit directly.

Identifier: `tron:<name>` where `<name>` ∈ {`mainnet`, `shasta`, `nile`}.
Identifier: `tron:<hexChainId>` per CAIP-2 (hex chain id as the reference, not a human-readable name). Canonical constants: `TRON_MAINNET`, `TRON_NILE`, `TRON_SHASTA` exported from `@bankofai/x402-tron`.

| Identifier | Chain ID (decimal) | Chain ID (hex) |
|---|---|---|
| `tron:mainnet` | 728126428 | 0x2b6653dc |
| `tron:shasta` | 2494104990 | 0x94a9059e |
| `tron:nile` | 3448148188 | 0xcd8690dc |
| Constant | Identifier | Chain ID (decimal) | Chain ID (hex) |
|---|---|---|---|
| `TRON_MAINNET` | `tron:0x2b6653dc` | 728126428 | 0x2b6653dc |
| `TRON_SHASTA` | `tron:0x94a9059e` | 2494104990 | 0x94a9059e |
| `TRON_NILE` | `tron:0xcd8690dc` | 3448148188 | 0xcd8690dc |

Chain id helper: `getTronChainId(network)` in `mechanisms/tron/src/utils.ts`.

Expand All @@ -17,7 +17,7 @@ Chain id helper: `getTronChainId(network)` in `mechanisms/tron/src/utils.ts`.
- TIP-712 is TRON's EIP-712 analogue. Structurally identical; same struct-hash / domain-separator algorithm. Uses the in-tree TIP-712 signer — do not add a new lib.
- **Every `address` field** — domain and message — must be **0x-prefixed EVM hex**. Passing Base58 produces a valid-looking but wrong signature.
- Convert Base58 → hex via `tronAddressToEvm` / `normalizeAddressForSigning` (`mechanisms/tron/src/utils.ts`). Do not reimplement.
- Signer factories: `createClientTronSigner` / `createFacilitatorTronSigner` / `createAuthorizerTronSigner` from `@bankofai/x402-tron`. Pass `{ network, apiKey? }`; the factory builds TronWeb internally.
- Signer factories: `createClientTronSigner` / `createFacilitatorTronSigner` / `createAuthorizerTronSigner` from `@bankofai/x402-tron`. `createClientTronSigner` / `createFacilitatorTronSigner` take `{ network, apiKey? }` and build TronWeb internally; `createAuthorizerTronSigner` takes only a wallet (no network — it signs offline).

## Gas & fees

Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Each component has its own `CLAUDE.md` (where present) with build/test commands
- **Addresses, selectors, event topics**: lowercase-normalized everywhere. TRON addresses are converted to **0x-prefixed EVM hex** before any EIP-712/TIP-712 signing — see [docs/solutions.md entry #1](docs/solutions.md).
- **Payment ID**: 16 random bytes, encoded as `0x` + 32 hex chars, signed as `bytes16`.
- **HTTP header encoding**: `Base64(UTF-8(JSON.stringify(object)))` for `PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE`, `PAYMENT-RESPONSE`.
- **Network identifiers**: CAIP-2 `eip155:<chainId>` for EVM; `tron:<name>` for TRON.
- **Mechanism registration**: `tron:nile` (exact match, higher priority) beats `tron:*` (wildcard, lower priority).
- **Network identifiers**: CAIP-2 `eip155:<chainId>` for EVM; `tron:<hexChainId>` for TRON (e.g. `tron:0xcd8690dc` for Nile).
- **Mechanism registration**: `tron:0xcd8690dc` (exact match, higher priority) beats `tron:*` (wildcard, lower priority).
- **Commit messages**: `<type>(<scope>): <description>` — e.g. `fix(tron): preserve raw_data_hex in tron approvals`.

## AI-native development
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const wallet = /* resolve your @bankofai/agent-wallet */;
// Permit2 approve that USDT/USDD need. When TRON_GRID_API_KEY is unset, mainnet
// RPC falls back to a BankofAI-operated endpoint.
const signer = await createClientTronSigner(wallet, {
network: "tron:nile",
network: "tron:0xcd8690dc",
apiKey: process.env.TRON_GRID_API_KEY,
});

Expand Down Expand Up @@ -148,9 +148,9 @@ x402 currently supports TRC-20 tokens on the TRON network and BEP-20 tokens on t

| Network | ID | Status | Recommended For |
|---------|----|--------|-----------------|
| **TRON Nile** | `tron:nile` | Testnet | **Development & Testing** |
| **TRON Shasta** | `tron:shasta` | Testnet | Alternative Testing |
| **TRON Mainnet** | `tron:mainnet` | Mainnet | Production |
| **TRON Nile** | `tron:0xcd8690dc` | Testnet | **Development & Testing** |
| **TRON Shasta** | `tron:0x94a9059e` | Testnet | Alternative Testing |
| **TRON Mainnet** | `tron:0x2b6653dc` | Mainnet | Production |
| **BSC Testnet** | `eip155:97` | Testnet | **Development & Testing** |
| **BSC Mainnet** | `eip155:56` | Mainnet | Production |

Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/.env-batch.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ TRON_GRID_API_KEY=

# ── CLIENT · the payer (clients/batch-settlement) ─────────────────────────
# Which chains to exercise, one burst (+refund) per entry, in order. Each entry is
# <network>[@<token>] network: "eip155:97"/"tron:nile" (or "eip155"/"tron");
# <network>[@<token>] network: "eip155:97"/"tron:0xcd8690dc" (or "eip155"/"tron");
# token optional (each chain advertises one: EVM=USDC, TRON=USDT) — symbol or
# asset address. Use `@` (not `#`) — dotenv treats `#` as a comment.
# Unset ⇒ each configured chain once.
PAY_TARGETS=eip155:97,tron:nile
PAY_TARGETS=eip155:97,tron:0xcd8690dc

# The resource the client fetches (server route).
RESOURCE_URL=http://localhost:4041/weather
Expand All @@ -45,7 +45,7 @@ REFUND_AFTER_REQUESTS=false # refund the remaining channel balance after the bur
# ── SERVER · the resource provider (servers/batch-settlement) ─────────────
# Payout addresses (set the chain(s) you want to accept).
EVM_ADDRESS=0x... # BSC, eip155:97 (token USDC, permit2)
TRON_ADDRESS=T... # TRON, tron:nile (token USDT, permit2)
TRON_ADDRESS=T... # TRON, tron:0xcd8690dc (token USDT, permit2)

# Where the server binds, and where it reaches the facilitator.
SERVER_PORT=4041
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/.env-exact.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ TRON_GRID_API_KEY=

# ── CLIENT · the payer (clients/fetch · clients/mcp) ──────────────────────
# Which chains/tokens to pay, one payment per entry, in order.
# <network>[@<token>] network: "eip155:97"/"tron:nile" (or "eip155"/"tron");
# <network>[@<token>] network: "eip155:97"/"tron:0xcd8690dc" (or "eip155"/"tron");
# token: symbol (DHLU/USDC/USDT on EVM, USDT/USDD on TRON) or an asset address;
# omit the token to use that network's first advertised token.
# Use `@` (not `#`) — dotenv treats `#` as a comment and would truncate the value.
# Unset ⇒ each configured chain once, with its first token.
PAY_TARGETS=eip155:97@DHLU,tron:nile@USDT
PAY_TARGETS=eip155:97@DHLU,tron:0xcd8690dc@USDT

# The resource the client fetches (server route).
RESOURCE_URL=http://localhost:4021/weather
Expand All @@ -40,7 +40,7 @@ MCP_SERVER_URL=http://localhost:4023
# ── SERVER · the resource provider (servers/express · servers/mcp) ────────
# Payout addresses (set the chain(s) you want to accept).
EVM_ADDRESS=0x... # BSC, eip155:97
TRON_ADDRESS=T... # TRON, tron:nile
TRON_ADDRESS=T... # TRON, tron:0xcd8690dc

# Where the server binds, and where it reaches the facilitator.
SERVER_PORT=4021
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/.env-gasfree.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RESOURCE_URL=http://localhost:4031/weather

# ── SERVER · the resource provider (servers/gasfree) ──────────────────────
# Payout address (TRON only).
TRON_ADDRESS=T... # TRON, tron:nile
TRON_ADDRESS=T... # TRON, tron:0xcd8690dc

# Where the server binds, and where it reaches the facilitator.
SERVER_PORT=4031
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/.env-upto.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ TRON_GRID_API_KEY=

# ── CLIENT · the payer (clients/upto) ─────────────────────────────────────
# Which chains to exercise, one N-request run per entry, in order. Each entry is
# <network>[@<token>] network: "eip155:97"/"tron:nile" (or "eip155"/"tron");
# <network>[@<token>] network: "eip155:97"/"tron:0xcd8690dc" (or "eip155"/"tron");
# token optional (each chain advertises one: EVM=USDC, TRON=USDT) — symbol or
# asset address. Use `@` (not `#`) — dotenv treats `#` as a comment.
# Unset ⇒ each configured chain once.
PAY_TARGETS=eip155:97,tron:nile
PAY_TARGETS=eip155:97,tron:0xcd8690dc

# The resource the client fetches (server route).
RESOURCE_URL=http://localhost:4051/generate
Expand All @@ -41,7 +41,7 @@ NUMBER_OF_REQUESTS=3
# ── SERVER · the resource provider (servers/upto) ─────────────────────────
# Payout addresses (set the chain(s) you want to accept).
EVM_ADDRESS=0x... # BSC, eip155:97 (token USDC, permit2)
TRON_ADDRESS=T... # TRON, tron:nile (token USDT, permit2)
TRON_ADDRESS=T... # TRON, tron:0xcd8690dc (token USDT, permit2)

# Where the server binds, and where it reaches the facilitator.
SERVER_PORT=4051
Expand Down
8 changes: 4 additions & 4 deletions examples/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ amount and strips the header. BSC uses USDC, TRON Nile uses USDT — both Permit

| Chain | Network | Token | Scheme | One-time approve | User pays gas? |
|---|---|---|---|---|---|
| TRON nile | `tron:nile` | USDT (6) | exact **permit2** | yes — client auto-broadcasts | only the approve (TRX) |
| TRON nile | `tron:nile` | USDD (18) | exact **permit2** | yes — client auto-broadcasts | only the approve (TRX) |
| TRON nile | `tron:0xcd8690dc` | USDT (6) | exact **permit2** | yes — client auto-broadcasts | only the approve (TRX) |
| TRON nile | `tron:0xcd8690dc` | USDD (18) | exact **permit2** | yes — client auto-broadcasts | only the approve (TRX) |
| BSC testnet | `eip155:97` | DHLU (6) | exact **eip3009** | none | **none (fully gasless)** |
| BSC testnet | `eip155:97` | USDC (18) | exact **permit2 + gas-sponsoring** | yes — client signs, facilitator relays | only the approve (BNB) |

Expand Down Expand Up @@ -131,8 +131,8 @@ below). All verified on-chain; sources: the official
| `eip155:56` (BSC) | USDC | `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d` | 18 | permit2 |
| `eip155:56` (BSC) | USDT | `0x55d398326f99059fF775485246999027B3197955` | 18 | permit2 |
| `eip155:56` (BSC) | EPS | `0xA7f552078dcC247C2684336020c03648500C6d9F` | 18 | permit2 |
| `tron:mainnet` | USDT | `TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t` | 6 | permit2 |
| `tron:mainnet` | USDD | `TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz` | 18 | permit2 |
| `tron:0x2b6653dc` | USDT | `TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t` | 6 | permit2 |
| `tron:0x2b6653dc` | USDD | `TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz` | 18 | permit2 |

> BSC mainnet has **no ERC-3009 token** (USDC/USDT/EPS are all plain BEP-20) — so
> mainnet EVM payments all go permit2 + gas-sponsored approve. DHLU (eip3009) is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* the address and re-adds the `0x` prefix agent-wallet strips. The TronWeb
* instance carries no private key.
*
* On `tron:nile` the server advertises USDT, a Permit2 token — the first request
* On `tron:0xcd8690dc` the server advertises USDT, a Permit2 token — the first request
* opens the channel via a **Permit2 deposit**, which needs a one-time
* `approve(Permit2)` from the payer. `signTransaction` lets the signer
* auto-broadcast that approve (parity with the `exact` TRON client). Later
Expand All @@ -16,7 +16,7 @@ import type { x402Client } from "@bankofai/x402-fetch";

import { tryResolveWallet, type BatchClientOptions, type RefundableScheme } from "../env.js";

const TRON_NETWORK = "tron:nile";
const TRON_NETWORK = "tron:0xcd8690dc";

/**
* Registers the TRON `batch-settlement` client scheme, if a TRON wallet is
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/clients/batch-settlement/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type SignerWallet = Wallet & {
*/
const CAIP2_BY_FAMILY: Record<"evm" | "tron", string> = {
evm: "eip155:97",
tron: "tron:nile",
tron: "tron:0xcd8690dc",
};

/**
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/clients/batch-settlement/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* target. This file imports no chain SDK directly.
*
* PAY_TARGETS — comma-separated, one burst (+refund) per entry, in order:
* <network>[@<token>] network: "eip155:97"/"tron:nile" (or "eip155"/"tron");
* <network>[@<token>] network: "eip155:97"/"tron:0xcd8690dc" (or "eip155"/"tron");
* token: symbol or asset address; omit ⇒ the network's first advertised token.
* (`@` not `#` — dotenv treats `#` as a comment.)
* Unset ⇒ each configured chain once.
Expand All @@ -36,8 +36,8 @@ const opts: BatchClientOptions = {
const TOKEN_ADDRESSES: Record<string, string> = {
DHLU: "0x375cADdd2cB68cE82e3D9B075D551067a7b4B816", // eip155:97, ERC-3009
USDC: "0x64544969ed7EBf5f083679233325356EbE738930", // eip155:97, permit2 (default)
USDT: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf", // tron:nile, permit2 (default)
USDD: "TGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaK", // tron:nile, permit2
USDT: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf", // tron:0xcd8690dc, permit2 (default)
USDD: "TGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaK", // tron:0xcd8690dc, permit2
};

/** A single payment target: a network prefix + optional asset address. */
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/clients/fetch/src/chains/tron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { x402Client } from "@bankofai/x402-fetch";

import { tryResolveWallet } from "../env.js";

const TRON_NETWORKS = ["tron:nile", "tron:mainnet"] as const;
const TRON_NETWORKS = ["tron:0xcd8690dc", "tron:0x2b6653dc"] as const;

/**
* Registers the TRON `exact` client scheme, if a TRON wallet is configured.
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/clients/fetch/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type SignerWallet = Wallet & {
*/
const CAIP2_BY_FAMILY: Record<"evm" | "tron", string> = {
evm: "eip155:97",
tron: "tron:nile",
tron: "tron:0xcd8690dc",
};

/**
Expand Down
14 changes: 7 additions & 7 deletions examples/typescript/clients/fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*
* PAY_TARGETS — comma-separated, one payment per entry, in order:
* <network>[@<token>]
* <network> matched by prefix: "eip155:97" / "tron:nile" (or "eip155" / "tron")
* <network> matched by prefix: "eip155:97" / "tron:0xcd8690dc" (or "eip155" / "tron")
* <token> symbol (DHLU/USDC/USDT/USDD) or an asset address; omit ⇒ that
* network's first advertised token
* e.g. PAY_TARGETS=eip155:97@DHLU,tron:nile@USDT,tron:nile@USDD
* e.g. PAY_TARGETS=eip155:97@DHLU,tron:0xcd8690dc@USDT,tron:0xcd8690dc@USDD
* (`@` not `#` — dotenv treats `#` as a comment.)
* Unset ⇒ each configured chain once, with its first advertised token.
*/
Expand All @@ -28,7 +28,7 @@ const RESOURCE_URL =
// Friendly token symbol → asset address, mirroring what `servers/express`
// advertises. Lets PAY_TARGETS name tokens by symbol instead of address.
// Indexed by chain family so the same symbol can resolve differently per
// network (e.g. USDT on eip155:97 vs tron:nile are different contracts).
// network (e.g. USDT on eip155:97 vs tron:0xcd8690dc are different contracts).
const TOKEN_ADDRESSES: Record<string, Record<string, string>> = {
"eip155:97": {
DHLU: "0x375cADdd2cB68cE82e3D9B075D551067a7b4B816", // eip155:97, ERC-3009
Expand All @@ -39,11 +39,11 @@ const TOKEN_ADDRESSES: Record<string, Record<string, string>> = {
USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
USDT: "0x55d398326f99059fF775485246999027B3197955",
},
"tron:nile": {
USDT: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf", // tron:nile, permit2
USDD: "TGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaK", // tron:nile, permit2
"tron:0xcd8690dc": {
USDT: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf", // tron:0xcd8690dc, permit2
USDD: "TGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaK", // tron:0xcd8690dc, permit2
},
"tron:mainnet": {
"tron:0x2b6653dc": {
USDT: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
USDD: "TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz",
},
Expand Down
4 changes: 2 additions & 2 deletions examples/typescript/clients/gasfree/src/chains/tron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { x402Client } from "@bankofai/x402-fetch";

import { tryResolveTronWallet } from "../env.js";

const TRON_NETWORK = "tron:nile";
const TRON_NETWORK = "tron:0xcd8690dc";

/**
* Registers the TRON `exact_gasfree` client scheme, if a TRON wallet resolves.
Expand All @@ -43,7 +43,7 @@ export async function registerTronGasFree(client: x402Client): Promise<boolean>
registerExactGasFreeTronScheme(client, {
signer,
...(process.env.GASFREE_API_URL
? { schemeOptions: { apiBaseUrls: { "tron:nile": process.env.GASFREE_API_URL } } }
? { schemeOptions: { apiBaseUrls: { "tron:0xcd8690dc": process.env.GASFREE_API_URL } } }
: {}),
});
console.info(`[tron] client registered tron:* exact_gasfree (${signer.address})`);
Expand Down
4 changes: 2 additions & 2 deletions examples/typescript/clients/gasfree/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export type SignerWallet = Wallet & {
*
* `@bankofai/agent-wallet` expects a **CAIP-2** network id. Key derivation is
* chain-id-independent within a family, so any `tron:` id resolves the same
* address; we use `tron:nile`.
* address; we use `tron:0xcd8690dc`.
*
* @returns The wallet, or `null` to skip TRON.
*/
export async function tryResolveTronWallet(): Promise<SignerWallet | null> {
try {
return (await resolveWallet({ network: "tron:nile" })) as SignerWallet;
return (await resolveWallet({ network: "tron:0xcd8690dc" })) as SignerWallet;
} catch {
return null;
}
Expand Down
Loading
Loading