@revibase/transaction-simulation
v0.2.1
Published
Simulate Solana instructions for a wallet and return display-ready balance rows from account snapshot diffs
Readme
Transaction simulation
In one sentence: run a Solana transaction as a dry run, compare account snapshots before vs after, and return human-readable balance rows for the approval screen.
Used by the auth app so users see estimated changes before they sign—similar to Phantom wallet.
Using it in code
import { simulateInstructions } from "@revibase/transaction-simulation";
const result = await simulateInstructions({
rpcEndpoint: "https://api.mainnet-beta.solana.com",
walletAddress,
payer: walletAddress,
instructions,
addressesByLookupTableAddress, // optional
});
// result.balanceChanges — amounts going up/down
// result.status — "succeeded" | "failed"Folder map (where things live)
src/
simulate-instructions.ts ← main entry you call
simulate.ts ← RPC compile + simulateTransaction
types/ ← shared types (parsers, simulation API)
parsers/
run.ts ← account snapshot diff orchestration
parsed-row.ts ← finalize rows + pending mint merge
account-guard.ts ← guardAccountDiff for account parsers
plugin-kit/ ← shared fungible helpers
plugins/ ← one folder per on-chain program
utils/labels/ ← user-visible text (“Your Wallet”, …)Scripts
| Command | What it does |
|---------|----------------|
| pnpm test | Run all tests |
| pnpm build | Build package for publish / app |
