Create the client in your backend. Then a badge when the address is pasted, a verdict when the token is
chosen, and the delisting list on a timer.
import { createGuardian, isUnavailable, matchDelistings } from '@maranilabs/guardian';
const guardian = createGuardian({ apiKey: process.env.GUARDIAN_KEY! });
// calls https://api.maranilabs.com
// 1. The address is pasted: show a badge.
const badge = await guardian.address(to);
// 2. The token is chosen: get the verdict.
const verdict = await guardian.check({ to, mint, symbol });
if (isUnavailable(verdict)) {
// We couldn't check in time. Say so, and never block on it.
} else {
show(verdict.level, verdict.message);
// e.g. "block", "Binance doesn't accept USDG on Solana. …"
if (verdict.level === 'block') {
// Disable Send. If verdict.swapTo is set, offer
// "Swap to {swapTo.symbol} and send" instead.
}
}
// 3. Delistings, e.g. hourly: fetch the whole list and match it locally.
const list = await guardian.delistings();
if (!isUnavailable(list)) {
const affected = matchDelistings(list.notices, heldMints);
}
- The address is pasted
- address(to)
- A badge for the recipient. Under about 150 ms for a known exchange wallet, up to about 2 s for any other address.
- The token is chosen
- check({ to, mint, symbol })
- The verdict. Pass the token's mint, or "SOL" for native SOL.
- Before signing
- check(…) again
- Only if the recipient or the token changed.
- Hourly, or on wallet open
- delistings(), then matchDelistings(…)
- The list is small. Matching runs on the device.
// the answer
{
"level": "block",
"code": "CEX_TOKEN_NOT_LISTED",
"message": "Binance doesn't accept USDG on Solana. If you send it, it won't be credited.",
"exchange": "binance",
"swapTo": { "symbol": "USDC", "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
"notes": [
{ "level": "warn", "code": "TOKEN2022_EXCHANGE_CREDIT", "message": "…" },
{ "level": "info", "code": "TOKEN2022_PERMANENT_DELEGATE", "message": "…" }
]
}
Skip the call for sends to the user's own address. Solana mainnet only. New codes and exchanges may be
added: if you get one that isn't documented, show the message and act on the level.
Read the docs