A realistic two-process Tempo charge example for mpp-go, mirroring the
separate server/client setup from mpp-rs.
The server exposes three endpoints:
GET /api/health— Free, returns{"status":"ok"}GET /api/ping— Costs0.01, returns{"pong":true}GET /api/fortune— Costs1.00, returns a random fortune and payer DID
Start the local Tempo devnet first:
docker compose up -dgo run ./examples/basic/serverThe server listens on http://localhost:3000.
It generates and funds a fresh merchant address on startup, similar to the
mpp-rs basic example.
In another terminal:
go run ./examples/basic/clientThe client automatically handles the 402 flow, pays the challenge, retries, and prints the returned receipt.
| Variable | Default | Description |
|---|---|---|
PRIVATE_KEY |
bundled devnet payer key | Client private key used to pay |
BASE_URL |
http://localhost:3000 |
Base URL for the example server |
TEMPO_RPC_URL |
http://127.0.0.1:8545 |
Tempo RPC endpoint |
MPP_SECRET_KEY |
basic-example-secret |
Secret key used to sign server challenges |