> ## 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.

# İşlemler

> Go'da LiteSVM ile işlemleri çalıştırın ve simüle edin

İşlemleri göndermek, simüle etmek ve yönetmek için kullanılan metotlar. Hem eski (legacy) hem de v0+
sürümlü işlemler desteklenir.

`litesvm-go`, [`gagliardetto/solana-go`](https://github.com/gagliardetto/solana-go) paketindeki
`(*solana.Transaction).MarshalBinary` tarafından üretilen bincode kodlu işlem baytlarını kabul eder.

## SendLegacyTransaction

```go
func (s *LiteSVM) SendLegacyTransaction(txBytes []byte) (*TxOutcome, error)
```

Bincode kodlu bir eski (legacy) `Transaction` gönderir. Başarılı olursa işlem
bellek içi deftere (ledger) işlenir.

```go
out, err := svm.SendLegacyTransaction(txBytes)
if err != nil {
    t.Fatal(err)
}

if !out.IsOk() {
    t.Fatalf("tx failed: %s\nlogs: %v", out.Error(), out.Logs())
}

t.Logf("signature: %s", out.Signature())
t.Logf("compute:   %d CU", out.ComputeUnits())
t.Logf("fee:       %d lamports", out.Fee())
```

<Warning>
  Dönen hata, yalnızca baytlar çözümlenemediğinde veya dahili bir hata oluştuğunda nil olmaz. *Çalışıp başarısız olan* bir işlem de
  nil olmayan bir `*TxOutcome` döndürür; yalnızca başarı durumunda geçerli olan durumu kullanmadan önce
  her zaman `IsOk()` değerini kontrol edin.
</Warning>

## SendVersionedTransaction

```go
func (s *LiteSVM) SendVersionedTransaction(txBytes []byte) (*TxOutcome, error)
```

`SendLegacyTransaction` ile aynı yapıdadır, ancak v0+ mesajlar içindir. `solana-go`'nun
`MarshalBinary` metodu her iki durum için de doğru baytları üretir.

## SimulateLegacyTransaction / SimulateVersionedTransaction

```go
func (s *LiteSVM) SimulateLegacyTransaction(txBytes []byte) (*TxOutcome, error)
func (s *LiteSVM) SimulateVersionedTransaction(txBytes []byte) (*TxOutcome, error)
```

İşlemi durumu işlemeden (commit etmeden) çalıştırır. Aynı `*TxOutcome` yapısı
döndürülür; ayrıca `PostAccounts()`, yazılabilir hesapların işlem sonrasında olması beklenen
durumuyla doldurulur.

```go
sim, err := svm.SimulateLegacyTransaction(txBytes)
if err != nil {
    t.Fatal(err)
}

if !sim.IsOk() {
    t.Fatalf("sim failed: %s", sim.Error())
}

t.Logf("would use %d compute units", sim.ComputeUnits())
t.Logf("logs: %v", sim.Logs())

posts, err := sim.PostAccounts()
if err != nil {
    t.Fatal(err)
}
for _, p := range posts {
    t.Logf("%s: %d lamports", p.Address, p.Account.Lamports)
}
```

<Info>
  Simülasyon durumu değiştirmez. Hesaplama bütçelerini belirlemek veya
  defterinizi kirletmeden günlükleri (log) doğrulamak için kullanın.
</Info>

## TxOutcome

Her gönderme / simülasyon çağrısı, başarı veya başarısızlıktan bağımsız olarak aynı üst verileri taşıyan bir `*TxOutcome` döndürür.
Tüm erişimci (accessor) metotlar `nil` alıcıyı tolere eder ve
sıfır değerler döndürür.

| Metot                | Dönüş değeri                            | Açıklama                                               |
| --------------------- | ---------------------------------- | --------------------------------------------------------- |
| `IsOk()`              | `bool`                             | İşlem başarılı oldu                                     |
| `Error()`             | `string`                           | Agave wire-format JSON hatası, örneğin `"BlockhashNotFound"` (başarılıysa boş) |
| `Signature()`         | `solana.Signature`                 | İşlem imzası                                     |
| `ComputeUnits()`      | `uint64`                           | Tüketilen hesaplama birimleri                                    |
| `Fee()`               | `uint64`                           | Tahsil edilen ücret                                               |
| `Logs()`              | `[]string`                         | Program günlükleri                                              |
| `ReturnData()`        | `(solana.PublicKey, []byte, bool)` | `set_return_data` ile ayarlanan dönüş verisi; yoksa `ok=false` |
| `InnerInstructions()` | `InnerInstructionsList`            | Üst düzey talimata göre gruplanmış CPI'lar                     |
| `PostAccounts()`      | `([]PostAccount, error)`           | İşlem sonrası durum - yalnızca simülasyonda                      |

### InnerInstruction

```go
type InnerInstruction struct {
    Instruction solana.CompiledInstruction // indices point into the transaction's account table
    StackHeight uint16                     // 1 for top-level, higher for deeper CPIs
}

type InnerInstructionsList [][]InnerInstruction
```

`InnerInstructions()`, her CPI grubunu tetikleyen üst düzey talimata göre
indekslenmiş bir slice döndürür.

### PostAccount

```go
type PostAccount struct {
    Address solana.PublicKey
    Account *solana.Account
}
```

Simülasyonlar için `PostAccounts()` tarafından döndürülür.

## Blockhash Yönetimi

### LatestBlockhash

```go
func (s *LiteSVM) LatestBlockhash() (solana.Hash, error)
```

Geçerli blockhash değerini okur. İşlem oluştururken bunu
`solana.NewTransaction(...)` fonksiyonuna geçirin.

```go
blockhash, err := svm.LatestBlockhash()
if err != nil {
    t.Fatal(err)
}

tx, _ := solana.NewTransaction(
    []solana.Instruction{ix},
    blockhash,
    solana.TransactionPayer(payer),
)
_ = tx // sign, marshal and send it
```

### ExpireBlockhash

```go
func (s *LiteSVM) ExpireBlockhash() error
```

Geçerli blockhash'i geçerek ilerler; böylece bir sonraki `LatestBlockhash` çağrısı yeni bir
değer döndürür. Daha eski bir blockhash ile imzalanan işlemler bu durumda
`"BlockhashNotFound"` hatasıyla başarısız olur; bu, blockhash süresinin dolmasıyla ilgili uç durumları test etmek için kullanışlıdır.

```go
bh1, err := svm.LatestBlockhash()
if err != nil {
    t.Fatal(err)
}
if err := svm.ExpireBlockhash(); err != nil {
    t.Fatal(err)
}
bh2, err := svm.LatestBlockhash()
if err != nil {
    t.Fatal(err)
}
// bh1 != bh2
_, _ = bh1, bh2
```

## İşlem Geçmişi

İşlem geçmişi varsayılan olarak açıktır ve tekrar gönderimleri (replay) algılayan da budur: aynı
imzalı işlemi iki kez göndermek, `AlreadyProcessed` hatasıyla bir sonuç döndürür. Kapasiteyi (veya mükerrer kayıt denetimini devre dışı bırakmayı)
`SetTransactionHistory` ile ayarlayabilirsiniz:

```go
// Cap history at 100 entries.
if err := svm.SetTransactionHistory(100); err != nil {
    t.Fatal(err)
}

// Disable dedup entirely (allows replaying identical transactions).
if err := svm.SetTransactionHistory(0); err != nil {
    t.Fatal(err)
}
```

Bir önceki işlemi imzasına göre sorgulayın (geçmiş varsayılan olarak en son 32 işlemi tutar; çalıştırılmış ancak başarısız olanlar da dahildir):

```go
prior := svm.GetTransaction(sig) // nil if unknown
if prior != nil {
    t.Logf("found: %s, fee=%d", prior.Signature(), prior.Fee())
}
```

## BuildTransferTx (test yardımcısı)

```go
func BuildTransferTx(
    payerSeed [32]byte,
    to solana.PublicKey,
    lamports uint64,
    blockhash solana.Hash,
) ([]byte, error)
```

`blockhash` kullanarak, `payerSeed` değerinden türetilen keypair'den `to` adresine `lamports` transfer eden,
bincode kodlu ve imzalı bir eski (legacy) `Transaction` üretir. Dönen
baytlar doğrudan `SendLegacyTransaction` fonksiyonuna verilmeye hazırdır. Ödeyen taraf,
tohumdan türetilen keypair'dir; bu yüzden önce adresini fonlayın (örneğin
`Airdrop` ile); aksi halde işlem `"InsufficientFundsForFee"` hatasıyla başarısız olur.

```go
var seed [32]byte
copy(seed[:], somePayerSeedBytes)

bh, err := svm.LatestBlockhash()
if err != nil {
    t.Fatal(err)
}
txBytes, err := litesvm.BuildTransferTx(seed, recipient, 1_000_000_000, bh)
if err != nil {
    t.Fatal(err)
}

out, err := svm.SendLegacyTransaction(txBytes)
if err != nil {
    t.Fatal(err)
}
if !out.IsOk() {
    t.Fatalf("tx failed: %s", out.Error())
}
```

<Info>
  Bu, testleri başlatmak için vardır. Gerçek işlemler oluşturmaya başladığınızda, yukarıda gösterilen `solana-go`
  yolunu tercih edin - birden fazla talimat içeren işlemlere, v0 mesajlarına
  ve her türlü programa ölçeklenir.
</Info>
