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

# Solana Integration

> Sign Solana transactions using Para's unified wallet architecture

export const Card = ({imgUrl, title, description, href, horizontal = false, newTab = false}) => {
  const [isHovered, setIsHovered] = useState(false);
  const handleClick = e => {
    e.preventDefault();
    if (newTab) {
      window.open(href, '_blank', 'noopener,noreferrer');
    } else {
      window.location.href = href;
    }
  };
  return <div className={`not-prose relative my-2 p-[1px] rounded-xl transition-all duration-300 ${isHovered ? 'bg-gradient-to-r from-[#FF4E00] to-[#874AE3]' : 'bg-gray-200'}`} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
      <a href={href} onClick={handleClick} className={`not-prose flex ${horizontal ? 'flex-row' : 'flex-col'} font-normal h-full bg-white overflow-hidden w-full cursor-pointer rounded-[11px] no-underline`}>
        {imgUrl && <div className={`relative overflow-hidden flex-shrink-0 ${horizontal ? 'w-[30%] rounded-l-[11px]' : 'w-full'}`} onClick={e => e.stopPropagation()}>
            <img src={imgUrl} alt={title} className="w-full h-full object-cover pointer-events-none select-none" draggable="false" />
            <div className="absolute inset-0 pointer-events-none" />
          </div>}
        <div className={`flex-grow px-6 py-5 ${horizontal ? 'w-[70%]' : 'w-full'} flex flex-col ${horizontal && imgUrl ? 'justify-center' : 'justify-start'}`}>
          {title && <h2 className="font-semibold text-base text-gray-800 m-0">{title}</h2>}
          {description && <div className={`font-normal text-gray-500 re leading-6 ${horizontal || !imgUrl ? 'mt-0' : 'mt-1'}`}>
              <p className="m-0 text-xs">{description}</p>
            </div>}
        </div>
      </a>
    </div>;
};

## Quick Start

```swift theme={null}
import ParaSwift

// Sign a Solana transaction
let paraManager = ParaManager(apiKey: "your-api-key")
// Get an existing Solana wallet or create one
let wallets = try await paraManager.fetchWallets()
let wallet: Wallet
if let existing = wallets.first(where: { $0.type == .solana }) {
    wallet = existing
} else {
    wallet = try await paraManager.createWallet(type: .solana, skipDistributable: false)
}

let transaction = try SolanaTransaction(
    to: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    lamports: UInt64(1_000_000), // 0.001 SOL
    feePayer: nil, // Uses wallet as fee payer
    recentBlockhash: nil // Fetched automatically with RPC URL
)

let result = try await paraManager.signTransaction(
    walletId: wallet.id,
    transaction: transaction,
    chainId: nil, // Not needed for Solana
    rpcUrl: "https://api.devnet.solana.com"
)
print("Transaction signed: \(result.signedTransaction)")
```

## Common Operations

### Sign Transaction

```swift theme={null}
let transaction = try SolanaTransaction(
    to: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    lamports: UInt64(1_000_000), // 0.001 SOL
    feePayer: nil, // Uses wallet as fee payer
    recentBlockhash: nil // Fetched automatically with RPC URL
)

let result = try await paraManager.signTransaction(
    walletId: wallet.id,
    transaction: transaction,
    chainId: nil, // Not needed for Solana
    rpcUrl: "https://api.devnet.solana.com"
)
print("Signed: \(result.signedTransaction)")
```

### Check Balance

```swift theme={null}
let balance = try await paraManager.getBalance(
    walletId: wallet.id,
    token: nil, // Native SOL
    rpcUrl: "https://api.devnet.solana.com"
)

// Convert lamports to SOL
let lamports = Double(balance) ?? 0
let sol = lamports / 1_000_000_000
print("Balance: \(String(format: "%.4f", sol)) SOL")
```

### Sign Message

```swift theme={null}
let message = "Hello, Solana!"
let result = try await paraManager.signMessage(
    walletId: wallet.id,
    message: message
)
print("Signature: \(result.signedTransaction)")
```

## Networks

### Testnets

| Network     | RPC URL                          | Native Token |
| ----------- | -------------------------------- | ------------ |
| **Devnet**  | `https://api.devnet.solana.com`  | SOL          |
| **Testnet** | `https://api.testnet.solana.com` | SOL          |

### Mainnets

| Network     | RPC URL                                            | Native Token | Network Type |
| ----------- | -------------------------------------------------- | ------------ | ------------ |
| **Mainnet** | `https://api.mainnet-beta.solana.com`              | SOL          | Production   |
| **Alchemy** | `https://solana-mainnet.g.alchemy.com/v2/YOUR_KEY` | SOL          | Production   |

## Complete Example

```swift theme={null}
import SwiftUI
import ParaSwift

struct SolanaWalletView: View {
    @EnvironmentObject var paraManager: ParaManager
    @State private var isLoading = false
    @State private var signature: String?
    
    let wallet: Wallet
    private let rpcUrl = "https://api.devnet.solana.com"
    
    var body: some View {
        VStack(spacing: 20) {
            Text(wallet.address ?? "No address")
                .font(.system(.caption, design: .monospaced))
            
            Button(action: signTransaction) {
                Text(isLoading ? "Signing..." : "Sign Transaction")
            }
            .disabled(isLoading)
            
            if let signature = signature {
                Text("Signed: \(signature)")
                    .font(.caption)
            }
        }
        .padding()
    }
    
    private func signTransaction() {
        isLoading = true
        Task {
            do {
                let transaction = try SolanaTransaction(
                    to: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
                    lamports: 1_000_000, // 0.001 SOL
                    feePayer: nil,
                    recentBlockhash: nil
                )
                
                let result = try await paraManager.signTransaction(
                    walletId: wallet.id,
                    transaction: transaction,
                    chainId: nil, // Not needed for Solana
                    rpcUrl: rpcUrl
                )
                signature = result.signedTransaction
            } catch {
                print("Error: \(error)")
            }
            isLoading = false
        }
    }
}
```

## Advanced Transaction Options

```swift theme={null}
// Transaction with compute budget
let transaction = try SolanaTransaction(
    to: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    lamports: UInt64(1_000_000),
    computeUnitLimit: UInt32(200_000), // Set compute budget
    computeUnitPrice: UInt64(1_000) // Set priority fee
)

// Transaction with custom blockhash
let transaction = try SolanaTransaction(
    to: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    lamports: UInt64(1_000_000),
    recentBlockhash: "custom_blockhash",
    feePayer: wallet.address
)
```

## Pre-Serialized Transactions

Sign base64-encoded Solana transactions from dApps or backend services.

```swift theme={null}
let base64Transaction = "AQABA8GlkLb8bd/L6i5/YftGpxyig/iBvof2eNEF9WPF2o0Z..."

let result = try await paraManager.signSolanaSerializedTransaction(
    walletId: wallet.id,
    base64Tx: base64Transaction
)
```

### Use Cases

```swift theme={null}
// From dApp
let serializedTx = dApp.getSerializedTransaction()
let signature = try await paraManager.signSolanaSerializedTransaction(
    walletId: wallet.id,
    base64Tx: serializedTx
)

// From backend
let preparedTx = await backend.prepareTransaction()
let result = try await paraManager.signSolanaSerializedTransaction(
    walletId: wallet.id,
    base64Tx: preparedTx.serialized
)
```

Accepts base64-encoded bytes from `transaction.serializeMessage()` or compatible Solana SDKs.
