x402 Endpoints

Pay-per-use APIs on Stacks blockchain

HTTP 402 Payment Required Protocol

Coin Refill

0.1 STX

Instantly refill any Stacks wallet with STX or sBTC. Perfect for testing, onboarding new users, or topping up wallets programmatically.

POST https://coin-refill.p-d07.workers.dev/refill
Accepts:
STX sBTC
Category: utility

sBTC Yield Calculator

0.001 STX

Calculate potential yield on sBTC deposits. Returns APY projections based on current DeFi rates and historical performance.

POST https://sbtc-yield-x402.p-d07.workers.dev/calculate-yield
Accepts:
STX
Category: defi

sBTC Yield Vault - Deposit

0.003 STX

Deposit sBTC into a yield-generating vault. Automatically compounds interest and manages positions across DeFi protocols.

POST https://sbtc-yield-vault.p-d07.workers.dev/deposit
Accepts:
STX sBTC
Category: defi

sBTC Yield Vault - Withdraw

0.003 STX

Withdraw sBTC plus accrued yield from the vault. Includes automatic position unwinding and fee calculation.

POST https://sbtc-yield-vault.p-d07.workers.dev/withdraw
Accepts:
STX sBTC
Category: defi

Quick Start with SDK

// Install: npm install @pbtc21/x402-client
import { X402Client } from "@pbtc21/x402-client";

const client = new X402Client({
  mnemonic: "your wallet mnemonic",
  network: "mainnet"
});

// Call any endpoint - payment is automatic
const result = await client.call(
  "https://coin-refill.p-d07.workers.dev/refill",
  {
    body: { token: "STX", amount: 1000000, recipient: "SP..." }
  }
);

console.log(result.data, result.payment.txid);