Over the last few weeks I read the signing code of a lot of open-source Solana bots and agents: trading bots, copy traders, launchpad tools, AI agents with a wallet. The same pattern shows up again and again:
const tx = VersionedTransaction.deserialize(Buffer.from(body.swapTransaction, "base64")); tx.sign([wallet]); // signs whatever came back await connection.sendTransaction(tx); The transaction is built by someone else (Jupiter's /swap or Ultra /order, PumpPortal, a launchpad API) and the bot signs it without reading it. Most of the time that's fine. But if the response is ever wrong (a bad config, a compromised endpoint, a proxy in between, a decimals slip), the key signs it anyway: an extra transfer out of the wallet, a different output token, a swap that pays someone else. A bot that trades on its own signs without anyone watching.
So I packaged the check I use myself into one line.
JavaScript / TypeScript
npm install solana-pulse import { checkBeforeSign } from "solana-pulse"; await checkBeforeSign(tx); // throws PulseBlockedError unless Pulse answers OK tx.sign([wallet]); No dependencies: it uses fetch (Node 18+, browsers, edge runtimes) and takes base64, bytes, or a @solana/web3.js Transaction / VersionedTransaction.
Python
pip install solana-pulse from solana_pulse import check_before_sign check_before_sign(swap_tx) # raises PulseBlocked unless Pulse answers OK signed = VersionedTransaction(swap_tx.message, [keypair]) Also zero dependencies.
What it actually checks
checkBeforeSign sends the unsigned transaction to Solana Pulse, which decodes every step, dry-runs it on live mainnet, and answers OK, REVIEW or BLOCK with each wallet's SOL and token changes. It blocks drainer approvals, authority changes, accounts closed to someone else, transactions that would fail, and expired blockhashes.
For swaps and transfers you can go one step further and say what you meant:
// Jupiter swap: sells exactly 0.5 SOL and pays the bought USDC back to your own wallet, nothing else. await checkBeforeSign(tx, { expected: { action: "swap", sell: "SOL", amount: "0.5", buy: USDC_MINT } }); // Transfer built from "send 5 USDC to X": await checkBeforeSign(tx, { expected: { token: USDC_MINT, amount: "5", to: recipient } }); If the transaction moves a different amount, a different token, pays someone else, or does anything extra, you get MISMATCH and the field that's off.
Fail-closed by design: if Pulse can't be reached, checkBeforeSign throws too. "Not checked" is never treated as "safe".
How well does it work? (measured, not claimed)
- 0 false BLOCKs on 200 real mainnet transactions.
- 9 of 9 attack cases caught for the right reason in a public benchmark built from real mainnet accounts: wrong recipient, wrong amount (a decimals slip), lookalike token, hidden approval, hidden transfer, a real Jupiter swap that pays a stranger, an owner-change drain, an expired transaction, and a replayed payment. The cases are in the repo.
- On the same 200 transactions,
tx_matchesconfirmed 80 of 80 transfers and 26 of 27 swaps. The 27th paid a bot 1.54%, so it was flagged.
It's a small benchmark, not a proof, and "OK" means none of the traps Pulse knows about are present. No check can promise a transaction is safe.
Cost
Each tool gives 25 free calls a day per caller, no key needed. After that a check costs $0.02 USDC, paid per request with x402. Calls that fail are never charged.
Using an agent framework?
- Coinbase AgentKit:
npm install agentkit-solana-pulseaddscheck_tx,tx_matches,token_safetyand a checked sign-and-send action. - elizaOS:
npm install elizaos-plugin-solana-pulse. - MCP (Claude, Cursor and others): connect to
https://solana-pulse-gateway-1021990235790.us-central1.run.app/mcp.
If you'd rather not depend on an outside service, the same idea works with plain RPC: call simulateTransaction with your wallet in accounts and compare the balance changes to the quote before signing. Please do something before that .sign().
Questions or a signing flow you want a second pair of eyes on? Ask in the comments. Code: GitHub · npm · PyPI
