{"_id":"@axvn-vn/kit-plugin-litesvm","_rev":"3-1768520f7725c88347a9aa17898b7921","name":"@axvn-vn/kit-plugin-litesvm","dist-tags":{"latest":"0.0.0"},"versions":{"0.0.0":{"name":"@axvn-vn/kit-plugin-litesvm","version":"0.0.0","keywords":["LiteSVM","kit","plugin","solana"],"license":"MIT","_id":"@axvn-vn/kit-plugin-litesvm@0.0.0","maintainers":[{"name":"davidtran76","email":"Farm15ceo@gmail.com"}],"homepage":"https://github.com/anza-xyz/kit-plugins#readme","bugs":{"url":"http://github.com/anza-xyz/kit-plugins/issues"},"dist":{"shasum":"399c1277592959bbb0866dfca13b569bdb87493c","tarball":"https://registry.npmjs.org/@axvn-vn/kit-plugin-litesvm/-/kit-plugin-litesvm-0.0.0.tgz","fileCount":42,"integrity":"sha512-zE58Tj8YdpDUukxTU/yDPyISADdCa+QqvZenvd1KmGkJUXcq9jiruLCASBeDghdWqiAthM+NrZTSzi8P0du+tg==","signatures":[{"sig":"MEUCIERXMPv6wAI/vp29U5Emyucx3Km9fqEhYnAj01JKscqEAiEAmSAngcq4+hv1g603xXEeyN5Q3q/8JWi7Su+ip34EVUQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":319072},"main":"./dist/index.node.cjs","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/index.node.mjs","browser":{"./dist/index.node.cjs":"./dist/index.browser.cjs","./dist/index.node.mjs":"./dist/index.browser.mjs"},"exports":{"node":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"types":"./dist/types/index.d.ts","browser":{"import":"./dist/index.browser.mjs","require":"./dist/index.browser.cjs"},"react-native":"./dist/index.react-native.mjs"},"scripts":{"dev":"vitest --project node","test":"pnpm test:types && pnpm test:treeshakability && pnpm test:unit","test:unit":"vitest run","test:types":"tsc --noEmit","test:treeshakability":"for file in dist/index.*.mjs; do agadoo $file; done"},"_npmUser":{"name":"davidtran76","email":"Farm15ceo@gmail.com"},"repository":{"url":"git+https://github.com/anza-xyz/kit-plugins.git","type":"git"},"_npmVersion":"11.17.0","description":"LiteSVM support for Kit clients","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","browserslist":["supports bigint and not dead","maintained node versions"],"dependencies":{"litesvm":"^1.3.0","@axvn-vn/kit-plugin-instruction-plan":"0.18.0"},"react-native":"./dist/index.react-native.mjs","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"@solana-program/system":"^0.13.0"},"peerDependencies":{"@axvn-vn/kit":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/kit-plugin-litesvm_0.0.0_1787355402150_0.8059996688686251","host":"s3://npm-registry-packages-npm-production"},"deprecated":"DEPRECATED: This package has been removed. Do not use."}},"time":{"created":"2026-08-21T23:36:41.952Z","modified":"2026-08-22T16:10:41.988Z","0.0.0":"2026-08-21T23:36:42.288Z"},"bugs":{"url":"http://github.com/anza-xyz/kit-plugins/issues"},"license":"MIT","homepage":"https://github.com/anza-xyz/kit-plugins#readme","keywords":["LiteSVM","kit","plugin","solana"],"repository":{"url":"git+https://github.com/anza-xyz/kit-plugins.git","type":"git"},"description":"LiteSVM support for Kit clients","maintainers":[{"name":"davidtran76","email":"Farm15ceo@gmail.com"},{"name":"nhamhuan","email":"Nhamhuan@gmail.com"}],"readme":"# Kit Plugins ➤ LiteSVM\n\n[![npm][npm-image]][npm-url]\n[![npm-downloads][npm-downloads-image]][npm-url]\n\n[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/kit-plugin-litesvm.svg?style=flat\n[npm-image]: https://img.shields.io/npm/v/@solana/kit-plugin-litesvm.svg?style=flat&label=%40solana%2Fkit-plugin-litesvm\n[npm-url]: https://www.npmjs.com/package/@solana/kit-plugin-litesvm\n\nThis package provides a plugin that adds LiteSVM functionality to your Kit clients.\n\n## Installation\n\n```sh\npnpm install @solana/kit-plugin-litesvm\n```\n\n## `litesvm` plugin\n\nThe `litesvm` plugin sets up a full LiteSVM client in a single call. It installs an SVM connection, airdrop support, minimum balance computation, transaction planning, and transaction execution on the client.\n\nThe client must have a `payer` set before applying this plugin.\n\n> [!IMPORTANT]\n> This plugin is only available in Node.js builds. Browser and React Native builds throw an error when calling `litesvm()`.\n\n### Installation\n\n```ts\nimport { createClient } from '@solana/kit';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { payer } from '@solana/kit-plugin-signer';\n\nconst client = createClient().use(payer(myPayer)).use(litesvm());\n```\n\n### Options\n\nAll options are provided via a `LiteSvmConfig` object:\n\n- `transactionConfig`: Options to configure how transaction messages are created. See the `litesvmTransactionPlanner` options below.\n\n### Features\n\n- `svm`: Access the underlying LiteSVM instance.\n- `rpc`: Call a subset of Solana RPC methods against the LiteSVM instance.\n- `airdrop`: Request SOL from the LiteSVM faucet.\n- `getMinimumBalance`: Compute minimum lamports for rent exemption.\n- `planTransaction(s)`: Plan instructions into transaction messages without executing them.\n- `sendTransaction(s)`: Plan and execute instructions, instruction plans, or transaction messages in one call.\n- `transactionPlanner` / `transactionPlanExecutor` (deprecated): Fields kept for backward compatibility. Use `planTransaction(s)` / `sendTransaction(s)` instead.\n\n## `litesvmConnection` plugin\n\nThe LiteSVM plugin starts a new LiteSVM instance within your Kit client, allowing you to simulate Solana programs and accounts locally. Additionally, it derives a small RPC subset that interacts with the LiteSVM instance instead of making network requests.\n\n> [!IMPORTANT]\n> This plugin is only available in Node.js builds. Browser and React Native builds throw an error when calling `litesvmConnection()`.\n\n### Installation\n\n```ts\nimport { createClient } from '@solana/kit';\nimport { litesvmConnection } from '@solana/kit-plugin-litesvm';\n\nconst client = createClient().use(litesvmConnection());\n```\n\n### Features\n\n- `svm`: Access the underlying LiteSVM instance.\n    ```ts\n    client.svm.setAccount(myAccount);\n    client.svm.addProgramFromFile(myProgramAddress, 'my_program.so');\n    ```\n- `rpc`: Call a subset of Solana RPC methods against the LiteSVM instance. Currently supported methods are: `getAccountInfo`, `getBalance`, `getEpochSchedule`, `getLatestBlockhash`, `getMinimumBalanceForRentExemption`, `getMultipleAccounts`, `getProgramAccounts`, `getSlot`, and `requestAirdrop`.\n    ```ts\n    const { value: latestBlockhash } = await client.rpc.getLatestBlockhash().send();\n    ```\n\n## `litesvmAirdrop` plugin\n\nThis plugin adds an `airdrop` method to your Kit client that airdrops SOL using the underlying LiteSVM instance. It performs error handling and returns the transaction signature on success.\n\n### Installation\n\nThe client must have the `litesvmConnection` plugin installed before applying this plugin.\n\n```ts\nimport { createClient } from '@solana/kit';\nimport { litesvmConnection, litesvmAirdrop } from '@solana/kit-plugin-litesvm';\n\nconst client = createClient().use(litesvmConnection()).use(litesvmAirdrop());\n```\n\n### Features\n\n- `airdrop`: An asynchronous helper function that airdrops a specified amount of lamports to a given address.\n    ```ts\n    await client.airdrop(address('HQVxiMVDoV9jzG4tpoxmDZsNfWvaHXm8DGGv93Gka75v'), lamports(1_000_000_000n));\n    ```\n\n## `litesvmGetMinimumBalance` plugin\n\nThis plugin adds a `getMinimumBalance` method to your Kit client that computes the minimum lamports required for an account with a given data size, using the underlying LiteSVM instance.\n\n### Installation\n\nThe client must have the `litesvmConnection` plugin installed before applying this plugin.\n\n```ts\nimport { createClient } from '@solana/kit';\nimport { litesvmConnection, litesvmGetMinimumBalance } from '@solana/kit-plugin-litesvm';\n\nconst client = createClient().use(litesvmConnection()).use(litesvmGetMinimumBalance());\n```\n\n### Features\n\n- `getMinimumBalance`: An asynchronous helper that returns the minimum lamports required for an account with the given data size. By default, the 128-byte account header is included on top of the provided space.\n\n    ```ts\n    // Minimum balance for an account with 100 bytes of data (plus header).\n    const balance = await client.getMinimumBalance(100);\n\n    // Minimum balance for exactly 100 bytes (without adding the header).\n    const rawBalance = await client.getMinimumBalance(100, { withoutHeader: true });\n    ```\n\n## `litesvmTransactionPlanner` plugin\n\nAdds `planTransaction` and `planTransactions` to the client, using a planner that plans instructions into transaction messages with a fee payer and optional priority fees. The fee payer is read from `client.payer` lazily, at plan time, so a dynamic payer (such as a connected wallet) is always respected.\n\n### Usage\n\nThe client must have a `payer` set before installing the plugin.\n\n```ts\nimport { createClient } from '@solana/kit';\nimport {\n    litesvmConnection,\n    litesvmTransactionPlanSendingExecutor,\n    litesvmTransactionPlanner,\n} from '@solana/kit-plugin-litesvm';\nimport { generatedPayer } from '@solana/kit-plugin-signer';\n\nconst client = await createClient()\n    .use(litesvmConnection())\n    .use(generatedPayer())\n    .use(litesvmTransactionPlanner())\n    .use(litesvmTransactionPlanSendingExecutor());\n\nconst transactionPlan = await client.planTransactions(myInstructionPlan);\n```\n\n### Options\n\nAll options are provided via a `TransactionPlannerConfig` object. Its shape is discriminated by the transaction `version`.\n\nFor legacy and version 0 transactions:\n\n- `version`: The transaction message version to use. Accepts `0` or `'legacy'`. Defaults to `0`.\n- `microLamportsPerComputeUnit`: The priority fee in micro-lamports per compute unit, added as a `setComputeUnitPrice` instruction. Defaults to no priority fees.\n\nUnlike the RPC planner, the LiteSVM planner does not estimate resource limits, since LiteSVM executes transactions locally without a simulation-based estimation step.\n\nVersion 1 transactions are defined for forward compatibility but are not yet buildable by `@solana/kit`; passing `version: 1` currently throws. When available, version 1 will accept `priorityFeeLamports` (a flat total in lamports) instead of `microLamportsPerComputeUnit`.\n\n## `litesvmTransactionPlanSendingExecutor` plugin\n\nAdds `sendTransaction` and `sendTransactions` to the client, using an executor that signs and sends transactions to the LiteSVM instance. When a transaction fails, it throws a `SolanaError` with the same error codes the RPC executor would produce. The executor stores the LiteSVM transaction metadata (`FailedTransactionMetadata` or `TransactionMetadata`) on `context.transactionMetadata`, so consumers can inspect logs, compute units consumed, and return data from the plan result.\n\n### Usage\n\nThe client must have an `svm` instance configured, and a transaction planner installed, before installing this plugin — sending plans through the client's planning functions.\n\n```ts\nimport { createClient } from '@solana/kit';\nimport {\n    litesvmConnection,\n    litesvmTransactionPlanSendingExecutor,\n    litesvmTransactionPlanner,\n} from '@solana/kit-plugin-litesvm';\nimport { generatedPayer } from '@solana/kit-plugin-signer';\n\nconst client = await createClient()\n    .use(litesvmConnection())\n    .use(generatedPayer())\n    .use(litesvmTransactionPlanner())\n    .use(litesvmTransactionPlanSendingExecutor());\n\nconst transactionPlanResult = await client.sendTransactions(myInstructionPlan);\n```\n\n### Result context\n\nAs it works through a transaction, the executor records the planned message (once its blockhash lifetime is set), the fully signed transaction, the signature it was sent under, and the LiteSVM metadata the send produced. A successful plan result carries all four on its `context`, and the exported `LiteSvmSendContext` type names that shape so you can annotate results yourself.\n\n```ts\nimport { SuccessfulSingleTransactionPlanResult } from '@solana/kit';\nimport { isFailedTransaction, LiteSvmSendContext } from '@solana/kit-plugin-litesvm';\n\nfunction logComputeUnits(result: SuccessfulSingleTransactionPlanResult<LiteSvmSendContext>) {\n    const { signature, transactionMetadata } = result.context;\n    if (!isFailedTransaction(transactionMetadata)) {\n        console.log(`${signature} consumed ${transactionMetadata.computeUnitsConsumed()} compute units`);\n    }\n}\n```\n\nBecause the context is filled in as execution progresses, a transaction that fails or is canceled part way through carries only what was recorded before it stopped. Failed and canceled results therefore type the context as partial — only successful results guarantee every field.\n\nThe `sendTransaction` and `sendTransactions` functions installed by this plugin propagate this context type, so their results carry a typed `LiteSvmSendContext` without any annotation needed.\n\n## Deprecated plugins\n\nThe following plugins are still exported for backward compatibility but are deprecated.\n\n- `litesvmTransactionPlanExecutor()`: Only sets the deprecated `client.transactionPlanExecutor` field. Use `litesvmTransactionPlanSendingExecutor` instead, which installs `sendTransaction` and `sendTransactions` alongside the executor.\n\n    ```ts\n    // Before\n    const client = await createClient()\n        .use(litesvmTransactionPlanner())\n        .use(litesvmTransactionPlanExecutor())\n        .use(planAndSendTransactions());\n\n    // After\n    const client = await createClient().use(litesvmTransactionPlanner()).use(litesvmTransactionPlanSendingExecutor());\n    ```\n","readmeFilename":"README.md"}