Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
aee0160
chore: refactor x402 types, make it extensible to other schemes
tmigone Jul 15, 2025
9ab2331
wip: implement deferred scheme
tmigone Jul 15, 2025
39f2eca
feat: implement x402 deferred scheme
tmigone Jul 16, 2025
aac3af4
fix: upstream dependencies previously assuming exact as the only scheme
tmigone Jul 16, 2025
65dd41e
chore: better zod types
tmigone Jul 17, 2025
e934145
chore: rename voucher value to valueAggregate
tmigone Jul 17, 2025
5c35c7b
fix: implement proper value check for vouchers on verify
tmigone Jul 17, 2025
a63d0e1
fix: remove throw empty error pattern
tmigone Jul 17, 2025
40e5ed8
fix: when verifying check escrow balance not erc20 balance
tmigone Jul 17, 2025
38a83fc
chore: rename and move scheme name definitions
tmigone Jul 17, 2025
02722ab
fix: clearer verification invalid reasons for deferred scheme
tmigone Jul 17, 2025
103af81
chore: add TODO comment about simulating tx on verify
tmigone Jul 17, 2025
8527fdc
chore: ensure consistent usage of buyer over from in deferred scheme
tmigone Jul 17, 2025
60d2f16
fix: more clear reject reason for verify fn
tmigone Jul 17, 2025
14f9363
chore: rename voucher verification function
tmigone Jul 17, 2025
377930f
feat: verify client network matches voucher network
tmigone Jul 18, 2025
3314e57
fix: remove unreachable code
tmigone Jul 18, 2025
d6eb04d
chore: comment clarification
tmigone Jul 18, 2025
cbaba30
fix: clean up verification code, ensure client verifies aggregate vou…
tmigone Jul 18, 2025
51566f4
test: add tests for verification steps on deferred scheme
tmigone Jul 18, 2025
c1c34d4
feat(x402-fetch): implement deferred scheme fetch wrapper (#4)
cmwhited Jul 21, 2025
adbc243
feat(x402-fetch): update README to include api for wrapFetchWithDefer…
cmwhited Jul 21, 2025
52e96cc
fix: change id re-usability behavior
tmigone Jul 18, 2025
d5e519c
feat: add expiry to voucher, add some more tests as well
tmigone Jul 18, 2025
65b1cda
fix: verify function was not returning verification results properly
tmigone Jul 18, 2025
8ff7e2c
feat(x402-axios): implement a deferred payment scheme axiox response …
cmwhited Jul 22, 2025
7842b1d
fix: use latest escrow abi
tmigone Jul 22, 2025
71a87a3
chore: lint
tmigone Jul 22, 2025
436f12a
fix: voucher signature structure
tmigone Jul 22, 2025
a48463b
test: amend tests due to latest changes
tmigone Jul 22, 2025
443548a
wip: resource server
tmigone Jul 30, 2025
89ccd96
feat: add X-PAYMENT-BUYER header logic to fetch client
tmigone Jul 31, 2025
c46bafd
feat: add deferred payment middleware to express package
tmigone Jul 31, 2025
35666a2
fix: better middleware for deferred
tmigone Jul 31, 2025
5103c9e
fix: add missing type
tmigone Jul 31, 2025
e8afde4
feat(x402-axios): add X-BUYER-header to axios request interceptor (#11)
cmwhited Jul 31, 2025
3c905fc
feat: implement split verify for deferred
tmigone Aug 13, 2025
989fa11
docs: add Python deferred payment scheme implementation plan
pcarranzav Jul 31, 2025
2f35450
feat: add deferred payment scheme support to Python client
pcarranzav Jul 31, 2025
8e7386b
chore: add signed voucher type
tmigone Aug 14, 2025
229ac4b
wip: merge gateway with facilitator
tmigone Aug 20, 2025
05992b2
feat: introduce previous gateway behavior into core deferred scheme
tmigone Aug 21, 2025
8b2f556
refactor: deferred verify steps to allow deferred settlement to run s…
tmigone Aug 21, 2025
efeda4c
feat: implement full deferred api
tmigone Aug 22, 2025
206c115
docs: minor comment
tmigone Aug 22, 2025
f9c69a9
feat: complete gateway migration
tmigone Aug 25, 2025
6ecab71
chore: fix network getter name
tmigone Aug 26, 2025
2642375
test: fix deferred tests
tmigone Aug 26, 2025
2955605
chore: lint code
tmigone Aug 26, 2025
4e55b66
test: add tests to useDeferred facilitator
tmigone Aug 26, 2025
654936e
test: add id generation tests for deferred
tmigone Aug 26, 2025
e702923
test: add deferred tests to useFacilitator
tmigone Aug 26, 2025
466a7d6
test: add tests for verify deferred, fix some bugs
tmigone Aug 26, 2025
f745715
test: add tests for deferred payment utils
tmigone Aug 26, 2025
5b63422
test: add test coverage for facilitator deferred logic
tmigone Aug 26, 2025
b607b88
feat: add deferred server helper with test
tmigone Aug 27, 2025
5f54c8f
fix: ensure voucher exists in store before settling
tmigone Aug 27, 2025
8adf13a
chore: add missing error definition
tmigone Aug 27, 2025
5e2e572
test: add integration tests, fix several bugs
tmigone Aug 27, 2025
e7fe85d
chore: update x402-express library to latest design
tmigone Aug 27, 2025
bb9e018
feat: add verifyAndStore fn to facilitator client
tmigone Aug 27, 2025
41aeb35
fix: use correct endpoint for verify and store deferred
tmigone Aug 27, 2025
94c833f
test: fix verify and store test
tmigone Aug 27, 2025
2d4d6a9
fix: simpliufy voucher store creatgion
tmigone Aug 28, 2025
4e2d0d1
feat: add get collections to facilitator client
tmigone Aug 28, 2025
d302d6b
fix: bug in mock store voucher
tmigone Aug 28, 2025
4e17595
fix: issues after resyncing with main
tmigone Sep 25, 2025
61779cf
fix: make sure x402 test suite passes
tmigone Sep 25, 2025
892aa6e
tests: fix x402-axios tests after resync
tmigone Sep 25, 2025
3f5f15a
feat: add deferred scheme specifications
pcarranzav Aug 16, 2025
ad8bb6b
refactor: consolidate voucher spec and merge gateway into facilitator
pcarranzav Aug 18, 2025
3ba04a2
fix: ensure deferred scheme supports smart account signing
tmigone Sep 26, 2025
c8ad37f
docs: add deferred specification documents
tmigone Sep 29, 2025
94c51ec
docs: add deferred facilitator spec
tmigone Sep 29, 2025
0c93065
feat: add DeferredPaymentEscrow
pcarranzav Sep 29, 2025
d4282e4
Merge pull request #2 from edgeandnode/feat/x402-deferred-escrow-cont…
tmigone Sep 29, 2025
1553786
docs: update deferred spec
tmigone Sep 29, 2025
4ce4ee2
Merge branch 'feat/x402-deferred' of github.com:edgeandnode/x402 into…
tmigone Sep 29, 2025
f5b3654
fix: integrate deferred contract properly
tmigone Sep 29, 2025
00136c0
docs: add deferred sequencing
tmigone Sep 29, 2025
12550e9
feat(x402-express): support both facilitator and local voucher stores
tmigone Oct 1, 2025
2600ac7
feat(examples): add deferred routes to example resource server
tmigone Oct 1, 2025
ff7d38b
fix: ensure correct headers are set and returned in deferred
tmigone Oct 1, 2025
76583d5
feat(examples): add deferred client examples
tmigone Oct 1, 2025
a11b785
feat(examples): add deferred facilitator example using in memory vouc…
tmigone Oct 2, 2025
6780087
test: fix axios test
tmigone Oct 2, 2025
f16d638
test: add tests for deferred middleware in x402-express package
tmigone Oct 2, 2025
b7c2848
feat(deferred): add support to x402 package for deposit with auth flow
tmigone Oct 2, 2025
4ff377a
test: fix deferred integration tests
tmigone Oct 3, 2025
06217ad
test: make deferred integration tests less brittle
tmigone Oct 3, 2025
b1c2f94
feat(deferred): add facilitator logic to execute deposit with auth
tmigone Oct 3, 2025
87e5645
feat(deferred): make permit optional in depositWIthAuth flow
tmigone Oct 3, 2025
518168c
wip(deferred): implement depositwithauth flow changes for components
tmigone Oct 10, 2025
7761157
feat(deferred): wire client libs to support deposit with auth
tmigone Oct 13, 2025
6bad2ee
feat(deferred): client verify balance before signing deposit auth
tmigone Oct 13, 2025
4d1854d
test: fix deferred tests
tmigone Oct 13, 2025
e7648f8
test: fix tests
tmigone Oct 14, 2025
de2f557
test: add more tests for deposit with auth
tmigone Oct 14, 2025
685816c
chore: lint
tmigone Oct 14, 2025
dbad6d1
chore: remove python deferred lib
tmigone Oct 14, 2025
797383b
docs: update with latest deposit with auth changes
tmigone Oct 14, 2025
fc26594
feat(deferred): add escrow flushing functionality
tmigone Oct 15, 2025
f5e5d0e
feat(deferred): support flushing all escrow accounts at once
tmigone Oct 15, 2025
f749d5f
docs: update deferred facilitator spec
tmigone Oct 15, 2025
f28cb26
refactor(deferred): refactor deposit with auth verification
tmigone Oct 15, 2025
12ca3c3
chore(deferred): make reverification skippable for settleVoucher and …
tmigone Oct 15, 2025
8559a9e
chore(deferred): dont allow settleVoucher to accept a depositAuth
tmigone Oct 15, 2025
0871d86
refactor(deferred): reduce contract reads with verification data gett…
tmigone Oct 15, 2025
c71d15f
test(deferred): remove dead code
tmigone Oct 16, 2025
9c46c8e
refactor(deferred): move server functionality to x402 server code
tmigone Oct 16, 2025
4e9c169
chore: update deferred spec
tmigone Oct 16, 2025
54a6684
refactor(deferred): consolidate facilitator calls from the server
tmigone Oct 16, 2025
bde440b
chore(deferred): remove x402-fetch incomplete implementation
tmigone Oct 16, 2025
e3e2c54
Merge branch 'main' into feat/x402-deferred
tmigone Oct 16, 2025
d33da38
test: fix x402-axios test, adjust expected object
tmigone Oct 16, 2025
20a365f
fix(deferred): use latest contract, no body on get requests
tmigone Oct 16, 2025
43d18f8
fix(deferred): consider thawing funds when collecting
tmigone Oct 17, 2025
54fab6b
chore(deferred): fix tests and improve error handling for useDeferred…
tmigone Oct 17, 2025
6e1d47d
Merge branch 'main' into feat/x402-deferred
tmigone Oct 17, 2025
65f7755
chore: remove spec documentation
tmigone Oct 22, 2025
a9badd7
Merge branch 'main' into feat/x402-deferred-implementation
tmigone Oct 22, 2025
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ proxy
.env
__pycache__/
**/.DS_Store
cache/
out/
lcov.info
broadcast/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "solidity/deferred-escrow/lib/openzeppelin-contracts"]
path = solidity/deferred-escrow/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "solidity/deferred-escrow/lib/forge-std"]
path = solidity/deferred-escrow/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "solidity/deferred-escrow/lib/safe-singleton-deployer-sol"]
path = solidity/deferred-escrow/lib/safe-singleton-deployer-sol
url = https://github.com/wilsoncusack/safe-singleton-deployer-sol
67 changes: 67 additions & 0 deletions examples/typescript/clients/axios/deferred.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import axios from "axios";
import { config } from "dotenv";
import {
withDeferredPaymentInterceptor,
decodeXPaymentResponse,
createSigner,
type Hex,
} from "x402-axios";

config();

const privateKey = process.env.PRIVATE_KEY as Hex | string;
const baseURL = process.env.RESOURCE_SERVER_URL as string; // e.g. https://example.com
const endpointPath = process.env.ENDPOINT_PATH as string; // e.g. /weather

if (!baseURL || !privateKey || !endpointPath) {
console.error("Missing required environment variables");
process.exit(1);
}

/**
* This example shows how to use the x402-axios package to make a request to a resource server that requires a payment
* using deferred scheme.
*
* To run this example, you need to set the following environment variables:
* - PRIVATE_KEY: The private key of the signer (buyer)
* - RESOURCE_SERVER_URL: The URL of the resource server
* - ENDPOINT_PATH: The path of the endpoint to call on the resource server
*
*/
async function main(): Promise<void> {
const signer = await createSigner("base-sepolia", privateKey);
const api = withDeferredPaymentInterceptor(
axios.create({
baseURL,
}),
signer,
// [
// {
// asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
// assetDomain: {
// name: "USDC",
// version: "2",
// },
// threshold: "996000",
// amount: "100",
// },
// ],
);

try {
const response = await api.get(endpointPath);
console.log(response.data);

const xPaymentHeader = response.config.headers["X-PAYMENT"];
const paymentPayload = JSON.parse(Buffer.from(xPaymentHeader, "base64").toString("utf-8"));
console.log("Deferred voucher details:");
console.log(paymentPayload.payload.voucher);

const paymentResponse = decodeXPaymentResponse(response.headers["x-payment-response"]);
console.log(paymentResponse);
} catch (error) {
console.error(error);
}
}

main();
3 changes: 2 additions & 1 deletion examples/typescript/clients/axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "module",
"scripts": {
"dev": "tsx index.ts",
"dev:deferred": "tsx deferred.ts",
"dev:multi-network-signer": "tsx multi-network-signer.ts",
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
Expand All @@ -27,4 +28,4 @@
"tsx": "^4.7.0",
"typescript": "^5.3.0"
}
}
}
11 changes: 8 additions & 3 deletions examples/typescript/clients/axios/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"strict": true,
"resolveJsonModule": true,
"baseUrl": ".",
"types": ["node"]
"types": [
"node"
]
},
"include": ["index.ts"]
}
"include": [
"index.ts",
"deferred.ts"
]
}
2 changes: 1 addition & 1 deletion examples/typescript/facilitator/.env-local
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
EVM_PRIVATE_KEY=0xYourPrivateKey
SVM_PRIVATE_KEY=base58EncodedSolanaPrivateKey
PORT=3002
PORT=3002
Loading