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.
npm install solana-pulse
js
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.
pip install solana-pulse
python
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.
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".
tx_matches confirmed 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.
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.
npm install agentkit-solana-pulse adds check_tx, token_safety and a checked sign-and-send action.npm install elizaos-plugin-solana-pulse. 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