All articles
Risk·April 19, 2026·5 min read

How to Build a Hard Kill Switch for Solana Trading Bots

Step-by-step guide to implementing a reliable kill switch using Solana account freezing, on-chain authority revocation, and an out-of-band emergency shutdown endpoint so your bot halts within one slot even if your main server is compromised.

A hard kill switch for Solana trading bots is not a nice-to-have — it is a precondition for running anything with real capital on-chain. Without one, a rogue loop, a corrupted config, or a compromised keypair can drain an account in under a minute while you scramble to SSH into a server. This guide covers three complementary layers: freezing token accounts at the SPL level, revoking delegate authority on-chain, and wiring an out-of-band shutdown endpoint that bypasses your main process entirely.

Why Software-Only Shutdown Is Not Enough

Most teams implement kill switches as an environment variable or a REST endpoint that sets a flag in their bot's main loop. This works until it doesn't: the process is stuck, the container is OOMed, or the server itself is the attack surface. A pure-software stop signal has exactly the same blast radius as your normal trading path. You need a kill mechanism that operates independently of your bot's runtime.

The goal is to halt execution within one confirmation slot (~400 ms on Solana mainnet) even if your application server is unreachable. That requires authority that lives on-chain, not in your process memory.

Layer 1 — SPL Token Account Freezing

Every SPL token account supports a freeze authority: a pubkey that can call FreezeAccount to make the account unwritable. If your bot's vault holds USDC or any other SPL token, set the freeze authority to a dedicated cold keypair at account creation time.

spl-token create-account <MINT> --owner <BOT_PUBKEY> --fee-payer <FEE_PAYER>
spl-token authorize <ACCOUNT> freeze <FREEZE_AUTHORITY_PUBKEY>

To trigger: spl-token freeze <ACCOUNT> --freeze-authority <FREEZE_AUTHORITY_KEYPAIR>. Once frozen, no transfer instruction involving that account will land — the runtime rejects it at the account validation stage, before your program logic even runs.

Trade-off: freeze authority only covers SPL token accounts. SOL itself and any program-owned PDAs are unaffected. Use this as one layer, not the whole answer.

Layer 2 — Delegate Revocation and Authority Transfer

If your bot signs transactions using a hot keypair that holds delegate authority over a larger vault (a common pattern for custody separation), you can revoke that delegation in a single transaction without touching the underlying funds.

For SPL accounts: spl-token revoke <ACCOUNT>. For program-owned authority patterns, the equivalent is a program instruction that sets the authority field to None or transfers it to a multisig. Both are atomic at the slot boundary.

Keep the revocation keypair on a separate machine — ideally an air-gapped signing device or a hardware wallet connected to a lightweight signing server with no internet-facing ports. The signing server only needs to accept one message type: "sign this revoke transaction." It should reject everything else.

Layer 3 — Out-of-Band Emergency Shutdown Endpoint

This is the layer most teams skip and most regret skipping. The idea is simple: run a minimal, dependency-free process on a different host from your main bot, listening on a private port (or a Tailscale/Wireguard overlay network). This process holds the freeze authority and revocation keypair in memory, and its only job is to broadcast pre-signed emergency transactions when triggered.

Pre-sign at startup, not at kill time. When your bot starts, generate and sign (but do not broadcast) the freeze and revoke transactions. Store them in memory in the out-of-band process. At kill time, this process just calls sendTransaction — no keypair exposure, no signing latency, no dependency on the main process being alive.

Architecture sketch:

  • Main bot server — holds hot trading keypair, runs your strategy
  • Kill server — separate host, holds freeze/revoke authority, accepts kill signal via authenticated HTTP or a simple TCP message
  • Operator device — your phone, a hardware key, or a second laptop that can send the kill signal from outside your infrastructure

The kill signal itself should require at minimum a TOTP or HMAC-signed payload. Do not expose this endpoint to the public internet without authentication.

Wiring It Together: Slot-Level Guarantees

To reliably halt within one slot, pre-sign your emergency transactions with a recent blockhash that you refresh every 30–60 seconds. Solana blockhashes expire after ~150 slots (~60 seconds). Your kill server should run a background task that re-signs with a fresh blockhash on that cadence, so the pre-signed transaction is always valid and ready to broadcast immediately.

When the kill signal fires:

  1. Kill server broadcasts the pre-signed freeze transaction via a dedicated RPC endpoint (not the same one your bot uses — use a backup provider or a local validator node for latency predictability).
  2. Kill server simultaneously sends a SIGTERM to the main bot process over the internal network if reachable.
  3. Kill server logs the slot number of the broadcast for post-incident review.

Realistic latency: network propagation to leaders is typically 50–200 ms; confirmation to finalized is 3–5 slots under normal conditions. For most risk scenarios, one slot is sufficient to prevent further transactions from landing.

Testing Your Kill Switch (Don't Skip This)

A kill switch you have never tested is not a kill switch. Run monthly fire drills on devnet with the same keypairs and RPC topology you use in production. Measure the actual slot delta between your last bot transaction and the freeze confirmation. Set an alerting threshold — if your kill latency exceeds 2 slots, investigate before the next production deployment.

Also test the failure case: what happens if your kill server is unreachable? You should have a manual fallback — a script on your operator device that can broadcast the pre-signed transaction directly. Keep a copy of the latest pre-signed transaction bytes in an encrypted file you can reach from your phone.

If you are running bots across multiple on-chain venues, each venue integration needs its own kill path. A freeze on your Solana SPL vault does nothing to a position open on Hyperliquid — those require separate authority revocation flows at the protocol level.


If you want a production-grade kill switch designed for your specific bot architecture, get in touch — we wire these into every system we build and can audit or retrofit your existing setup.

Need a bot like this built?

We design, build and run trading bots on Solana, Hyperliquid and Polymarket.

Start a project
#risk#solana#trading-bots#infrastructure#kill-switch#on-chain-safety