Skip to content

Commit b12a125

Browse files
authored
Merge branch 'main' into starknet
2 parents 0067ba1 + aff487f commit b12a125

File tree

82 files changed

+5754
-5161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5754
-5161
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# x402 payments protocol
22

3-
> "1 line of code to accept digital dollars. No fee, 2 second settlement, $0.001 minimum payment."
3+
> "1 line of code to accept digital dollars. No fees, 2-second settlement, $0.001 minimum payment."
44
55
```typescript
66
app.use(
77
// How much you want to charge, and where you want the funds to land
88
paymentMiddleware("0xYourAddress", { "/your-endpoint": "$0.01" })
99
);
10-
// That's it! See examples/typescript/servers/express.ts for a complete example. Instruction below for running on base-sepolia.
10+
// That's it! See examples/typescript/servers/express/index.ts for a complete example. Instruction below for running on base-sepolia.
1111
```
1212

1313
## Philosophy

examples/typescript/clients/axios/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ async function main(): Promise<void> {
3636
const response = await api.get(endpointPath);
3737
console.log(response.data);
3838

39-
const paymentResponse = decodeXPaymentResponse(response.headers["x-payment-response"]);
40-
console.log(paymentResponse);
39+
const paymentResponseHeader = response.headers["x-payment-response"];
40+
if (paymentResponseHeader) {
41+
const paymentResponse = decodeXPaymentResponse(paymentResponseHeader);
42+
console.log(paymentResponse);
43+
}
4144
}
4245

4346
main();

examples/typescript/clients/fetch/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ async function main(): Promise<void> {
3030
const body = await response.json();
3131
console.log(body);
3232

33-
const paymentResponse = decodeXPaymentResponse(response.headers.get("x-payment-response")!);
34-
console.log(paymentResponse);
33+
const paymentResponseHeader = response.headers.get("x-payment-response");
34+
if (paymentResponseHeader) {
35+
const paymentResponse = decodeXPaymentResponse(paymentResponseHeader);
36+
console.log(paymentResponse);
37+
}
3538
}
3639

3740
main().catch(error => {

examples/typescript/dynamic_agent/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"hono": "^4.7.7",
2121
"llamaindex": "^0.10.2",
2222
"viem": "^2.28.3",
23-
"x402": "^0.2.0",
24-
"x402-axios": "^0.1.0",
25-
"x402-hono": "^0.1.0",
23+
"x402": "workspace:*",
24+
"x402-axios": "workspace:*",
25+
"x402-hono": "workspace:*",
2626
"zod": "^3.24.3"
2727
},
2828
"devDependencies": {

examples/typescript/fullstack/auth_based_pricing/backend.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
Network as X402Network,
1212
Resource as X402Resource,
1313
PaymentPayload,
14-
settleResponseHeader
14+
settleResponseHeader,
15+
ERC20TokenAmount
1516
} from 'x402/types';
1617
import { useFacilitator } from 'x402/verify';
1718
import { exact } from 'x402/schemes';
@@ -70,6 +71,7 @@ function createExactPaymentRequirements(
7071
throw new Error(`Failed to process price: ${atomicAmountForAsset.error}`);
7172
}
7273
const { maxAmountRequired, asset } = atomicAmountForAsset;
74+
const erc20Asset = asset as ERC20TokenAmount["asset"];
7375
return {
7476
scheme: "exact",
7577
network,
@@ -79,9 +81,9 @@ function createExactPaymentRequirements(
7981
mimeType: "application/json", // Content type of the protected resource
8082
payTo: BUSINESS_WALLET_ADDRESS,
8183
maxTimeoutSeconds: 60, // Client has 60s to complete payment after challenge
82-
asset: asset.address, // e.g., USDC contract address on the specified network
84+
asset: erc20Asset.address, // e.g., USDC contract address on the specified network
8385
outputSchema: undefined, // Optional: JSON schema for the expected response after payment
84-
extra: { name: asset.eip712.name, version: asset.eip712.version }, // EIP-712 domain info for the payment asset
86+
extra: { name: erc20Asset.eip712.name, version: erc20Asset.eip712.version }, // EIP-712 domain info for the payment asset
8587
};
8688
}
8789

examples/typescript/fullstack/auth_based_pricing/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
"author": "Your Name",
2424
"license": "MIT",
2525
"dependencies": {
26-
"@coinbase/x402": "^0.3.3",
26+
"@coinbase/x402": "workspace:*",
2727
"@hono/node-server": "^1.11.2",
2828
"dotenv": "^16.4.5",
2929
"hono": "^4.4.0",
3030
"node-fetch": "^3.3.2",
3131
"siwe": "^2.3.2",
3232
"viem": "^2.13.8",
33-
"x402": "^0.3.2",
34-
"x402-fetch": "^0.3.2",
35-
"x402-hono": "^0.3.2"
33+
"x402": "workspace:*",
34+
"x402-fetch": "workspace:*",
35+
"x402-hono": "workspace:*"
3636
},
3737
"devDependencies": {
3838
"@types/node": "^20.14.2",

examples/typescript/fullstack/browser-wallet-example/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ Learn more at [x402.org](https://x402.org) or check out the [GitHub repository](
3636
### 1. Install Dependencies
3737

3838
```bash
39-
npm run install:all
39+
pnpm install:all
4040
```
4141

4242
### 2. Configure the Server
4343

44-
Create `server/.env`:
44+
Create `.env`:
4545
```env
4646
FACILITATOR_URL=https://x402.org/facilitator
4747
NETWORK=base-sepolia
@@ -52,7 +52,7 @@ PORT=3001
5252
### 3. Run Both Server and Client
5353

5454
```bash
55-
npm run dev
55+
pnpm dev
5656
```
5757

5858
This starts:

0 commit comments

Comments
 (0)