Skip to content
Open
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
66 changes: 65 additions & 1 deletion docs/getting-started/quickstart-for-sellers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ There are pre-configured examples available in the x402 repo for both [Node.js](
npm install @x402/hono @x402/core @x402/evm @x402/svm
```
</Tab>
<Tab title="Fastify">
Install the [x402 Fastify middleware package](https://www.npmjs.com/package/@x402/fastify).

```bash
npm install @x402/fastify @x402/core @x402/evm @x402/svm
```
</Tab>
<Tab title="Go">
Add the x402 Go module to your project:

Expand Down Expand Up @@ -299,6 +306,63 @@ Integrate the payment middleware into your application. You will need to provide
serve({ fetch: app.fetch, port: 4021 });
```
</Tab>
<Tab title="Fastify">
Full example in the repo [here](https://github.com/coinbase/x402/tree/main/examples/typescript/servers/fastify).

```typescript
import Fastify from "fastify";
import { paymentMiddleware, x402ResourceServer } from "@x402/fastify";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { ExactSvmScheme } from "@x402/svm/exact/server";
import { HTTPFacilitatorClient } from "@x402/core/server";

const app = Fastify();
const evmAddress = "0xYourEvmAddress";
const svmAddress = "YourSolanaAddress";

const facilitatorClient = new HTTPFacilitatorClient({
url: "https://x402.org/facilitator"
});

paymentMiddleware(
app,
{
"GET /weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "eip155:84532", // Base Sepolia
payTo: evmAddress,
},
{
scheme: "exact",
price: "$0.001",
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", // Solana Devnet
payTo: svmAddress,
},
],
description: "Weather data",
mimeType: "application/json",
},
},
new x402ResourceServer(facilitatorClient)
.register("eip155:84532", new ExactEvmScheme())
.register("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", new ExactSvmScheme()),
);

app.get("/weather", async () => {
return {
report: {
weather: "sunny",
temperature: 70,
},
};
});

app.listen({ port: 4021 });
```
</Tab>
<Tab title="Go (Gin)">
Full example in the repo [here](https://github.com/coinbase/x402/tree/main/examples/go/servers/gin).

Expand Down Expand Up @@ -686,7 +750,7 @@ Change from testnet to mainnet network identifiers:
For multi-network support, register both EVM and SVM schemes:

<Tabs>
<Tab title="Node.js">
<Tab title="Express / Hono / Fastify">
```typescript
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { ExactSvmScheme } from "@x402/svm/exact/server";
Expand Down
Loading