acdf7bed035db28c134f164343caea739f85710c7124f653959e36290f692367UQC0xYjlVBm1-I6qXH9Idzc7sXlEoO7IPqdmH2HNTVdyu7p9To pay for endpoints, open a TON payment channel with this public key as party B. The server accepts channels dynamically — no pre-registration needed.
GET /api/premium402 + PAYMENT-REQUIRED header (includes price + server public key)PAYMENT-SIGNATURE header200 OKcurl http://${location.host}/api/time
curl -v http://${location.host}/api/premium
# → 402 Payment Required + PAYMENT-REQUIRED header
Request: GET /api/premium
Response: 402
Header: PAYMENT-REQUIRED: base64({
scheme: "c402",
amount: "1000000", // nanotons
channelAddress: "", // empty — client provides
channelId: "0", // empty — client provides
extra: {
publicKeyB: "acdf7bed035db28c134f164343caea739f85710c7124f653959e36290f692367"
}
})
Retry: GET /api/premium
Header: PAYMENT-SIGNATURE: base64({
x402Version: 2,
scheme: "c402",
payload: {
channelAddress: "EQ...", // client's channel
channelId: "123",
state: { balanceA, balanceB, seqnoA, seqnoB },
signature: "Ed25519...",
publicKey: "client-hex...",
initBalanceA: "1000000000", // for channel discovery
initBalanceB: "0"
}
})
Response: 200 OK + PAYMENT-RESPONSE header (counter-signature)
Server Status · GitHub · Built with TON Payment Channels