Build a fail-closed token risk preflight into a Base trading bot
An automated swap should not treat “the contract call succeeded” as evidence that the token is safe to buy or sell. A useful preflight combines independent signals, records missing evidence, and refuses execution when the evidence is incomplete.
1. Normalize the asset and chain
Require an exact 20-byte EVM address, bind it to Base chain ID 8453, and reject symbols or names as identifiers. Cache only by chain plus normalized contract address.
2. Collect independent evidence
- Execution simulation: buy/sell availability, honeypot behavior, transfer restrictions, and taxes.
- Contract evidence: verified source, proxy state, ownership controls, minting or blacklist capabilities.
- Market evidence: real DEX liquidity, pair age, recent volume, and abnormal price movement.
- Holder evidence: concentration and whether one controllable account dominates supply.
3. Fail closed on missing data
Timeouts and unavailable providers are not low-risk observations. Return a completeness field alongside the score and require the caller to decide whether degraded evidence is acceptable.
const decision = await riskPreflight({ chain: "base", token });
if (decision.dataCompleteness !== "complete") {
return { execute: false, reason: "risk_evidence_incomplete" };
}
if (decision.flags.some(flag => BLOCKING_FLAGS.has(flag))) {
return { execute: false, reason: "blocking_token_risk", flags: decision.flags };
}
if (decision.riskScore >= 40) {
return { execute: false, reason: "risk_threshold_exceeded" };
}
return { execute: true, evidenceId: decision.evidenceId };4. Preserve the evidence used to decide
Store timestamps, provider status, normalized inputs, raw signal summaries, the policy version, and the resulting action. Without that record, a bot cannot explain why a trade was allowed after market conditions change.
5. Keep the risk gate separate from execution
The risk component should return evidence and a deterministic recommendation. The execution component should enforce position size, slippage, approval, and transaction simulation independently.
Need this fitted to an existing bot?
Sol Node Labs offers a fixed-scope $49 USDC pilot that adds the preflight, fail-closed policy, and evidence logging to one existing workflow.
Request the integration pilotThis guide describes engineering controls, not financial advice or a guarantee of token safety.