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

# Prepare Arbitrary Transaction

> Prepare arbitrary transactions using your Smart Account as a signer

Execute any arbitrary transaction using your Smart Account as a signer. This is one of the core functionalities of a Smart Account - it enables you to use your Smart Account like a regular Solana wallet, but with the added security of multi-signature controls and self-custodial programmability.

### Key Concepts

* **Smart Account as a Signer**: Your Smart Account can act as a signer for any Solana transaction, just like a regular wallet. This means you can interact with any protocol or program on Solana.

* **Multi-signature Security**: The transaction will only be executed if it meets the Smart Account's threshold requirements. For example, if your Smart Account requires 2-of-3 signatures, you'll need to provide at least 2 valid signatures from authorized signers.

* **Transaction Preparation**: The transaction you provide should be properly constructed and encoded in base64 format. This transaction should include all the instructions you want to execute.

### Common Use Cases

1. **Token Transfers**: Send tokens from your Smart Account to any recipient
2. **DeFi Interactions**: Interact with DeFi protocols (swaps, lending, etc.)
3. **NFT Operations**: Buy, sell, or transfer NFTs
4. **Program Interactions**: Call any program on Solana with your Smart Account as the signer

<Note>Message signing is currently not supported on smart accounts.</Note>

### Important Notes

* The transaction must be properly constructed and include all necessary instructions
* All provided transaction\_signers must be registered signers of the Smart Account
* The number of valid signatures must meet or exceed the Smart Account's threshold

<Note>
  The submitted instructions must be under 1050 bytes to allow for fee
  configuration instructions.
</Note>

### Constructing Instructions

When building your instructions, treat them as regular Solana transactions but use your Smart Account's address wherever you would normally use a signer's address. For example:

```typescript theme={null}
// If you're transferring tokens, use your Smart Account's address as the owner
const transferInstruction = createTransferInstruction(
  sourceTokenAccount, // from token account (owned by Smart Account)
  destinationTokenAccount, // to token account
  smartAccountAddress, // owner (Smart Account address)
  amount
);
```


## OpenAPI

````yaml POST /api/v0/smart_account/transaction/prepare
openapi: 3.0.3
info:
  title: Squads Smart Account API
  version: 0.1.0
  description: >
    The Squads Smart Account API enables creation and management of Smart
    Accounts on Solana. It provides endpoints for creating smart accounts,
    managing signers, thresholds, and spending limits.
servers:
  - url: https://developer-api.squads.so
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Smart Account
    description: Endpoints for Smart Account management
paths:
  /api/v0/smart_account/transaction/prepare:
    parameters:
      - $ref: '#/components/parameters/NetworkParam'
    post:
      tags:
        - Smart Account
      summary: Prepare Transaction
      description: Prepares a transaction for a Smart Account with the required signers
      operationId: prepareArbitraryTransaction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrepareArbitraryTransactionRequest'
      responses:
        '200':
          description: Transaction successfully prepared
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrepareArbitraryTransactionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    NetworkParam:
      name: x-squads-network
      in: header
      schema:
        type: string
        enum:
          - devnet
          - mainnet
        default: mainnet
      required: false
      description: >
        Specifies which Solana network to use. Defaults to 'mainnet' if not
        provided.

        Valid values are 'devnet' or 'mainnet'.
  schemas:
    PrepareArbitraryTransactionRequest:
      type: object
      required:
        - smart_account_address
        - transaction
        - transaction_signers
        - fee_config
      properties:
        smart_account_address:
          type: string
          pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
          description: The address of the Smart Account
        transaction:
          type: string
          description: The transaction to prepare encoded in base64
        transaction_signers:
          type: array
          items:
            type: string
            pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
          description: List of addresses that will sign this transaction
        fee_config:
          $ref: '#/components/schemas/FeeConfig'
    PrepareArbitraryTransactionResponse:
      type: object
      required:
        - transaction
        - fee
      properties:
        transaction:
          type: string
          description: The transaction encoded in base64
        fee:
          $ref: '#/components/schemas/Fee'
    FeeConfig:
      type: object
      required:
        - currency
        - payer_address
      properties:
        currency:
          type: string
          enum:
            - sol
            - usdc
          description: The currency to pay fees in
        payer_address:
          type: string
          pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
          description: The address that will pay the fees
    Fee:
      type: object
      required:
        - amount
        - amount_decimal
        - currency
        - sol_equivalent
      properties:
        amount:
          type: string
          format: uint64
          description: The fee amount in base units
        amount_decimal:
          type: string
          description: The fee amount as a decimal string
        currency:
          type: string
          description: The currency of the fee (e.g. 'sol', 'usdc')
        sol_equivalent:
          $ref: '#/components/schemas/SolEquivalent'
    SolEquivalent:
      type: object
      required:
        - amount
        - amount_decimal
      properties:
        amount:
          type: string
          format: uint64
          description: The amount in lamports (SOL base units)
        amount_decimal:
          type: string
          description: The amount as a decimal string in SOL
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Authorization header using the Bearer scheme.
        Example: "Authorization: Bearer {token}"

````