Open facilitator for the x402 protocol — pay-per-request APIs with stablecoins, cross-chain, zero intermediaries.
Server returns HTTP 402 with payment requirements and wallet address
Client sends stablecoin payment through Blocky402 facilitator
Original request retried with a PAYMENT-SIGNATURE header, API responds with data
Built on HTTP 402 standard, no proprietary middleware needed
On-chain verification, no custody, transparent settlement
Self-hostable, auditable, community-driven development
Polygon Amoy, Solana Devnet, and Hedera Testnet on hosted testnet; Hedera Mainnet on hosted mainnet; additional EVM and Solana chains when self-hosting
// Node.js client — x402 v2, Hedera. The client never calls Blocky402 directly:
// it hits a protected resource server, and @x402/fetch handles the 402 →
// sign → retry-with-PAYMENT-SIGNATURE → decode-settlement dance. Blocky402
// acts as the facilitator behind that resource server.
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client, x402HTTPClient } from '@x402/core/client';
import { ExactHederaScheme } from '@x402/hedera/exact/client';
import { createClientHederaSigner, PrivateKey } from '@x402/hedera';
// 1. Build a Hedera client signer (payer account + ECDSA key).
const network = process.env.HEDERA_NETWORK || 'hedera:testnet';
const hederaSigner = createClientHederaSigner(
process.env.HEDERA_ACCOUNT_ID!, // e.g. '0.0.7326075'
PrivateKey.fromStringECDSA(process.env.HEDERA_PRIVATE_KEY!),
{ network },
);
// 2. Register the Hedera scheme on a x402Client. Add @x402/evm or @x402/svm
// schemes here too if you want a single client to handle multiple families.
// HBAR is not a default asset, so the client must opt in to it. Without
// setSpendControls it refuses to pay. The cap here equals the price (0.001 HBAR).
const client = new x402Client()
.register('hedera:*', new ExactHederaScheme(hederaSigner))
.setSpendControls({
allowedAssets: [{ network, asset: '0.0.0', maxAmountPerPayment: '100000' }],
});
// 3. Wrap fetch. fetchWithPayment retries 402 responses with a PAYMENT-SIGNATURE
// header automatically; httpClient lets you decode the settlement response.
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const httpClient = new x402HTTPClient(client);
// 4. Hit the protected resource. One call — no manual verify/settle.
const response = await fetchWithPayment('https://api.example.com/protected', {
method: 'GET',
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status} ${await response.text()}`);
}
const data = await response.json();
// 5. (Optional) Inspect the on-chain settlement the facilitator performed.
// getPaymentSettleResponse throws if PAYMENT-RESPONSE is absent, e.g. when the
// resource did not require payment, so check for the header first.
if (response.headers.get('PAYMENT-RESPONSE')) {
const settlement = httpClient.getPaymentSettleResponse(
(name) => response.headers.get(name),
);
console.log('Transaction:', settlement.transaction); // 0.0.<feePayer>@<seconds>.<nanos>
}
console.log('Data:', data);Yes. Blocky402 is an independent, open-source implementation that operates alongside other x402 facilitators.
Yes. Run your own instance using Docker or Node.js. See the documentation for setup instructions.
Hosted testnet: Polygon Amoy, Solana Devnet, and Hedera Testnet. Hosted mainnet: Hedera Mainnet. Additional chains are available when self-hosting. See networks documentation for details.
Yes! Testnet is fully operational and open access (no API key required). Perfect for development and testing. See testnet guide.