Skip to main content
← Back to templates
Maintainer 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.

  1. Scaffold the project into a new my-app folder:
    Terminal
    npx giget@latest gh:cardano-foundation/developer-portal/examples/templates/x402-express my-app
  2. Install dependencies, then generate a preprod wallet:
    Terminal
    cd my-app
    npm install
    cp .env.example .env
    npm run wallet
  3. Copy the mnemonic into .env, set your Blockfrost project id and a seller address, and fund the printed address at the preprod faucet.
  4. 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 GitHub

Spotted something off?

This directory is open source. Open a pull request to update or correct this entry.