Skip to content

feat(plugin-misc): add transaction simulation pre-flight skill - #590

Open
spektre-labs wants to merge 1 commit into
sendaifun:v2from
spektre-labs:feat/tx-simulation-preflight
Open

feat(plugin-misc): add transaction simulation pre-flight skill#590
spektre-labs wants to merge 1 commit into
sendaifun:v2from
spektre-labs:feat/tx-simulation-preflight

Conversation

@spektre-labs

Copy link
Copy Markdown

What

Adds a new SIMULATE_TRANSACTION agent skill to plugin-misc: a transaction simulation pre-flight action.

Given a base64-encoded serialized transaction, it simulates it against current chain state and returns a clean structured result:

{
  willSucceed: boolean,
  error: string | null,
  unitsConsumed: number | null,
  logs: string[],
  summary: string
}

It supports both legacy Transaction and VersionedTransaction (tries VersionedTransaction.deserialize first, falls back to Transaction.from), and uses { sigVerify: false, replaceRecentBlockhash: true } for versioned transactions so unsigned/about-to-be-built transactions can be checked.

Why

This is the runtime complement to static safety checks: an agent can dry-run a transaction before signing or sending it.

  • Avoids paying fees on transactions that would fail on-chain.
  • Surfaces compute-unit usage and program logs for debugging/observability.
  • Lets an agent reason about outcome before committing.

core/src/utils/send_tx.ts simulates internally as part of sending, but there was no standalone, agent-callable simulation skill — this fills that gap.

API

  • Tool: simulateTransactionPreflight(agent, base64Tx, opts?)
  • Action: SIMULATE_TRANSACTION (zod schema { transaction: string })

Both are wired into the misc plugin's methods and actions, following the existing ottersec integration pattern (tools/ + actions/ + index registration).

Fail-safe by design

The tool never throws. Any deserialize or RPC failure resolves to willSucceed: false with summary: "⛔ could not simulate — do not assume safe", so a caller can never mistake an unsimulated transaction for a safe one.

Verification done

  • pnpm run build:core and pnpm run build:plugin-misc — clean (CJS + ESM + DTS).
  • biome check on the new files + index.ts — clean (matches repo style).
  • Runtime smoke test of the fail-safe path (garbage / empty base64 → willSucceed: false, never throws) — passes.
  • Zero new dependencies (uses @solana/web3.js, already a dependency).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants