Quick Start
Get up and running with Conduit x402 payments in under 5 minutes.
1
Set facilitator URL
Add the Conduit facilitator URL to your environment variables:
FACILITATOR_URL=https://getconduit.io/api/facilitator2
Install x402 middleware
Install the x402 package for your framework:
npm install @x402/expressConfigure the middleware in your server:
import express from 'express'
import { x402Middleware } from '@x402/express'
const app = express()
app.use(x402Middleware({
facilitatorUrl: process.env.FACILITATOR_URL,
network: 'solana', // or 'solana-devnet'
}))
app.get('/api/data', (req, res) => {
res.json({ message: 'This endpoint requires payment!' })
})
app.listen(3000)3
Make paid requests
Use the x402 client to make paid API calls:
import { x402Fetch } from '@x402/client'
const response = await x402Fetch('http://localhost:3000/api/data', {
wallet: myWallet, // Your Solana wallet
})
const data = await response.json()
console.log(data)