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

# Build Custom Transactions

The built-in helpers cover common flows. Use `wallet.buildTransaction(...)` or
`wallet.build_transaction(...)` when you still want hosted preparation but need
your own instruction set.

## What it does

The custom transaction builder prepares a transaction for an existing Swig
wallet from a list of Solana instructions you provide.

Use it when:

* the transfer and swap helpers are not enough
* you already know the exact instruction bundle you want to run
* you still want the backend to prepare the final wallet transaction

## Example

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  const prepared = await wallet.buildTransaction({
    feePayer,
    instructions: [
      {
        programId: targetProgramId,
        accounts: [
          {
            pubkey: writableAccount,
            isWritable: true,
          },
          {
            pubkey: readonlyAccount,
          },
        ],
        data: Buffer.from(instructionData).toString('base64'),
      },
    ],
    addressLookupTableAccounts: [lookupTableAddress],
  });
  ```

  ```python Python theme={null}
  from swig_developer_sdk import SolanaAccountMeta, SolanaInstructionInput

  prepared = await wallet.build_transaction(
      fee_payer=fee_payer,
      instructions=(
          SolanaInstructionInput(
              program_id=target_program_id,
              accounts=(
                  SolanaAccountMeta(
                      pubkey=writable_account,
                      is_writable=True,
                  ),
                  SolanaAccountMeta(pubkey=readonly_account),
              ),
              data=instruction_data,
          ),
      ),
      address_lookup_table_accounts=(lookup_table_address,),
  )
  ```
</CodeGroup>

The SDK normalizes the instruction input and sends it to
`POST /transaction/prepare/custom`. The API returns the prepared transaction
for your client-signing and submission flow.

## What still applies

This is still a prepared transaction result. That means:

* your app still checks `signatureRequests` / `signature_requests`
* the client still signs if required
* your app still chooses direct submission or sponsor submission

## Full protocol control

Use the [Protocol SDK](/reference) for full protocol control, custom role or
action construction, or instruction-by-instruction authoring.
