> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Pierwsze kroki

> Zainstaluj LiteSVM i napisz swoje pierwsze testy.

Ten przewodnik omawia podstawy: jak utworzyć konto, zasilić konto i
wysłać transakcję.

<Steps titleSize="h2">

<Step title="Zainstaluj zależności">
<Tabs>
<Tab title="Rust">

Dodaj LiteSVM do zależności deweloperskich:

```bash
cargo add --dev litesvm
```

Kilka crate'ów Solana usprawnia testowanie, dostarczając niezbędne
typy i narzędzia. Przykłady na tej stronie korzystają z wygodnego crate'a `solana-sdk`
(przypiętego do linii 4.x, której używa LiteSVM 0.18) oraz crate'a z interfejsem System Program:

```bash
cargo add --dev solana-sdk@4
cargo add --dev solana-system-interface --features bincode
```

<Warning>
  Używaj `solana-sdk@4`, a nie najnowszej wersji głównej. Nowszy `solana-sdk` pobiera
  drugą kopię crate'ów składowych (`solana-keypair`,
  `solana-transaction` i innych), przez co typy przestają pasować do tych,
  których oczekuje LiteSVM. Jeśli wolisz, zamiast `solana-sdk` możesz dodać
  poszczególne crate'y składowe, które LiteSVM reeksportuje.
</Warning>

</Tab>
<Tab title="TypeScript">

```bash
npm install @solana/kit @solana/kit-plugin-litesvm @solana/kit-plugin-signer @solana-program/system
```

</Tab>
</Tabs>

</Step>

<Step title="Utwórz plik testowy">
<Tabs>
<Tab title="Rust">

W swoim workspace utwórz folder `tests`.

```bash
mkdir tests
```

</Tab>
<Tab title="TypeScript">

Utwórz nowy plik TypeScript dla testu. Testy używają `await` na najwyższym poziomie, więc
najpierw ustaw `"type": "module"` w pliku `package.json` (w przeciwnym razie `tsx` zakończy się błędem
`Top-level await is currently not supported with the "cjs" output format`):

```bash
npm pkg set type=module
touch basic-test.ts
```

</Tab>
</Tabs>

</Step>

<Step title="Utwórz i zasil konto">
<Tabs>
<Tab title="Rust">

Napiszmy Twój pierwszy test LiteSVM.

W folderze `tests` utwórz nowy plik i skopiuj ten kod:

```rust tests/create_account.rs
use litesvm::LiteSVM;
use solana_sdk::signature::{Keypair, Signer};

#[test]
fn create_account() {
    // Create the test environment
    let mut svm = LiteSVM::new();

    // Create a test account
    let user = Keypair::new();

    // Fund the account with SOL
    svm.airdrop(&user.pubkey(), 1_000_000_000).unwrap();

    // Check the balance
    let balance = svm.get_balance(&user.pubkey()).unwrap();
    assert_eq!(balance, 1_000_000_000);

    println!("Account funded with {} SOL", balance as f64 / 1e9);
}
```

</Tab>
<Tab title="TypeScript">

Skopiuj ten kod do pliku testowego:

```typescript basic-test.ts
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";

// Payer first, then the LiteSVM transport.
const mySigner = await generateKeyPairSigner();
const client = createClient().use(signer(mySigner)).use(litesvm());

// Fund the payer and check balance
client.svm.airdrop(client.payer.address, lamports(5_000_000_000n));
const balance = client.svm.getBalance(client.payer.address);
console.log("Balance:", balance, "lamports");
```

</Tab>
</Tabs>

</Step>

<Step title="Uruchom test">
<Tabs>
<Tab title="Rust">

```bash
cargo test create_account -- --show-output
```

Powinien pojawić się taki wynik:

```
running 1 test
test create_account ... ok

successes:

---- create_account stdout ----
Account funded with 1 SOL


successes:
    create_account
```

</Tab>
<Tab title="TypeScript">

```bash
npx tsx basic-test.ts
```

Powinien pojawić się taki wynik:

```
Balance: 5000000000n lamports
```

</Tab>
</Tabs>

<Info>
  Właśnie powstał Twój pierwszy test LiteSVM, który obejmuje tworzenie
  konta i jego zasilanie.
</Info>

</Step>

<Step title="Wykonaj transakcję">
Teraz utwórzmy transakcję przelewu.

<Tabs>
<Tab title="Rust">

Utwórz nowy plik testowy i skopiuj ten kod:

```rust tests/transfer_test.rs
use litesvm::LiteSVM;
use solana_sdk::{
    signature::{Keypair, Signer},
    transaction::Transaction,
};
use solana_system_interface::instruction as system_instruction;

#[test]
fn test_transfer() {
    let mut svm = LiteSVM::new();

    // Create two accounts
    let alice = Keypair::new();
    let bob = Keypair::new();

    // Fund Alice
    svm.airdrop(&alice.pubkey(), 2_000_000_000).unwrap();

    // Create transfer instruction
    let transfer = system_instruction::transfer(
        &alice.pubkey(),
        &bob.pubkey(),
        1_000_000_000, // 1 SOL
    );

    // Build and sign transaction
    let tx = Transaction::new_signed_with_payer(
        &[transfer],
        Some(&alice.pubkey()),
        &[&alice],
        svm.latest_blockhash(),
    );

    // Send it (execution happens immediately)
    svm.send_transaction(tx).unwrap();

    // Check new balances
    assert_eq!(svm.get_balance(&bob.pubkey()).unwrap(), 1_000_000_000);
    assert!(svm.get_balance(&alice.pubkey()).unwrap() < 1_000_000_000);

    println!("Transfer successful!");
}
```

</Tab>
<Tab title="TypeScript">

Utwórz nowy plik i skopiuj ten kod:

```typescript transfer-test.ts
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";
import { systemProgram } from "@solana-program/system";

// Payer first, then the LiteSVM transport, then program plugins.
const mySigner = await generateKeyPairSigner();
const client = createClient()
  .use(signer(mySigner))
  .use(litesvm())
  .use(systemProgram());
const recipient = await generateKeyPairSigner();

// Airdrop SOL to the payer
client.svm.airdrop(client.payer.address, lamports(2_000_000_000n));

// Build and send the transfer
await client.system.instructions
  .transferSol({
    source: client.payer,
    destination: recipient.address,
    amount: lamports(1_000_000_000n) // 1 SOL
  })
  .sendTransaction();

// Check new balances
const recipientBalance = client.svm.getBalance(recipient.address) ?? 0n;
console.log("Recipient balance:", Number(recipientBalance) / 1e9, "SOL");
console.log("Transfer successful!");
```

</Tab>
</Tabs>

<Info>
  Ten test obejmuje wykonanie instrukcji transferu z programu
  System Program.
</Info>

</Step>

<Step title="Uruchom wszystkie testy">
<Tabs>
<Tab title="Rust">

```bash
cargo test -- --show-output
```

Powinien pojawić się taki wynik:

```
running 1 test
test create_account ... ok

successes:

---- create_account stdout ----
Account funded with 1 SOL


successes:
    create_account

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

     Running tests/transfer_test.rs (target/debug/deps/transfer_test-f174954e7483f36b)

running 1 test
test test_transfer ... ok

successes:

---- test_transfer stdout ----
Transfer successful!


successes:
    test_transfer

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

   Doc-tests litesvm_quickstart

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```

</Tab>
<Tab title="TypeScript">

```bash
npx tsx basic-test.ts && npx tsx transfer-test.ts
```

Powinien pojawić się taki wynik:

```
Balance: 5000000000n lamports
Recipient balance: 1 SOL
Transfer successful!
```

</Tab>
</Tabs>

<Info>
  Masz już testy LiteSVM, które tworzą i zasilają konta oraz wykonują transakcje.
</Info>
</Step>

</Steps>

## Dalsze kroki

**[Dlaczego LiteSVM →](/developers/docs/tools/litesvm/core-concepts)** Dowiedz się, dlaczego warto
używać LiteSVM do testowania

<Tabs>
  <Tab title="Rust">
    **[Testowanie własnego programu →](/developers/docs/tools/litesvm/testing-your-program)** Dowiedz się,
    jak testować własny program Solana <br /> **[Przykłady
    →](/developers/docs/tools/litesvm/examples)** Zobacz gotowe do skopiowania rozwiązania dla typowych
    scenariuszy oraz pełne przykłady repozytoriów <br /> **[Dokumentacja API
    →](/developers/docs/tools/litesvm/api-reference)** Poznaj zaawansowane funkcje i niestandardowe
    konfiguracje
  </Tab>
  <Tab title="TypeScript">
    **[Testowanie własnego programu →](/developers/docs/tools/litesvm/typescript/getting-started)**
    Dowiedz się, jak testować własny program Solana za pomocą LiteSVM dla TypeScript{" "}
    <br /> **[Przykłady →](/developers/docs/tools/litesvm/typescript/examples)** Zobacz
    gotowe do skopiowania rozwiązania dla typowych scenariuszy <br /> **[Dokumentacja API
    →](/developers/docs/tools/litesvm/typescript/api-reference)** Poznaj zaawansowane funkcje
    i niestandardowe konfiguracje
  </Tab>
</Tabs>
