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

# List transactions

> Fetch paginated transaction history for an embedded wallet with the Swift and Android SDKs

Privy's Swift and Android SDKs let an app fetch the transaction history for an embedded Ethereum or
Solana wallet, with support for filtering by asset, token, or transaction hash, and paginating
through results.

<Warning>
  Only TEE wallets support fetching transaction history. Calling `getTransactions` on a wallet that
  isn't a TEE wallet returns an error.
</Warning>

<View title="Swift" icon="swift">
  Use the `getTransactions` method on an embedded wallet to fetch its paginated transaction history.

  ```swift theme={"system"}
  func getTransactions(_ params: GetTransactionsParams) async throws -> TransactionsPage
  ```

  ### Usage

  ```swift theme={"system"}
  // Ethereum
  guard let ethereumWallet = privy.user?.embeddedEthereumWallets.first else { return }

  let params = GetTransactionsParams(
      chain: .base,
      assets: ["eth"],
      limit: 20
  )

  let page = try await ethereumWallet.getTransactions(params)

  for transaction in page.transactions {
      print(transaction.transactionHash ?? "pending", transaction.status)
  }

  // Fetch the next page, if any
  if let nextCursor = page.nextCursor {
      let nextPage = try await ethereumWallet.getTransactions(
          GetTransactionsParams(chain: .base, assets: ["eth"], limit: 20, cursor: nextCursor)
      )
  }
  ```

  ```swift theme={"system"}
  // Solana
  guard let solanaWallet = privy.user?.embeddedSolanaWallets.first else { return }

  let page = try await solanaWallet.getTransactions(
      GetTransactionsParams(chain: .solana, assets: ["sol"], limit: 20)
  )
  ```

  ### Parameters

  <ParamField path="params" type="GetTransactionsParams" required>
    The filters and pagination options for the transaction history request.

    <Expandable title="child attributes" defaultOpen="true">
      <ParamField path="chain" type="TransactionChain" required>
        The chain to fetch transactions for, e.g. `.base`, `.ethereum`, `.solana`, or
        `.custom(chainSlug)` for other supported chains.
      </ParamField>

      <ParamField path="assets" type="[String]?">
        Filter by named asset, e.g. `["eth"]` or `["usdc"]`. Mutually exclusive with `tokens`.
      </ParamField>

      <ParamField path="tokens" type="[String]?">
        Filter by token contract address (EVM) or mint address (Solana). Mutually exclusive
        with `assets`.
      </ParamField>

      <ParamField path="txHash" type="String?">
        Filter to a single transaction by its hash. EVM hashes are `0x`-prefixed 64 hex
        characters; Solana hashes are 87-88 base58 characters.
      </ParamField>

      <ParamField path="limit" type="Int?">
        The maximum number of transactions to return in this page.
      </ParamField>

      <ParamField path="cursor" type="String?">
        A pagination cursor from a previous `TransactionsPage.nextCursor`, used to fetch the
        next page of results.
      </ParamField>

      <ParamField path="includeArchived" type="Bool?">
        Whether to include transactions from archived wallets. Defaults to `false`.
      </ParamField>
    </Expandable>
  </ParamField>

  ### Returns

  <ResponseField name="TransactionsPage" type="TransactionsPage">
    The requested page of transaction history.

    <Expandable title="child attributes" defaultOpen="true">
      <ResponseField name="transactions" type="[WalletTransaction]">
        The transactions in this page.

        <Expandable title="child attributes">
          <ResponseField name="caip2" type="String">
            The CAIP-2 chain ID for the network the transaction was broadcasted on, e.g. `eip155:8453`.
          </ResponseField>

          <ResponseField name="transactionHash" type="String?">
            The hash of the transaction, if it has been broadcasted.
          </ResponseField>

          <ResponseField name="userOperationHash" type="String?">
            The ERC-4337 user operation hash, for smart-contract wallets only.
          </ResponseField>

          <ResponseField name="status" type="TransactionStatus">
            The current status of the transaction: `.broadcasted`, `.confirmed`,
            `.executionReverted`, `.failed`, `.replaced`, `.finalized`, `.providerError`,
            `.pending`, or `.unknown(rawValue)`.
          </ResponseField>

          <ResponseField name="createdAt" type="Int">
            The creation time of the transaction, in milliseconds since the Unix epoch.
          </ResponseField>

          <ResponseField name="sponsored" type="Bool">
            Whether gas for the transaction was sponsored.
          </ResponseField>

          <ResponseField name="privyTransactionId" type="String?">
            Privy's internal ID for the transaction, if available.
          </ResponseField>

          <ResponseField name="walletId" type="String">
            The ID of the wallet that sent the transaction.
          </ResponseField>

          <ResponseField name="details" type="TransactionDetails?">
            Additional details about the transaction, present for transfer transactions.

            <Expandable title="child attributes">
              <ResponseField name="type" type="TransactionType">
                `.transferSent`, `.transferReceived`, or `.unknown(rawValue)`.
              </ResponseField>

              <ResponseField name="sender" type="String">
                The address that sent the transaction.
              </ResponseField>

              <ResponseField name="senderPrivyUserId" type="String?">
                The Privy user ID for the sender, if known.
              </ResponseField>

              <ResponseField name="recipient" type="String">
                The address that received the transaction.
              </ResponseField>

              <ResponseField name="recipientPrivyUserId" type="String?">
                The Privy user ID for the recipient, if known.
              </ResponseField>

              <ResponseField name="chain" type="String">
                The chain the transaction occurred on.
              </ResponseField>

              <ResponseField name="asset" type="String">
                The asset transferred, e.g. `"eth"` or a token contract/mint address.
              </ResponseField>

              <ResponseField name="rawValue" type="String">
                The raw transferred amount, as a string to avoid floating-point precision loss.
              </ResponseField>

              <ResponseField name="rawValueDecimals" type="Int">
                The number of decimals for `rawValue`.
              </ResponseField>

              <ResponseField name="displayValues" type="[String: String]">
                Formatted, human-readable amounts for the transfer.
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="nextCursor" type="String?">
        A cursor for fetching the next page of results. `nil` if there are no more results.
      </ResponseField>
    </Expandable>
  </ResponseField>
</View>

<View title="Android" icon="android">
  Use the `getTransactions` method on an embedded wallet to fetch its paginated transaction history.

  ```kotlin theme={"system"}
  public suspend fun getTransactions(
      params: GetTransactionsParams<TransactionChain.Evm>
  ): Result<TransactionsPage>

  public suspend fun getTransactions(
      params: GetTransactionsParams<TransactionChain.Solana>
  ): Result<TransactionsPage>
  ```

  ### Usage

  ```kotlin theme={"system"}
  // Ethereum
  val ethereumWallet = privy.user?.embeddedEthereumWallets?.first() ?: return

  val params = GetTransactionsParams(
      chain = TransactionChain.Evm.Base,
      assets = listOf("eth"),
      limit = 20,
  )

  val result = ethereumWallet.getTransactions(params)

  result.fold(
      onSuccess = { page ->
          page.transactions.forEach { transaction ->
              println("${transaction.transactionHash}: ${transaction.status}")
          }

          // Fetch the next page, if any, reusing the same filters
          page.nextCursor?.let { nextCursor ->
              ethereumWallet.getTransactions(params.copy(cursor = nextCursor))
          }
      },
      onFailure = { error ->
          // Handle error
      }
  )
  ```

  ```kotlin theme={"system"}
  // Solana
  val solanaWallet = privy.user?.embeddedSolanaWallets?.first() ?: return

  val result = solanaWallet.getTransactions(
      GetTransactionsParams(
          chain = TransactionChain.Solana.Mainnet,
          assets = listOf("sol"),
          limit = 20,
      )
  )
  ```

  ### Parameters

  <ParamField path="params" type="GetTransactionsParams" required>
    The filters and pagination options for the transaction history request. The type parameter
    is inferred automatically from the `chain` you pass in, so it doesn't need to be specified
    explicitly.

    <Expandable title="child attributes" defaultOpen="true">
      <ParamField path="chain" type="TransactionChain.Evm | TransactionChain.Solana" required>
        The chain to fetch transactions for. Pass a `TransactionChain.Evm` case (e.g.
        `TransactionChain.Evm.Base`) when calling from an `EmbeddedEthereumWallet`, or a
        `TransactionChain.Solana` case (e.g. `TransactionChain.Solana.Mainnet`) when calling
        from an `EmbeddedSolanaWallet`.
      </ParamField>

      <ParamField path="assets" type="List<String>?">
        Filter by named asset, e.g. `listOf("eth")` or `listOf("usdc")`. Mutually exclusive
        with `tokens`.
      </ParamField>

      <ParamField path="tokens" type="List<String>?">
        Filter by token contract address (EVM) or mint address (Solana). Mutually exclusive
        with `assets`.
      </ParamField>

      <ParamField path="txHash" type="String?">
        Filter to a single transaction by its hash. EVM hashes are `0x`-prefixed 64 hex
        characters; Solana hashes are 87-88 base58 characters.
      </ParamField>

      <ParamField path="limit" type="Int?">
        The maximum number of transactions to return in this page.
      </ParamField>

      <ParamField path="cursor" type="String?">
        A pagination cursor from a previous `TransactionsPage.nextCursor`, used to fetch the
        next page of results.
      </ParamField>

      <ParamField path="includeArchived" type="Boolean?">
        Whether to include transactions from archived wallets. Defaults to `false`.
      </ParamField>
    </Expandable>
  </ParamField>

  ### Returns

  <ResponseField name="result" type="Result<TransactionsPage>">
    A `Result` that, when successful, contains the requested page of transaction history.

    <Expandable title="child attributes" defaultOpen="true">
      <ResponseField name="transactions" type="List<Transaction>">
        The transactions in this page.

        <Expandable title="child attributes">
          <ResponseField name="caip2" type="String">
            The CAIP-2 chain ID for the network the transaction was broadcasted on, e.g. `eip155:8453`.
          </ResponseField>

          <ResponseField name="transactionHash" type="String?">
            The hash of the transaction, if it has been broadcasted.
          </ResponseField>

          <ResponseField name="userOperationHash" type="String?">
            The ERC-4337 user operation hash, for smart-contract wallets only.
          </ResponseField>

          <ResponseField name="status" type="TransactionStatus">
            The current status of the transaction: `Broadcasted`, `Confirmed`,
            `ExecutionReverted`, `Failed`, `Replaced`, `Finalized`, `ProviderError`,
            `Pending`, or `Unknown(rawValue)`.
          </ResponseField>

          <ResponseField name="createdAt" type="Long">
            The creation time of the transaction, in milliseconds since the Unix epoch.
          </ResponseField>

          <ResponseField name="sponsored" type="Boolean">
            Whether gas for the transaction was sponsored.
          </ResponseField>

          <ResponseField name="privyTransactionId" type="String?">
            Privy's internal ID for the transaction, if available.
          </ResponseField>

          <ResponseField name="walletId" type="String">
            The ID of the wallet that sent the transaction.
          </ResponseField>

          <ResponseField name="details" type="TransactionDetails?">
            Additional details about the transaction, present for transfer transactions.

            <Expandable title="child attributes">
              <ResponseField name="type" type="TransactionType">
                `TransferSent`, `TransferReceived`, or `Unknown(rawValue)`.
              </ResponseField>

              <ResponseField name="sender" type="String">
                The address that sent the transaction.
              </ResponseField>

              <ResponseField name="senderPrivyUserId" type="String?">
                The Privy user ID for the sender, if known.
              </ResponseField>

              <ResponseField name="recipient" type="String">
                The address that received the transaction.
              </ResponseField>

              <ResponseField name="recipientPrivyUserId" type="String?">
                The Privy user ID for the recipient, if known.
              </ResponseField>

              <ResponseField name="chain" type="String">
                The chain the transaction occurred on.
              </ResponseField>

              <ResponseField name="asset" type="String">
                The asset transferred, e.g. `"eth"` or a token contract/mint address.
              </ResponseField>

              <ResponseField name="rawValue" type="String">
                The raw transferred amount, as a string to avoid floating-point precision loss.
              </ResponseField>

              <ResponseField name="rawValueDecimals" type="Int">
                The number of decimals for `rawValue`.
              </ResponseField>

              <ResponseField name="displayValues" type="Map<String, String>">
                Formatted, human-readable amounts for the transfer.
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="nextCursor" type="String?">
        A cursor for fetching the next page of results. `null` if there are no more results.
      </ResponseField>
    </Expandable>
  </ResponseField>
</View>
