Skip to content

Commit 0d2fb60

Browse files
committed
Server now accepts both eip-3009 and erc-7710 payments
1 parent 0405c20 commit 0d2fb60

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/x402-example/src/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ async function main() {
114114
},
115115
});
116116

117-
const httpClient = new x402HTTPClient(new x402Client().register(
118-
'eip155:*',
119-
erc7710Client
120-
));
117+
const coreClient = new x402Client().register('eip155:*', erc7710Client);
118+
119+
const httpClient = new x402HTTPClient(coreClient);
121120

122121
const fetchWithPayment = wrapFetchWithPayment(fetch, httpClient);
123122

packages/x402-example/src/server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { config } from 'dotenv';
22
import express from 'express';
33
import { HTTPFacilitatorClient } from '@x402/core/server';
44
import { paymentMiddleware, x402ResourceServer } from '@x402/express';
5-
import { ExactEvmScheme } from '@x402/evm/exact/server';
65
import {
76
type Network,
87
} from '@x402/core/types';
@@ -24,6 +23,10 @@ const network = (process.env.NETWORK ?? 'eip155:84532') as Network;
2423
const port = Number(process.env.PORT ?? 4021);
2524
const price = '1000' as const;
2625
const acceptedToken = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as const;
26+
const acceptedTokenEip712Domain = {
27+
name: 'USD Coin',
28+
version: '2',
29+
} as const;
2730

2831
const facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });
2932
const app = express();
@@ -55,6 +58,7 @@ app.use(
5558
},
5659
extra: {
5760
assetTransferMethod: 'eip3009',
61+
...acceptedTokenEip712Domain,
5862
},
5963
},
6064
],
@@ -76,6 +80,6 @@ app.get('/random', (_req: unknown, res: { type: (value: string) => { send: (valu
7680

7781
app.listen(port, () => {
7882
console.log(
79-
`x402 ERC-7710 example server listening on http://localhost:${port}/random`,
83+
`x402 ERC-7710 + EIP-3009 example server listening on http://localhost:${port}/random`,
8084
);
8185
});

0 commit comments

Comments
 (0)