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

# Hesap Yönetimi

> Go'da hesapları, bakiyeleri ve rent'i yönetme yöntemleri

Hesapları fonlama, okuma ve yazma yöntemleri.

## Airdrop

```go
func (s *LiteSVM) Airdrop(pubkey solana.PublicKey, lamports uint64) error
```

Bir hesabı lamports ile fonlar. Dahili faucet'ten gerçek bir system-program
transferi olarak uygulanır; bu nedenle alıcı, ortaya çıkan bakiyeyi
tutabilecek durumda olmalıdır.

```go
priv, err := solana.NewRandomPrivateKey()
if err != nil {
    t.Fatal(err)
}
payer := priv.PublicKey()

// Airdrop 5 SOL
if err := svm.Airdrop(payer, 5_000_000_000); err != nil {
    t.Fatal(err)
}
```

## Bakiye

```go
func (s *LiteSVM) Balance(pubkey solana.PublicKey) (uint64, bool, error)
```

Hesabın SOL bakiyesini döndürür. Hesap mevcut değilse ikinci değer `false` olur;
bu durum, "hesap mevcut ve sıfır lamports içeriyor" durumundan farklıdır.

```go
lamports, ok, err := svm.Balance(payer)
if err != nil {
    t.Fatal(err)
}
if !ok {
    t.Log("account does not exist")
} else {
    t.Logf("balance: %d lamports (%.3f SOL)", lamports, float64(lamports)/1e9)
}
```

## GetAccount

```go
func (s *LiteSVM) GetAccount(pubkey solana.PublicKey) *solana.Account
```

Hesabın bir kopyasını döndürür; hesap mevcut değilse `nil` döndürür.
`*solana.Account`, [`gagliardetto/solana-go`](https://github.com/gagliardetto/solana-go) içindeki sade bir
struct'tır; dolayısıyla kapatılacak bir şey yoktur ve döndürülen değeri
değiştirmek, onu `SetAccount`'a iletene kadar SVM durumunu değiştirmez.

```go
acct := svm.GetAccount(payer)
if acct == nil {
    t.Fatal("account missing")
}

_ = acct.Lamports   // uint64
_ = acct.Owner      // solana.PublicKey
_ = acct.Executable // bool
_ = acct.RentEpoch  // uint64
_ = acct.Data       // []byte (copy)
```

### Hesap alanları

| Alan        | Tür               | Açıklama                       |
| ------------ | ------------------ | --------------------------------- |
| `Lamports`   | `uint64`           | SOL bakiyesi                       |
| `Owner`      | `solana.PublicKey` | Sahip program                    |
| `Executable` | `bool`             | Hesabın çalıştırılabilir olup olmadığı |
| `RentEpoch`  | `uint64`           | Rent epoch                        |
| `Data`       | `[]byte`           | Hesap verisinin kopyası          |

## NewAccount

```go
func NewAccount(lamports uint64, data []byte, owner solana.PublicKey, executable bool, rentEpoch uint64) (*solana.Account, error)
```

`SetAccount`'a iletilecek bir `*solana.Account` oluşturur. Hata sonucu her zaman
`nil`'dir; `&solana.Account{Lamports: rent, Data: payload, Owner: ownerProgramID}`
gibi bir composite literal de aynı işi görür.

```go
payload := []byte{1, 2, 3, 4}
rent, err := svm.MinimumBalanceForRentExemption(len(payload))
if err != nil {
    t.Fatal(err)
}

acct, err := litesvm.NewAccount(rent, payload, ownerProgramID, false, 0)
if err != nil {
    t.Fatal(err)
}
t.Logf("account: %d lamports, owner %s", acct.Lamports, acct.Owner)
```

## SetAccount

```go
func (s *LiteSVM) SetAccount(pubkey solana.PublicKey, acct *solana.Account) error
```

`acct` hesabının bir kopyasını `pubkey` adresinde saklar ve mevcut hesabın yerini
alır. SVM verinin kendi kopyasını tutar. Bir sysvar adresine yazmak o sysvar'ı
yeniler; sıfır lamports içeren bir hesap ise saklanmak yerine silinir.

```go
if err := svm.SetAccount(targetAddr, acct); err != nil {
    t.Fatal(err)
}
```

<Info>
  `SetAccount`, bir test için çok sayıda hesabı seed etmeniz gerektiğinde
  işlemleri yürütmekten çok daha hızlıdır. Lamports değerinin, veri boyutu için
  rent muafiyetine gereken asgari tutara eşit veya daha yüksek olduğundan emin olun.
</Info>

## MinimumBalanceForRentExemption

```go
func (s *LiteSVM) MinimumBalanceForRentExemption(dataLen int) (uint64, error)
```

Belirtilen veri uzunluğundaki bir hesabın rent'ten muaf olması için gereken
lamports miktarını hesaplar.

```go
for _, size := range []int{0, 100, 1024} {
    min, err := svm.MinimumBalanceForRentExemption(size)
    if err != nil {
        t.Fatal(err)
    }
    t.Logf("%4d bytes -> %d lamports", size, min)
}
```

## Program Yönetimi

### AddProgram

```go
func (s *LiteSVM) AddProgram(programID solana.PublicKey, programBytes []byte) error
```

Bellekteki baytlardan bir SBF programı yükler.

```go
bytes, err := os.ReadFile("./target/deploy/my_program.so")
if err != nil {
    t.Fatal(err)
}
if err := svm.AddProgram(programID, bytes); err != nil {
    t.Fatal(err)
}
```

### AddProgramFromFile

```go
func (s *LiteSVM) AddProgramFromFile(programID solana.PublicKey, path string) error
```

Bir `.so` dosya yolundan SBF programı yükler.

```go
if err := svm.AddProgramFromFile(programID, "./target/deploy/my_program.so"); err != nil {
    t.Fatal(err)
}
```

### AddProgramWithLoader

```go
func (s *LiteSVM) AddProgramWithLoader(programID solana.PublicKey, programBytes []byte, loader solana.PublicKey) error
```

Belirli bir loader altında SBF programı yükler. Varsayılan olmayan bir BPF
loader sürümüne karşı test yaparken kullanışlıdır.

## Toplu Hesap Kurulumu

Çok sayıda seed edilmiş hesap gerektiren testlerde `SetAccount` üzerinde döngü kurun:

```go
const N = 10
for i := 0; i < N; i++ {
    pk := solana.NewWallet().PublicKey()
    data := []byte{byte(i)}
    rent, err := svm.MinimumBalanceForRentExemption(len(data))
    if err != nil {
        t.Fatal(err)
    }

    acct, err := litesvm.NewAccount(rent, data, owner, false, 0)
    if err != nil {
        t.Fatal(err)
    }
    if err := svm.SetAccount(pk, acct); err != nil {
        t.Fatal(err)
    }
}
```

<Info>
  `SetAccount` hesap verisini kopyalar; bu nedenle çağrıdan sonra `acct`'yi
  SVM'yi etkilemeden yeniden kullanabilir veya değiştirebilirsiniz.
</Info>
