Example wallet
One wallet: the code below is the keyed call a distributor makes, and the example beneath it shows what Yutai answered for the wallet named in that code. This page reads that answer without a key, so a signed-out visitor sees it too.
The call
The printed call is the keyed call a distributor makes: it connects the SDK's client and asks the eligibility read for one wallet, with a placeholder where the key stands. This page's own live read does not use that key: it asks Yutai's keyless documentation read for the same wallet, so the example below draws without a key being set. The key never reaches your browser.
import { connectDistributorApi } from "@yutai/sdk-web/client";
const client = connectDistributorApi({ base: "https://api.yutai.com", key: "ytk_your-key" });
const answer = await client.askEligibility(["0xcd8a4c3f9d3ab5c8817729a4d1420b95869b5928"]);GET /v1/eligibilitythe tokens a wallet holds and the benefits they reach: the keyed call the printed snippet makes; the page's own answer and the paste box's read ask the docs route's keyless twin of the same answerPOST /v1/claims/challengethe words the wallet signs, before the claim is askedPOST /v1/claimsthe claim, recorded on the proof the wallet signedGET /v1/claims/{id}the claim's own state, in the words the read answers
The example
The answer rides the SDK's module element, the renderer your page gets when it loads the SDK: one row per token the wallet holds, the benefits the holding reaches, and the one label on every offer no real issuer stands behind. This page asks the keyless read for a fresh answer at most once a minute, so the answer below can stand up to a minute behind Yutai's own answer now.
Yutai read this wallet and it carries none of the tokens Yutai knows. Nothing was drawn.
The claim flow
A benefit the wallet reaches is one its holder can claim. The claim flow is the wallet's own: its wallet signs the one message Yutai asks for, Yutai records the claim on that proof, and the read answers the state the claim stands in. Each press names the way its own benefit reaches the holder: a code reaches the holder in their own Yutai app, and the answers Yutai hands back carry the claim's facts alone, never the holder's code. The presses still use the docs demo key held in the serving environment, because a claim is a write behind the keyed API; when that key is not set, a press answers that the example is not wired.
The flow's own code, the order the presses run it in: the two asks the SDK's client carries, then the read, the calls the panel above names.
import { connectDistributorApi, refusedSentenceOf } from "@yutai/sdk-web/client";
const key = "ytk_your-key";
const client = connectDistributorApi({ base: "https://api.yutai.com", key });
const headers = { Authorization: `Bearer ${key}`, Accept: "application/json" };
// The words the wallet signs, before the claim is asked.
const challenge = await client.askClaimChallenge(benefitId, [wallet]);
const signature = await wallet.signMessage(challenge.message);
// The claim, recorded on that proof.
const answer = await client.askClaim({ benefitId, wallet, nonce: challenge.nonce, signature });
if (answer.status !== "claimed") throw new Error(refusedSentenceOf(answer.reason));
// The claim's own state, in the words the read answers.
const claim = await fetch(`https://api.yutai.com/v1/claims/${answer.claimId}`, { headers }).then((read) => read.json());Try an address
The paste box takes one address and asks the same keyless read for it: the answer draws the way the example above does, and an address of a chain Yutai carries no wallet on is refused before anything is sent. The box answers six pastes a minute; a seventh in the same minute reads nothing and answers once the minute is up. One pasted address also asks the API at most once a minute, because the read keeps its own one-minute window.