# `Cartouche.Solana.TokenProgram`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche/solana/token_program.ex#L1)

Instruction builders for the SPL Token Program.

Works with both SPL Token and Token-2022 via the `:token_program` option.
SPL Token uses a 1-byte instruction index (unlike System Program's 4-byte u32).

## Examples

    iex> ix = Cartouche.Solana.TokenProgram.transfer(<<1::256>>, <<2::256>>, <<3::256>>, 1_000_000)
    iex> ix.data
    <<3, 64, 66, 15, 0, 0, 0, 0, 0>>

# `approve`

```elixir
@spec approve(&lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, non_neg_integer(), keyword()) ::
  Cartouche.Solana.Transaction.Instruction.t()
```

Approve a delegate to transfer up to `amount` tokens from source.

## Options
- `:token_program` - Override the token program (default: SPL Token Program).

# `close_account`

```elixir
@spec close_account(&lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, keyword()) ::
  Cartouche.Solana.Transaction.Instruction.t()
```

Close a token account, transferring remaining SOL rent to destination.

## Options
- `:token_program` - Override the token program (default: SPL Token Program).

# `sync_native`

```elixir
@spec sync_native(
  &lt;&lt;_::256&gt;&gt;,
  keyword()
) :: Cartouche.Solana.Transaction.Instruction.t()
```

Sync the native SOL balance of a wrapped SOL token account.

## Options
- `:token_program` - Override the token program (default: SPL Token Program).

# `transfer`

```elixir
@spec transfer(&lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;, non_neg_integer(), keyword()) ::
  Cartouche.Solana.Transaction.Instruction.t()
```

Transfer tokens from source to destination.

The authority must sign the transaction.

## Options
- `:token_program` - Override the token program (default: SPL Token Program).

# `transfer_checked`

```elixir
@spec transfer_checked(
  &lt;&lt;_::256&gt;&gt;,
  &lt;&lt;_::256&gt;&gt;,
  &lt;&lt;_::256&gt;&gt;,
  &lt;&lt;_::256&gt;&gt;,
  non_neg_integer(),
  non_neg_integer(),
  keyword()
) :: Cartouche.Solana.Transaction.Instruction.t()
```

Transfer tokens with decimal verification (preferred over `transfer/5`).

Requires passing the mint, preventing accidental wrong-decimal transfers.

## Options
- `:token_program` - Override the token program (default: SPL Token Program).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
