← Back to templatesMaintainer pick
x402 Express Starter
An API that charges per request and an agent that pays for it, via the x402 standard on Cardano preprod.
New to x402 on Cardano? The x402 page has the full picture.
Get started
You need Node.js 20+ and a free Blockfrost project id. No browser wallet is needed, the starter generates its own.
- Scaffold the project into a new
my-appfolder:Terminalnpx giget@latest gh:cardano-foundation/developer-portal/examples/templates/x402-express my-app - Install dependencies, then generate a preprod wallet:Terminal
cd my-app npm install cp .env.example .env npm run wallet - Copy the mnemonic into .env, set your Blockfrost project id and a seller address, and fund the printed address at the preprod faucet.
- Run it, in two terminals:Terminal
npm run facilitator npm run demo
The agent pays the route and the terminal prints the receipt with an explorer link. Expect 20 to 60 seconds for on-chain confirmation.
Read the template README on GitHubSpotted something off?
This directory is open source. Open a pull request to update or correct this entry.