How Cagar works
A hold is a promise backed by locked tUSD8: the host can charge up to the held amount, and only for a limited time.
The life of a hold
Authorize
The guest signs an EIP-3009 authorization. The relayer submits it, the tUSD8 moves into the vault, and the hold records the merchant, the amount and the expiry.
Capture
The merchant charges part of the hold with a list of items. The contract stores a hash of the items, so anyone can check the receipt later. Several captures are allowed, never more than the amount held.
Release
The merchant can return the rest early.
Expiry
After the expiry anyone can call releaseExpired, and the remaining balance goes back to the payer. The keeper on this server does it within a couple of minutes.
Agent mandates
An owner signs an EIP-712 mandate for an agent key. The agent can place holds at listed merchants within the limits below. It can't capture, transfer or approve anything, and revoking the mandate stops it at once.
- Most per hold
- 1.50 tUSD8
- Most held at once
- 3.00 tUSD8
- Longest hold
- 24 hours
- Mandate valid for
- 7 days
Booking API, x402-style
A merchant answers a booking without a hold with HTTP 402 and a signed hold quote. The client places the hold and asks again with the X-Cagar-Hold header. This follows the shape of x402; it is not a claim of x402 compliance.
POST https://cagar.example/api/merchants/seri-pantai/book
→ 402 { quote, quoteSig, vault, chainId }
# place the hold the quote describes, then ask again:
POST https://cagar.example/api/merchants/seri-pantai/book
X-Cagar-Hold: <holdId>
→ 200 { ok: true, booking }Reuse it
The TypeScript SDK in packages/cagar-sdk holds the ABIs, the typed data to sign and a small API client. The contracts and the SDK are MIT licensed.
import { createCagarClient } from "@cagar/sdk";
const cagar = createCagarClient({ baseUrl: "https://cagar.example" });
const offer = await cagar.requestQuote("seri-pantai"); // 402 + signed quote
const { holdId } = await cagar.demoAuthorize("seri-pantai"); // gasless hold
const booking = await cagar.book("seri-pantai", holdId!); // 200Network and contracts
- Network
- aevum
- Chain ID
- 44005
- Explorer
- explorer-test.qday.info
Not deployed on this network yet.
Limits of this demo
- Test tokens only. Nothing here has real value.
- Demo holds last 10 minutes so you can see the release happen. A real stay would hold for 3 days.
- Money already captured is not refunded through Cagar. Disputes and incremental holds are out of scope.
- The contracts can't be upgraded. A fix means a new deployment and a new address.