Build with Takusen
Build your first judgement
Use the x402 flow to submit a typed question and follow it to a verifiable result.Before you start
Set TAKUSEN_API_URL to the API origin and choose the EVM wallet that will pay for requests. Takusen uses prepaid USDC credits: the wallet deposits USDC into one settlement domain's escrow, and the API exposes the observed amount as credits on that domain. Credits never move between domains automatically.
1. Choose a settlement domain
shcurl "$TAKUSEN_API_URL/v1/chain"Choose a domain whose active and healthy fields are true. Save its domainId, chainId, USDC contract, escrow address, and one advertised depositMechanisms value. Your wallet needs that domain's USDC plus enough native gas for any wallet-submitted transactions.
2. Deposit USDC and receive credits
For an API integration, request a deposit plan. amountMicros uses micro-USDC, so 10000000 means 10 USDC. Use a mechanism advertised by /v1/chain.
shcurl --request POST "$TAKUSEN_API_URL/v1/credits/deposit" \
--header 'Content-Type: application/json' \
--cookie takusen.cookies \
--data '{
"settlementDomain": "0x<domainId>",
"amountMicros": 10000000,
"mechanism": "eip3009"
}'| Mechanism | What the requester does |
|---|---|
| eip3009 | Sign the returned TransferWithAuthorization typed data, then POST settlementDomain, mechanism, the returned message as authorization, and the signature to /v1/credits/deposit/facilitate. |
| approve | Submit every returned wallet transaction in order, wait for confirmation, then POST the final deposit transaction hash with settlementDomain and amountMicros to /v1/credits/deposit/observe. |
The deposit is spendable only after Native Chain observation. Poll /v1/credits with the session cookie until the selected account's availableMicros is at least the request's spendLimitMicros. depositedMicros includes observed funding; reservedMicros is committed to active requests; spentMicros is finalized execution cost.
shcurl --cookie takusen.cookies "$TAKUSEN_API_URL/v1/credits"3. Discover models and output types
shcurl "$TAKUSEN_API_URL/v1/models"
curl "$TAKUSEN_API_URL/v1/output-schemas"Choose active model IDs from /v1/models and a governed output type from /v1/output-schemas. Do not hard-code these values across protocol revisions.
4. Prepare the request
json{
"settlementDomain": "0x<domainId returned by /v1/chain>",
"prompt": "Will the stated resolution condition be satisfied?",
"outputType": "boolean",
"models": ["openai/gpt-6-luna", "anthropic/claude-haiku-5.5"],
"spendLimitMicros": 250000,
"timeLimitSeconds": 90,
"executionQuorum": 2,
"visibility": "public"
}spendLimitMicros is the maximum all-in reservation in micro-USDC: 250000 is 0.25 USDC. Keep the serialized body unchanged through the challenge and submission calls.
5. Request the payment challenge
shcurl --request POST \
--url "$TAKUSEN_API_URL/v1/x402/requests" \
--header 'Content-Type: application/json' \
--dump-header response.headers \
--data @request.json402 Payment Required is the expected response. Decode the PAYMENT-REQUIRED header or read the equivalent JSON body. It contains the exact network, asset, escrow, amount, one-use challenge ID, AuthorizeRequest typed data, and extensions.takusen.binding for an on-chain consumer. The challenge expires after ten minutes, leaving time to confirm the application binding before payment.
6. Sign and submit
- Sign the exact
extensions.takusen.authorizationEIP-712 typed data with the funded payer wallet. - Create an x402 v2
PaymentPayloadusing the selectedacceptsentry. Setextensions.takusen.challengeId,requester, andrequestSignature. - Base64-encode that JSON payload as
PAYMENT_SIGNATURE. - POST the unchanged
request.jsonagain withPAYMENT-SIGNATURE. A successful response is202 Acceptedand contains therequestId.
shcurl --request POST \
--url "$TAKUSEN_API_URL/v1/x402/requests" \
--header 'Content-Type: application/json' \
--header "PAYMENT-SIGNATURE: $PAYMENT_SIGNATURE" \
--data @request.json7. Follow the result
shcurl --no-buffer "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID/stream"
curl "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID"
curl "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID/answers"Public requests need no session for streaming or reads. Reconnect the SSE stream with Last-Event-ID until the request reaches a terminal state, then inspect the aggregate record, model answers, evidence hashes, measured spend, and settlement transaction.