Skip to content

Commit dc3c321

Browse files
committed
2 parents b92066b + 9c217cd commit dc3c321

File tree

16 files changed

+235
-456
lines changed

16 files changed

+235
-456
lines changed

CLAUDE.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ pnpm -C web/frontend check # Web frontend uses Biome
105105
cd contracts
106106
./deploy-contract.sh [NETWORK] [OPTIONS]
107107

108-
# Examples:
109-
./deploy-contract.sh base-sepolia --all --verify # Deploy all contracts
110-
./deploy-contract.sh base --settlement --verify # SettlementRouter only
111-
./deploy-contract.sh xlayer --hooks --verify # Built-in hooks
108+
# Examples (using CAIP-2 format):
109+
./deploy-contract.sh eip155:84532 --all --verify # Deploy all contracts (Base Sepolia)
110+
./deploy-contract.sh eip155:8453 --settlement --verify # SettlementRouter only (Base Mainnet)
111+
./deploy-contract.sh eip155:196 --hooks --verify # Built-in hooks (X-Layer Mainnet)
112112
```
113113

114114
## Key Architecture Concepts
@@ -162,7 +162,15 @@ Hooks receive **net value** (after facilitator fee) and implement arbitrary busi
162162

163163
### Dual-Stack Protocol Support
164164

165-
The codebase supports both x402 v1 (human-readable network names like `base-sepolia`) and v2 (CAIP-2 identifiers like `eip155:84532`). Detection is automatic based on request format. Enable v2 with `FACILITATOR_ENABLE_V2=true`.
165+
The codebase supports both x402 v1 (human-readable network names like `base-sepolia`) and v2 (CAIP-2 identifiers like `eip155:84532`). Detection is automatic based on request format. CAIP-2 format is recommended for all new implementations.
166+
167+
**CAIP-2 format examples:**
168+
- Base Sepolia: `eip155:84532` (chain ID 84532)
169+
- Base Mainnet: `eip155:8453` (chain ID 8453)
170+
- X-Layer Testnet: `eip155:1952` (chain ID 1952)
171+
- X-Layer Mainnet: `eip155:196` (chain ID 196)
172+
173+
Enable v2 with `FACILITATOR_ENABLE_V2=true`.
166174

167175
## Important Development Rules
168176

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ cd contracts
154154
./deploy-contract.sh [NETWORK] [OPTIONS] # Configure .env first
155155

156156
# Examples:
157-
./deploy-contract.sh base-sepolia --all --verify # Deploy everything on testnet
158-
./deploy-contract.sh base --settlement --verify # Deploy SettlementRouter on mainnet
159-
./deploy-contract.sh xlayer --hooks --verify # Deploy built-in hooks
157+
./deploy-contract.sh eip155:84532 --all --verify # Deploy everything on testnet (Base Sepolia)
158+
./deploy-contract.sh eip155:8453 --settlement --verify # Deploy SettlementRouter on mainnet (Base)
159+
./deploy-contract.sh eip155:196 --hooks --verify # Deploy built-in hooks (X-Layer)
160160
```
161161

162162
## 💡 Usage Examples

README_CN.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,30 @@ x402-exec/
105105

106106
### 第三方开发者集成
107107

108-
如果你想在自己的项目中使用 x402-exec,我们提供了一个增强版的 x402 包。详细说明请查看 [第三方集成指南](./docs/third-party-integration.md)
108+
如果你想在自己的项目中使用 x402-exec,请使用官方 x402 v2 包。详细说明请查看 [第三方集成指南](./docs/third-party-integration.md)
109109

110110
**快速安装:**
111111

112112
```bash
113-
# 使用 npm alias(推荐)
114-
npm install x402@npm:@x402x/x402@0.6.6-patch.7
113+
# 使用官方 x402 v2 包
114+
npm install @x402/core @x402/evm @x402x/extensions
115115

116116
# 或使用 pnpm
117-
pnpm add x402@npm:@x402x/x402@0.6.6-patch.7
117+
pnpm add @x402/core @x402/evm @x402x/extensions
118118
```
119119

120120
`package.json` 中:
121121
```json
122122
{
123123
"dependencies": {
124-
"x402": "npm:@x402x/x402@0.6.6-patch.7"
124+
"@x402/core": "latest",
125+
"@x402/evm": "latest",
126+
"@x402x/extensions": "latest"
125127
}
126128
}
127129
```
128130

129-
> 💡 **为什么使用修改版?** 我们对 x402 添加了 `paymentRequirements` 字段支持([PR #578](https://github.com/coinbase/x402/pull/578)),但该改进被官方推迟到 v2`@x402x/x402` 让你现在就能使用这些功能,且完全向后兼容
131+
> ⚠️ **注意**x402 v1 已废弃。请使用官方 x402 v2 包配合 `@x402x/extensions` 进行集成
130132
131133
### 开发者快速开始
132134

@@ -156,10 +158,10 @@ forge test
156158
cd contracts
157159
./deploy-contract.sh [网络] [选项] # 先配置 .env 文件
158160

159-
# 示例:
160-
./deploy-contract.sh base-sepolia --all --verify # 在测试网部署所有内容
161-
./deploy-contract.sh base --settlement --verify # 在主网部署 SettlementRouter
162-
./deploy-contract.sh xlayer --hooks --verify # 部署内置 hooks
161+
# 示例(使用 CAIP-2 网络标识符)
162+
./deploy-contract.sh eip155:84532 --all --verify # 在测试网部署所有内容 (Base Sepolia)
163+
./deploy-contract.sh eip155:8453 --settlement --verify # 在主网部署 SettlementRouter (Base)
164+
./deploy-contract.sh eip155:196 --hooks --verify # 部署内置 hooks (X-Layer)
163165
```
164166

165167
## 💡 使用示例

contracts/DEPLOYMENT.md

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ This guide explains how to deploy x402-exec contracts to different networks, wit
66

77
## 🌐 Supported Networks
88

9-
| Network | Chain ID | RPC Default | Block Explorer |
10-
|---------|----------|-------------|----------------|
11-
| Base Sepolia | 84532 | https://sepolia.base.org | https://sepolia.basescan.org |
12-
| Base Mainnet | 8453 | https://mainnet.base.org | https://basescan.org |
13-
| X-Layer Testnet | 1952 | https://testrpc.xlayer.tech | https://www.oklink.com/xlayer-test |
14-
| X-Layer Mainnet | 196 | https://rpc.xlayer.tech | https://www.oklink.com/xlayer |
9+
| Network | CAIP-2 Identifier | Chain ID | RPC Default | Block Explorer |
10+
|---------|------------------|----------|-------------|----------------|
11+
| Base Sepolia | `eip155:84532` | 84532 | https://sepolia.base.org | https://sepolia.basescan.org |
12+
| Base Mainnet | `eip155:8453` | 8453 | https://mainnet.base.org | https://basescan.org |
13+
| X-Layer Testnet | `eip155:1952` | 1952 | https://testrpc.xlayer.tech | https://www.oklink.com/xlayer-test |
14+
| X-Layer Mainnet | `eip155:196` | 196 | https://rpc.xlayer.tech | https://www.oklink.com/xlayer |
15+
16+
**Note:** CAIP-2 identifiers use the format `eip155:<chainId>` and are the recommended format for network identification in x402 v2.
1517

1618
## 🚀 Quick Start: Deploy to X-Layer Testnet
1719

@@ -65,9 +67,11 @@ Deploy both SettlementRouter and all showcase scenarios:
6567

6668
```bash
6769
cd contracts
68-
./deploy-contract.sh xlayer-testnet --all
70+
./deploy-contract.sh eip155:1952 --all
6971
```
7072

73+
**Note:** `eip155:1952` is the CAIP-2 identifier for X-Layer Testnet (chain ID 1952).
74+
7175
This will:
7276
1. ✅ Deploy `SettlementRouter` (built-in TransferHook available)
7377
2. ✅ Deploy `NFTMintHook` + `RandomNFT`
@@ -87,6 +91,7 @@ X_LAYER_TESTNET_SETTLEMENT_ROUTER_ADDRESS=0x...
8791
**Showcase server `.env`** (`examples/showcase/server/.env`):
8892
```bash
8993
# Copy from env.example first: cp env.example .env
94+
# Environment variables use CAIP-2 format for network identification
9095
X_LAYER_TESTNET_SETTLEMENT_ROUTER_ADDRESS=0x...
9196
X_LAYER_TESTNET_REVENUE_SPLIT_HOOK_ADDRESS=0x...
9297
X_LAYER_TESTNET_NFT_MINT_HOOK_ADDRESS=0x...
@@ -111,7 +116,7 @@ If you have `OKLINK_API_KEY` set and used `--verify` flag:
111116
### Deploy Only SettlementRouter
112117

113118
```bash
114-
./deploy-contract.sh xlayer-testnet --settlement
119+
./deploy-contract.sh eip155:1952 --settlement
115120
```
116121

117122
After deployment, save the address:
@@ -127,14 +132,14 @@ Built-in Hooks are protocol-level Hooks deployed once per network for universal
127132
Requires `[NETWORK]_SETTLEMENT_ROUTER_ADDRESS` to be set first:
128133

129134
```bash
130-
# Deploy all built-in hooks to X-Layer Testnet
131-
./deploy-builtin-hooks.sh xlayer-testnet --all
135+
# Deploy all built-in hooks to X-Layer Testnet (CAIP-2: eip155:1952)
136+
./deploy-builtin-hooks.sh eip155:1952 --all
132137

133138
# Deploy specific hooks
134-
./deploy-builtin-hooks.sh base-sepolia --transfer # TransferHook only
139+
./deploy-builtin-hooks.sh eip155:84532 --transfer # TransferHook only (Base Sepolia)
135140

136141
# Deploy with verification
137-
./deploy-builtin-hooks.sh xlayer-testnet --all --verify
142+
./deploy-builtin-hooks.sh eip155:1952 --all --verify
138143
```
139144

140145
**Current Built-in Hooks:**
@@ -148,22 +153,22 @@ Requires `SETTLEMENT_ROUTER_ADDRESS` to be set first:
148153

149154
```bash
150155
# Make sure X_LAYER_TESTNET_SETTLEMENT_ROUTER_ADDRESS is set in .env
151-
./deploy-contract.sh xlayer-testnet --showcase
156+
./deploy-contract.sh eip155:1952 --showcase
152157
```
153158

154159
### Deploy with Verification
155160

156161
```bash
157162
# Requires OKLINK_API_KEY in .env
158-
./deploy-contract.sh xlayer-testnet --all --verify
163+
./deploy-contract.sh eip155:1952 --all --verify
159164
```
160165

161166
### Non-Interactive Deployment
162167

163168
Skip confirmation prompts:
164169

165170
```bash
166-
./deploy-contract.sh xlayer-testnet --all --yes
171+
./deploy-contract.sh eip155:1952 --all --yes
167172
```
168173

169174
## 🔧 Legacy Deployment Scripts
@@ -184,17 +189,17 @@ Skip confirmation prompts:
184189

185190
### Migration Guide
186191

187-
**Before (Base Sepolia):**
192+
**Before (Base Sepolia - legacy):**
188193
```bash
189194
export RPC_URL=https://sepolia.base.org
190195
./deploy.sh
191196
./deploy-showcase.sh --all
192197
```
193198

194-
**After (Multi-Network):**
199+
**After (Multi-Network with CAIP-2):**
195200
```bash
196-
# Just specify the network!
197-
./deploy-contract.sh base-sepolia --all
201+
# Just specify the network using CAIP-2 format!
202+
./deploy-contract.sh eip155:84532 --all # Base Sepolia
198203
```
199204

200205
## 🌐 Deploy to Other Networks
@@ -206,8 +211,8 @@ export RPC_URL=https://sepolia.base.org
206211
BASE_RPC_URL=https://mainnet.base.org
207212
BASESCAN_API_KEY=your_api_key
208213

209-
# Deploy
210-
./deploy-contract.sh base --all --verify
214+
# Deploy (using CAIP-2 format: eip155:8453)
215+
./deploy-contract.sh eip155:8453 --all --verify
211216
```
212217

213218
### X-Layer Mainnet
@@ -217,8 +222,8 @@ BASESCAN_API_KEY=your_api_key
217222
X_LAYER_RPC_URL=https://rpc.xlayer.tech
218223
OKLINK_API_KEY=your_api_key
219224

220-
# Deploy
221-
./deploy-contract.sh xlayer --all --verify
225+
# Deploy (using CAIP-2 format: eip155:196)
226+
./deploy-contract.sh eip155:196 --all --verify
222227
```
223228

224229
## 🛠️ Troubleshooting
@@ -263,7 +268,7 @@ Cannot deploy showcase: SETTLEMENT_ROUTER_ADDRESS not set
263268
```
264269

265270
**Solution:** Either:
266-
1. Deploy SettlementRouter first: `./deploy-contract.sh xlayer-testnet --settlement`
271+
1. Deploy SettlementRouter first: `./deploy-contract.sh eip155:1952 --settlement`
267272
2. Or use `--all` to deploy everything at once
268273

269274
## 📝 Deployment Checklist
@@ -352,8 +357,8 @@ Always verify contracts on mainnet deployments:
352357
### How to Redeploy
353358

354359
```bash
355-
# Redeploy everything
356-
./deploy-contract.sh xlayer-testnet --all
360+
# Redeploy everything (using CAIP-2 format)
361+
./deploy-contract.sh eip155:1952 --all
357362

358363
```
359364

contracts/docs/builtin_hooks.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function execute(
7070
```json
7171
{
7272
"scheme": "exact",
73-
"network": "base-sepolia",
73+
"network": "eip155:84532",
7474
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
7575
"maxAmountRequired": "1010000",
7676
"payTo": "0xSettlementRouter...",
@@ -113,12 +113,12 @@ The additional ~8k gas provides:
113113

114114
#### Deployment Addresses
115115

116-
| Network | Address | Status |
117-
|---------|---------|--------|
118-
| Base Sepolia (Testnet) | [`0x6b486aF5A08D27153d0374BE56A1cB1676c460a8`](https://sepolia.basescan.org/address/0x6b486aF5A08D27153d0374BE56A1cB1676c460a8) | ✅ Active |
119-
| X-Layer Testnet | [`0x3D07D4E03a2aDa2EC49D6937ab1B40a83F3946AB`](https://www.oklink.com/xlayer-test/address/0x3D07D4E03a2aDa2EC49D6937ab1B40a83F3946AB) | ✅ Active |
120-
| Base Mainnet | TBD | 🚧 Pending Audit |
121-
| Ethereum Mainnet | TBD | 🚧 Pending Audit |
116+
| Network | CAIP-2 Identifier | Address | Status |
117+
|---------|------------------|---------|--------|
118+
| Base Sepolia (Testnet) | `eip155:84532` | [`0x6b486aF5A08D27153d0374BE56A1cB1676c460a8`](https://sepolia.basescan.org/address/0x6b486aF5A08D27153d0374BE56A1cB1676c460a8) | ✅ Active |
119+
| X-Layer Testnet | `eip155:1952` | [`0x3D07D4E03a2aDa2EC49D6937ab1B40a83F3946AB`](https://www.oklink.com/xlayer-test/address/0x3D07D4E03a2aDa2EC49D6937ab1B40a83F3946AB) | ✅ Active |
120+
| Base Mainnet | `eip155:8453` | TBD | 🚧 Pending Audit |
121+
| Ethereum Mainnet | `eip155:1` | TBD | 🚧 Pending Audit |
122122

123123
## Integration Guide
124124

contracts/docs/facilitator_guide.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,31 +506,46 @@ function handleSettlement(request):
506506
### Environment Variables
507507

508508
```bash
509-
# Standard Facilitator configuration
510-
RPC_URL_BASE_SEPOLIA=https://sepolia.base.org
511-
RPC_URL_BASE=https://mainnet.base.org
509+
# Standard Facilitator configuration (using CAIP-2 format for network identifiers)
510+
# CAIP-2 format: eip155:<chainId>
511+
RPC_URL_EIP155_84532=https://sepolia.base.org # Base Sepolia (chain ID 84532)
512+
RPC_URL_EIP155_8453=https://mainnet.base.org # Base Mainnet (chain ID 8453)
512513
PRIVATE_KEY=0x...
513514

514-
# SettlementRouter addresses (per network)
515-
SETTLEMENT_ROUTER_BASE_SEPOLIA=0x...
516-
SETTLEMENT_ROUTER_BASE=0x...
517-
SETTLEMENT_ROUTER_ETHEREUM=0x...
515+
# SettlementRouter addresses (per network, using CAIP-2 format)
516+
SETTLEMENT_ROUTER_EIP155_84532=0x... # Base Sepolia
517+
SETTLEMENT_ROUTER_EIP155_8453=0x... # Base Mainnet
518+
SETTLEMENT_ROUTER_EIP155_1=0x... # Ethereum Mainnet (chain ID 1)
518519
```
519520

520521
### Network Configuration
521522

522523
```json
523524
{
524525
"networks": {
525-
"base": {
526+
"eip155:8453": {
526527
"rpcUrl": "https://mainnet.base.org",
527528
"settlementRouter": "0x...",
528-
"chainId": 8453
529+
"chainId": 8453,
530+
"name": "Base Mainnet"
529531
},
530-
"base-sepolia": {
531-
"rpcUrl": "https://sepolia.base.org",
532+
"eip155:84532": {
533+
"rpcUrl": "https://sepolia.base.org",
532534
"settlementRouter": "0x...",
533-
"chainId": 84532
535+
"chainId": 84532,
536+
"name": "Base Sepolia"
537+
},
538+
"eip155:196": {
539+
"rpcUrl": "https://rpc.xlayer.tech",
540+
"settlementRouter": "0x...",
541+
"chainId": 196,
542+
"name": "X-Layer Mainnet"
543+
},
544+
"eip155:1952": {
545+
"rpcUrl": "https://testrpc.xlayer.tech",
546+
"settlementRouter": "0x...",
547+
"chainId": 1952,
548+
"name": "X-Layer Testnet"
534549
}
535550
}
536551
}

docs/development.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ pnpm run build
235235
cd contracts
236236
./deploy-contract.sh [NETWORK] [OPTIONS]
237237

238-
# Examples:
239-
./deploy-contract.sh xlayer-testnet --all # Deploy everything
240-
./deploy-contract.sh base-sepolia --settlement # Deploy SettlementRouter only
241-
./deploy-contract.sh xlayer --hooks --verify # Deploy hooks with verification
238+
# Examples (using CAIP-2 format):
239+
./deploy-contract.sh eip155:1952 --all # Deploy everything (X-Layer Testnet)
240+
./deploy-contract.sh eip155:84532 --settlement # Deploy SettlementRouter only (Base Sepolia)
241+
./deploy-contract.sh eip155:196 --hooks --verify # Deploy hooks with verification (X-Layer)
242242
```
243243

244244
### Cloud Deployment

examples/showcase/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ cp .env.example .env
9191

9292
```bash
9393
cd ../../contracts
94-
./deploy-contract.sh xlayer-testnet --all
94+
./deploy-contract.sh eip155:1952 --all
9595

96-
# Or deploy to other networks:
97-
# ./deploy-contract.sh base-sepolia --all --verify
98-
# ./deploy-contract.sh xlayer --settlement
96+
# Or deploy to other networks (using CAIP-2 format):
97+
# ./deploy-contract.sh eip155:84532 --all --verify # Base Sepolia
98+
# ./deploy-contract.sh eip155:196 --settlement # X-Layer Mainnet
99+
# ./deploy-contract.sh eip155:8453 --settlement # Base Mainnet
99100
```
100101

101102
After deployment, copy the output contract addresses and update `server/.env`:
@@ -360,12 +361,12 @@ These contracts need to be deployed for NFT Mint and Reward Points scenarios:
360361
For mainnet deployment, use the following commands and update the `client/.env` file with the deployed addresses:
361362

362363
```bash
363-
# Deploy to Base Mainnet
364+
# Deploy to Base Mainnet (CAIP-2: eip155:8453)
364365
cd contracts
365-
./deploy-contract.sh base --showcase --verify
366+
./deploy-contract.sh eip155:8453 --showcase --verify
366367

367-
# Deploy to X Layer Mainnet
368-
./deploy-contract.sh xlayer --showcase --verify
368+
# Deploy to X Layer Mainnet (CAIP-2: eip155:196)
369+
./deploy-contract.sh eip155:196 --showcase --verify
369370
```
370371

371372
After deployment, update your `examples/showcase/client/.env`:

0 commit comments

Comments
 (0)