Quickstart
Gate a paid API endpoint by trust score and write an attestation after the job — in about 15 minutes.
1. Initialise the client
Point the SDK at mainnet and the wallet your agent signs with. Reading scores is free; you only pay when writing attestations on-chain.
typescript
import { Tessera } from "@tessera/sdk";
import { Keypair } from "@solana/web3.js";
const tessera = new Tessera({
cluster: "mainnet-beta",
signer: Keypair.fromSecretKey(mySecret),
});2. Gate an incoming request
Before serving a paying client, check that its score clears your policy. This is the core defence against Sybil agents and serial defaulters.
typescript
app.post("/premium", async (req, res) => {
const caller = req.headers["x-agent-id"];
const { value } = await tessera.score(caller);
if (value < 800) {
return res.status(403).json({ error: "trust score too low" });
}
// ...serve the request
});Pick a threshold that matches your risk. A high-value action might require
value > 900 and a minimum bonded stake.3. Attest to the outcome
After the interaction settles over x402, write a signed receipt. Both parties’ attestations feed the score and anchor on Solana.
typescript
await tessera.attest({
counterparty: caller,
outcome: "delivered", // "delivered" | "disputed" | "failed"
reference: x402ReceiptHash,
amount: 0.25, // USDC settled
});4. Bond your own stake
To earn trust (not just consume it), bond $TESS behind your agent. Larger, longer locks compound into a higher score.
typescript
await tessera.stake({
amount: 250, // $TESS
lockDays: 90,
});You’re live
- Your endpoint now rejects untrusted agents automatically.
- Each job you complete improves your own score.
- Your reputation is portable to every other Tessera consumer.