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

# Transfers

> Send SOL and SPL tokens from a Swig wallet.

## Introduction

A transfer sends SOL or tokens from the wallet using a role with the matching asset allowance.

* **Use when:** your application pays a recipient from wallet-owned funds.
* **For:** payment flows, withdrawal screens, and automated disbursements.

## How it works

1. Fetch the wallet and use its wallet address as the source or token-account owner.
2. Choose a role with access to the transfer program and the required spending budget.
3. Build the transfer in integer base units and authorize it through Swig.
4. Sign, submit, and confirm the returned transaction instructions.

## Transfer inputs

| Asset | Amount unit | Destination | Scoped permissions |
| - | - | - | - |
| SOL | Lamports | Recipient public key | System Program access and SOL allowance |
| SPL token | Mint base units | Recipient token account | Token Program access and allowance for the mint |

For tokens, create the recipient token account first if it does not exist. This example uses the original SPL Token program.

## SDK example

### SOL

The [SOL signing example](https://build.onswig.com/solana/transactions/signing.md#ed25519-signer) builds a 0.001 SOL transfer. Send its result using [Sending transactions](https://build.onswig.com/solana/transactions/sending.md).

### SPL tokens

Install the token client:

```bash theme={null}
npm install @solana/spl-token
```

Supply the mint, an existing destination token account for that mint, and an amount in base units. The function reads the mint's decimals and uses the wallet's associated token account as the source.

```typescript theme={null}
import { type Connection, type PublicKey } from "@solana/web3.js";
import {
  createTransferCheckedInstruction,
  getAssociatedTokenAddressSync,
  getMint,
} from "@solana/spl-token";
import { fetchSwig, getSignInstructions, getSwigWalletAddress } from "@swig-wallet/classic";

async function prepareTokenTransfer(
  connection: Connection,
  configAddress: PublicKey,
  roleId: number,
  payer: PublicKey,
  mint: PublicKey,
  recipientTokenAccount: PublicKey,
  amount: bigint,
) {
  const swig = await fetchSwig(connection, configAddress);
  const walletAddress = await getSwigWalletAddress(swig);
  const source = getAssociatedTokenAddressSync(mint, walletAddress, true);
  const mintInfo = await getMint(connection, mint);
  const transfer = createTransferCheckedInstruction(
    source,
    mint,
    recipientTokenAccount,
    walletAddress,
    amount,
    mintInfo.decimals,
  );
  return getSignInstructions(swig, roleId, [transfer], false, { payer });
}
```

* `true` allows the wallet's program-derived address to own the associated token account.
* Grant `tokenLimit({ mint, amount })` or a matching recurring/destination permission alongside Token Program access.
* This example uses an Ed25519 role. Other authorities supply their [signing options](https://build.onswig.com/solana/transactions/signing.md).
* [Send and confirm](https://build.onswig.com/solana/transactions/sending.md) the returned instructions with the role signer and payer.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.