npx skills add ...
npx skills add hedera-dev/hedera-skills --skill x402-payments
x402 pay-per-use payments on Hedera. Use when gating HTTP resources behind native HBAR payments, wiring a self-hosted Hedera facilitator (verify/settle), building x402ResourceServer / ExactHederaScheme flows, or integrating WalletConnect payment retries (PAYMENT-REQUIRED → PAYMENT-SIGNATURE).
npx skills add hedera-dev/hedera-skills --skill x402-payments
Pay-per-use pattern: store protected bytes off-chain, record access terms separately (on-chain or config), gate HTTP resources with HTTP 402 + a self-hosted Hedera facilitator that verifies and settles native HBAR transfers.
The resource server never holds facilitator keys. Settlement uses a funded ECDSA fee-payer account on the facilitator process.
| Piece | Role |
|---|---|
| Payment asset | "0.0.0" — native HBAR; amounts in tinybars (1 HBAR = 1e8) |
| Resource server | @x402/core + ExactHederaScheme → talks to facilitator over HTTP |
| Facilitator | GET /supported, POST /verify, POST /settle, GET /health |
| Client | Request → read 402 → sign → retry with PAYMENT-SIGNATURE (legacy X-PAYMENT also accepted) |
| Wallet | ECDSA Hedera account (e.g. HashPack via WalletConnect / UniversalProvider) |
See references/examples.md for server/client snippets. See references/facilitator.md for env vars and settle semantics.
Hedera x402 settles with native TransferTransactions. The buyer partially signs (authorize buyer → seller). The facilitator must:
/supported)SUCCESSRequires FACILITATOR_ACCOUNT_ID + FACILITATOR_PRIVATE_KEY on a funded ECDSA account — separate from deployer/seller keys. Do not put that key in the resource-server process.
Payment requirements use tinybars. Convert in UIs with 8-decimal helpers; never float.
payTo = seller Hedera account id, amount in tinybars, asset 0.0.0, network (e.g. hedera:testnet)PAYMENT-REQUIRED header + JSON bodyverifyPayment then settlePayment; only on success return resource + PAYMENT-RESPONSEMachine-to-machine clients use a key-based signer instead of a browser wallet.
X402_NETWORK (e.g. hedera:testnet)0.0.0/health OK before testing paid requestspayTo is a Hedera account id string (e.g. 0.0.1234), not an EVM address@x402/hederaconst facilitator = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
const server = new x402ResourceServer(facilitator)
.register(X402_NETWORK, new ExactHederaScheme());
await server.initialize(); // pulls fee-payer from /supportedconst first = await fetch(resourceUrl);
if (first.status === 402) {
const paymentRequired = httpClient.getPaymentRequiredResponse(...);
const payload = await httpClient.createPaymentPayload(paymentRequired);
const headers = httpClient.encodePaymentSignatureHeader(payload);
const paid = await fetch(resourceUrl, { headers });
// processResponse → resource + settle receipt
}