A Solana trading bot is only as good as the tokens it refuses to buy. Most of the ways a new token goes wrong for a buyer can be checked before the trade: someone can still mint more supply, someone can freeze your tokens, the token carries extensions that tax or claw back transfers, a few wallets hold most of it, or a large team allocation unlocks next week.
This guide adds a pre-buy check to a bot in one file. Four of the checks read the token's mint and holders from any Solana RPC. The fifth, locked and vesting supply, comes from one call to the Vestream API. It pairs with our guide to building with token unlock data, which covers keys, limits and six other projects.
Read the mint with getAccountInfo (jsonParsed): mintAuthority and freezeAuthority should be null, and a Token-2022 mint's extensions need a look. Use getTokenLargestAccounts for concentration. Call GET /token/101/{mint}/summary for locked supply, what can be cancelled and the next unlock. Treat every result as a flag for your own rules, not a verdict. Not trading advice.
What to check, and where the answer comes from
| Check | Why it matters | Source |
|---|---|---|
| Mint authority | If it isn't revoked, someone can create new tokens and dilute you | Solana RPC: getAccountInfo |
| Freeze authority | If it's set, the holder of that key can freeze your token account so you can't sell | Solana RPC: getAccountInfo |
| Token-2022 extensions | Transfer fees, transfer hooks and a permanent delegate can tax, block or move tokens you hold | Solana RPC: getAccountInfo |
| Holder concentration | A few wallets holding most of the supply can sell into your buy | Solana RPC: getTokenLargestAccounts |
| Locked and vesting supply | How much of the supply is in team or investor locks, whether the sender can cancel them, and when the next tranche unlocks | Vestream API: /token/101/{mint}/summary |
On Solana, Vestream reads Streamflow, Jupiter Lock and Smithii, the platforms most projects use to lock and vest SPL tokens. The chain id for Solana in the API is 101.
Set up
- A Vestream key. Get one free at vestream.io/build. It appears on screen straight away. Put it in
VESTREAM_API_KEY. - A Solana RPC URL. The public endpoint works for getAccountInfo, but it rate-limits getTokenLargestAccounts hard (it answered our test with a 429). A free plan from any RPC provider is enough. Put the URL in
SOLANA_RPC_URL. - Node 18 or later, which has fetch built in. No packages needed.
The check, in one file
Copy this into your bot as safety.mjs. It runs the RPC reads and the API call together and returns a list of flags. An empty list means none of your rules fired, nothing more.
// safety.mjs: a pre-buy safety check for a Solana trading bot (Node 18+)
const RPC = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";
const API = "https://www.vestream.io/api/v1";
const TOKEN_2022 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
// Extensions that let someone tax, block or move tokens after you buy.
const RISKY_EXTENSIONS = ["permanentDelegate", "transferHook", "transferFeeConfig", "defaultAccountState", "nonTransferable"];
async function rpc(method, params) {
const res = await fetch(RPC, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
});
const body = await res.json();
if (body.error) throw new Error(`${method}: ${body.error.message}`);
return body.result;
}
// 1–3. Mint authority, freeze authority and Token-2022 extensions.
export async function checkMint(mint) {
const { value } = await rpc("getAccountInfo", [mint, { encoding: "jsonParsed" }]);
if (!value) throw new Error("Mint account not found");
const info = value.data.parsed.info;
const extensions = (info.extensions ?? []).map((e) => e.extension);
return {
supply: BigInt(info.supply), // raw units
decimals: info.decimals,
mintAuthority: info.mintAuthority, // null = nobody can mint more
freezeAuthority: info.freezeAuthority, // null = nobody can freeze holders
token2022: value.owner === TOKEN_2022,
riskyExtensions: extensions.filter((e) => RISKY_EXTENSIONS.includes(e)),
};
}
// 4. Holder concentration: the 20 largest token accounts.
export async function checkHolders(mint, supply) {
const { value } = await rpc("getTokenLargestAccounts", [mint]);
const top10 = value.slice(0, 10).reduce((sum, a) => sum + BigInt(a.amount), 0n);
return {
top10Pct: supply > 0n ? Number((top10 * 10000n) / supply) / 100 : 0,
largestAccount: value[0]?.address ?? null,
};
}
// 5. Locked and vesting supply from Vestream.
export async function checkVesting(mint) {
// Pass the mint exactly as it is: Solana addresses are case-sensitive.
const res = await fetch(`${API}/token/101/${mint}/summary`, {
headers: { Authorization: `Bearer ${process.env.VESTREAM_API_KEY}` },
});
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(`Vestream ${res.status}: ${body.error ?? res.statusText}`);
}
return res.json();
}
// Your rules. These are examples: tune them to the tokens you trade.
export async function safetyCheck(mint) {
const m = await checkMint(mint);
const [holders, vesting] = await Promise.all([checkHolders(mint, m.supply), checkVesting(mint)]);
const flags = [];
if (m.mintAuthority) flags.push("mint authority not revoked: supply can grow");
if (m.freezeAuthority) flags.push("freeze authority set: token accounts can be frozen");
if (m.riskyExtensions.length) flags.push(`Token-2022 extensions: ${m.riskyExtensions.join(", ")}`);
if (holders.top10Pct > 50) flags.push(`top 10 accounts hold ${holders.top10Pct}% (is the largest the pool?)`);
if (BigInt(vesting.cancelable_locked) > 0n) flags.push("some locked supply can be cancelled by the sender");
const next = vesting.next_unlock;
const liquidity = vesting.market?.liquidity_usd ?? null;
const withinAWeek = next && next.unlock_time - Date.now() / 1000 < 7 * 86400;
if (withinAWeek && next.usd_value != null && liquidity && next.usd_value > liquidity * 0.25) {
flags.push(`$${Math.round(next.usd_value).toLocaleString("en-US")} unlocks within 7 days, over 25% of pool liquidity`);
}
const locked = BigInt(vesting.locked_now); // same raw units as the supply
return {
mint,
flags,
lockedPct: m.supply > 0n ? Number((locked * 10000n) / m.supply) / 100 : 0,
activeSchedules: vesting.active_schedules,
coverage: vesting.coverage,
};
}Use it before every buy:
import { safetyCheck } from "./safety.mjs";
const result = await safetyCheck(candidateMint);
if (result.flags.length > 0) {
console.log(`skip ${candidateMint}:`, result.flags.join("; "));
} else {
// your buy logic here
}Reading the results
Mint and freeze authority
A null mintAuthority means the supply is fixed: nobody holds the key to create more. A null freezeAuthority means nobody can freeze holders' accounts. For a new memecoin, either one still being set is a strong reason to skip. Context matters, though: regulated stablecoins such as USDC keep both on purpose, so a rule that skips anything with a freeze authority will also skip USDC.
Token-2022 extensions
Tokens created with the newer Token-2022 program can carry extensions. Most are harmless, such as on-chain metadata. A few change what you can do with tokens you own: transferFeeConfig takes a fee on every transfer, transferHook runs the creator's program on every transfer and can block it, and permanentDelegate lets one address move or burn tokens from any account. The check flags those; read what each one is set to before you decide.
Holder concentration
getTokenLargestAccounts returns the 20 largest token accounts. The largest is very often the liquidity pool's own vault, not a whale, so look up its owner before you treat a high figure as a warning. Exchange and lock accounts can look concentrated too.
Locked and vesting supply
The summary call returns, for the platforms Vestream indexes:
locked_now: tokens still locked or vesting, in raw units. The check turns it into a share of supply.cancelable_locked: the part of that the sender can still cancel. Tokens a team can pull back aren't really committed.next_unlock: the date (unlock_time, Unix seconds), rawamountandusd_valueof the next tranche.usd_valueis null when the market is too thin to value it honestly.unlocking_next_7d,_30d,_90d: how much releases in each window.market: price,liquidity_usd, 24-hour volume and market cap, so you can compare an unlock with the pool that would absorb it.
For the list of every schedule behind those totals, with each one's recipient, dates and whether it can be cancelled, call /token/101/{mint}/locks. For unlocks measured against liquidity and volume over several windows, call /token/101/{mint}/pressure.
Many new tokens, including most launched straight onto a bonding curve, have no team allocation in a vesting contract at all. Then locked_now is 0 and next_unlock is null. That tells you no lock exists on the platforms Vestream reads, not that the supply is safe or that no lock exists anywhere. The response's coverage field says what was checked.
Keeping it fast and inside your limits
- Run your cheap filters first. Check the mint (one RPC call) and only spend the holder and Vestream calls on tokens that pass. The free Vestream plan is 250 calls a month and 50 a day: plenty for testing, or for a bot that shortlists a few tokens a day.
- Cache by mint. Locks and vesting schedules change daily, not by the second. Keep each result for an hour and a bot that sees the same token twice pays once.
- Check a watchlist in one request.
POST /batch/tokensreturns summaries for up to 25 tokens; each token counts as one call. - Need more? Starter is $49 a month for 1,000 calls, with webhooks and commercial use. See plans.
Mistakes that catch people out
- Lowercasing the mint. Solana addresses are case-sensitive. Pass the mint exactly as you received it, to the RPC and to the API.
- Comparing raw amounts with whole tokens.
supply,locked_nowandamountare raw units. Compare them with each other, or divide by10^decimalsfirst, using BigInt so large supplies don't lose precision. - Calling the API from a browser extension or front end. Anything shipped to users is public. Keep the key on the machine that runs the bot.
- Treating the result as a verdict. The check reports facts about the token. Whether to trade on them is your call, and nothing here is trading advice.
Where to go next
- Build with token unlock data: keys, limits and six more projects, from a Telegram unlock bot to an unlock chart.
- Token lock checker: the same lock check by hand, for any token.
- Developer docs: every endpoint, parameter and response.
- Streamflow and Jupiter Lock: live data for the main Solana lock platforms.
Frequently Asked Questions
Can this tell me whether a Solana token is a rug pull?
No check can. It tells you whether supply can still grow, whether holders can be frozen, whether the token carries extensions that tax or move transfers, how concentrated holders are, and how much supply is locked and when it unlocks. Those are the usual levers; how you weigh them is up to you.
Which Solana lock platforms does the Vestream API read?
Streamflow, Jupiter Lock and Smithii. Use chain id 101 and the token's mint address.
Does it work on tokens launched on pump.fun?
The mint, freeze, extension and holder checks work on any SPL token. Tokens launched on a bonding curve usually have no team allocation in a vesting contract, so the vesting part normally comes back empty, which is information in itself rather than a pass.
How fast is the check?
The RPC reads and the API call run in parallel, so the check takes about as long as the slowest of them, typically well under a second with a good RPC. Caching by mint removes the cost for tokens you've seen recently.
Is the Vestream API free for this?
Yes, for testing and light use: 250 calls a month, 50 a day. A bot that checks many tokens a day needs a paid plan.