{"id":24909,"library":"anvil-sol","title":"Anvil Sol","description":"Anvil is a CLI tool that transpiles Anchor-based Solana programs to Pinocchio, native (solana-program), or Quasar Rust dialects, producing cargo-buildable projects from a single typed IR. Current stable version is 0.3.4, released with a weekly cadence. Key differentiators: deterministic emit with a validator, portability linting, CU benchmarking, and a migration safety analysis tool. Requires Bun >=1.0.0 and depends on litesvm, @solana/web3.js, and @noble/hashes as peer dependencies. Supports three targets with regression gates (21+ MUST_PASS for pinocchio and native).","status":"active","version":"0.3.4","language":"javascript","source_language":"en","source_url":"https://github.com/Pratikkale26/Anvil","tags":["javascript","solana","anchor","pinocchio","transpiler","compute-units","cu-optimization","rust","cli"],"install":[{"cmd":"npm install anvil-sol","lang":"bash","label":"npm"},{"cmd":"yarn add anvil-sol","lang":"bash","label":"yarn"},{"cmd":"pnpm add anvil-sol","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime; must be >=1.0.0 as per engines.","package":"bun","optional":false},{"reason":"Used for local Solana VM execution in tests/benchmarks.","package":"litesvm","optional":true},{"reason":"Required for Solana RPC interaction and account layout representation.","package":"@solana/web3.js","optional":false},{"reason":"Used for hashing operations in the transpiler.","package":"@noble/hashes","optional":false}],"imports":[{"note":"ESM-only; ESM support only from v0.3+.","wrong":"const anvil = require('anvil-sol');","symbol":"default","correct":"import anvil from 'anvil-sol';"},{"note":"Named export; subpath imports not supported.","wrong":"import { compile } from 'anvil-sol/compile';","symbol":"compile","correct":"import { compile } from 'anvil-sol';"},{"note":"Also top-level named export.","wrong":"const { lint } = await import('anvil-sol');","symbol":"lint","correct":"import { lint } from 'anvil-sol';"}],"quickstart":{"code":"// Install globally\nbun install -g anvil-sol\n\n# Transpile an Anchor program to Pinocchio\nanvil compile program.rs --target pinocchio --output ./out\ncd ./out && cargo build\n\n# Parse to IR\nanvil parse program.rs --json\n\n# Portability lint\nanvil lint program.rs --target pinocchio\n\n# Benchmark CU\nanvil bench program.rs\n\n# Snapshot CUs\nanvil snapshot program.rs\n\n# Diff IRs\nanvil diff old.ir.json new.ir.json\n\n# Migration analysis\nanvil migrate diff old-layout.json new-layout.json\nanvil migrate codegen old-layout.json new-layout.json --output migration.rs","lang":"bash","description":"Shows installation, transpilation to Pinocchio, parsing to IR, portability linting, CU benchmarking, snapshotting, diffing, and migration analysis."},"warnings":[{"fix":"Install Bun from https://bun.sh before using anvil-sol.","message":"Requires Bun >=1.0.0 — Node.js and npm are not supported.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use import syntax or run via Bun which supports ESM.","message":"ESM-only module — CommonJS require() will fail.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Use pinocchio or native targets for production.","message":"Quasar target is experimental; cargo-build may fail and some CPIs emit TODO stubs.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade to >=0.3.0 for migration support.","message":"The `anvil migrate diff` command is new in 0.3; older versions don't have it.","severity":"deprecated","affected_versions":"<0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'curl -fsSL https://bun.sh/install | bash' to install Bun.","cause":"Bun is not installed or not in PATH.","error":"bun: command not found"},{"fix":"Install globally with 'bun install -g anvil-sol' or run with 'bunx anvil-sol'.","cause":"Package not installed or wrong import path.","error":"Error: Cannot find module 'anvil-sol'"},{"fix":"Use named imports like '{ compile }' instead of default import.","cause":"Using default import incorrectly; named exports are required.","error":"TypeError: anvil is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}