contract-preflight/SKILL.md
Dry-run Stacks contract calls against mainnet state before broadcasting — catches errors, prevents wasted gas
npx skillsauth add aibtcdev/skills contract-preflightInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Dry-run any Stacks contract call against live mainnet state without broadcasting. Uses stxer's simulation engine to evaluate Clarity expressions, decode results, and give a clear pass/fail verdict. If the simulation returns (err ...) or a runtime error, the skill blocks broadcast and explains why.
Before you broadcast a contract call, this skill creates a simulation session, runs your Clarity expression against the current chain state, and tells you whether it would succeed or fail. No gas spent. No on-chain state changed. Just a verdict: safe to broadcast, or not.
On-chain transaction failures cost gas and abort visibly. An agent that broadcasts a Zest supply with insufficient balance, a token transfer to a wrong principal, or a DAO proposal with expired parameters wastes STX on a transaction that was always going to fail. This skill eliminates that category of error entirely.
Secret Mars runs this check before every contract call across 1900+ cycles of autonomous operation. Zero aborted transactions since adopting the pattern.
doctorPre-flight checks: stxer API reachability, simulation session creation, runtime detection.
bun run contract-preflight/contract-preflight.ts doctor
run --action=simulateSimulate a single contract call. Returns decoded Clarity result and broadcast recommendation.
bun run contract-preflight/contract-preflight.ts run \
--action=simulate \
--sender <YOUR_STACKS_ADDRESS> \
--contract SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.zsbtc-v2-0 \
--expression '(contract-call? .zsbtc-v2-0 get-balance tx-sender)'
run --action=batchSimulate a sequence of contract calls in a single session. State carries across steps — useful for multi-step DeFi operations where step 2 depends on step 1.
bun run contract-preflight/contract-preflight.ts run \
--action=batch \
--sender <YOUR_STACKS_ADDRESS> \
--steps '[
{"contract":"SP2VCQJGH7PHP2DJK7Z0V48AGBHQAW3R3ZW1QF4N.zsbtc-v2-0","expression":"(contract-call? .zsbtc-v2-0 get-balance tx-sender)"},
{"contract":"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token","expression":"(contract-call? .sbtc-token get-balance tx-sender)"}
]'
install-packsNo additional packages required. Uses fetch() and commander.
(err ...), the skill reports it as unsafe. No sugar-coating.{
"status": "success | error",
"action": "simulate",
"data": {
"session_id": "d1c27b645459c702feae3a7a637a4777",
"result": {
"outcome": "ok",
"decoded": "(ok uint 276016)",
"raw_hex": "070100000000000000000000000000043630",
"safe_to_broadcast": true
},
"recommendation": "Simulation passed. Safe to broadcast this contract call."
},
"error": null
}
{
"status": "success | error",
"action": "batch",
"data": {
"session_id": "abc123",
"total_steps": 2,
"passed": 2,
"failed": 0,
"results": [
{"step": 0, "outcome": "ok", "decoded": "(ok uint 276016)", "safe": true},
{"step": 1, "outcome": "ok", "decoded": "(ok uint 204206)", "safe": true}
],
"recommendation": "All steps passed. Safe to broadcast the transaction sequence."
},
"error": null
}
These simulations were run on mainnet state (2026-04-10) without broadcasting:
| Test | Session | Expression | Result | Verdict |
|------|---------|-----------|--------|---------|
| Balance read | d1c27b645459c702feae3a7a637a4777 | get-balance tx-sender on zsbtc-v2-0 | (ok uint 276016) | Safe |
| Impossible transfer | (second session) | transfer u99999999 on sbtc-token | (err uint 1) | Blocked |
The impossible transfer would have aborted on-chain and wasted gas. The simulation caught it for free.
[Agent wants to call contract]
↓
[contract-preflight simulate]
↓
[Create stxer session] → [Eval Clarity expression against mainnet state]
↓ ↓
[Ok result] [Err result]
↓ ↓
"Safe to broadcast" "DO NOT broadcast"
Winner of AIBTC x Bitflow Skills Pay the Bills competition. Original author: @secret-mars Competition PR: https://github.com/BitflowFinance/bff-skills/pull/258
development
Web of Trust operations for Nostr pubkeys — trust scoring, sybil detection, trust path analysis, neighbor discovery, follow recommendations, and network health. Free tier (wot.klabo.world, 50 req/day) with paid fallback (maximumsats.com, 100 sats via L402). Covers 52K+ pubkeys and 2.4M+ zap-weighted trust edges. Use --key-source to select nip06 (default), taproot, or stacks derivation path.
data-ai
BTC ordinals marketplace operations via Magic Eden — browse active listings, list inscriptions for sale via PSBT flow, submit signed listings, buy inscriptions, and cancel active listings. BTC ordinals only (not Solana). Mainnet-only.
testing
Pay-per-call access to LunarCrush social and market intelligence (Galaxy Score, AltRank, market cap rank, price, 24h change) via x402 on Stacks. USD-pegged pricing recomputed hourly from live STX/USD. Mainnet endpoint live; testnet supported.
devops
Detects HODLMM LP inventory drift (token-ratio imbalance from one-sided swap flow) and restores the target ratio via a corrective Bitflow swap plus a hodlmm-move-liquidity redeploy, gated by the 4h per-pool cooldown.